Skip to content

Commit b82932a

Browse files
committed
feature: acquire exact tarantool version
Sometimes we want to test a module against specific tarantool version, not a latest in the series. For example, 2.6 series may have 2.6.1, 2.6.2 and 2.6.3 releases and we want to setup 2.6.1. Fixes #15
1 parent 966c6c1 commit b82932a

File tree

6 files changed

+407
-20
lines changed

6 files changed

+407
-20
lines changed
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Usage example:
2+
#
3+
# - steps:
4+
# - id: latest_version
5+
# uses: ./.github/actions/latest-version
6+
# with:
7+
# tarantool-series: '1.10' # don't miss quotes!
8+
#
9+
# - run: echo ${{ steps.latest-version.outputs.package }}
10+
# # ---> 1.10.13.0.g1d2c5aad5-1
11+
# - run: echo ${{ steps.latest-version.outputs.abc }}
12+
# # ---> 1.10.13
13+
# - run: echo ${{ steps.latest-version.outputs.abcd }}
14+
# # ---> 1.10.13.0
15+
# - run: echo ${{ steps.latest-version.outputs.abc-d }}
16+
# # ---> 1.10.13-0
17+
# - run: echo ${{ steps.latest-version.outputs.git-describe }}
18+
# # ---> 1.10.13-0-g1d2c5aad5
19+
20+
name: 'Latest tarantool version'
21+
description: 'Get latest tarantool version of given release series'
22+
inputs:
23+
tarantool-series:
24+
description: 'Tarantool release series'
25+
required: true
26+
nightly-build:
27+
description: 'Whether to look into a repository with nightly builds'
28+
required: false
29+
default: false
30+
outputs:
31+
package:
32+
description: 'Latest tarantool version in the Debian package format'
33+
value: ${{ steps.get-latest-version.outputs.package }}
34+
abc:
35+
description: 'Latest tarantool version in the A.B.C form'
36+
value: ${{ steps.get-latest-version.outputs.abc }}
37+
abcd:
38+
description: 'Latest tarantool version in the A.B.C.D form'
39+
value: ${{ steps.get-latest-version.outputs.abcd }}
40+
abc-d:
41+
description: 'Latest tarantool version in the A.B.C-D form'
42+
value: ${{ steps.get-latest-version.outputs.abc-d }}
43+
git-describe:
44+
description: 'Latest tarantool version in the A.B.C-D-gHHHHHHHHH form'
45+
value: ${{ steps.get-latest-version.outputs.git-describe }}
46+
runs:
47+
using: 'composite'
48+
steps:
49+
- id: get-latest-version
50+
run: |
51+
node <<'SCRIPT'
52+
process.env['INPUT_TARANTOOL-VERSION'] = '${{ inputs.tarantool-series }}'
53+
process.env['INPUT_NIGHTLY-BUILD'] = '${{ inputs.nightly-build }}'
54+
require('./dist/main').latest_version().then(v => {
55+
console.log(`package: ${v}`)
56+
console.log(`::set-output name=package::${v}`)
57+
58+
/* 1.10.13.0.g1d2c5aad5-1
59+
* ->
60+
* parts[0]: '1'
61+
* parts[1]: '10'
62+
* parts[2]: '13'
63+
* parts[3]: '0'
64+
* parts[4]: 'g1d2c5aad5'
65+
* parts[5]: '1'
66+
*/
67+
var parts = v.split(/[.-]/)
68+
69+
var abc = parts.slice(0, 3).join('.')
70+
var abcd = `${abc}.${parts[3]}`
71+
var abc_d = `${abc}-${parts[3]}`
72+
var git_describe = `${abc_d}-${parts[4]}`
73+
74+
console.log(`abc: ${abc}`)
75+
console.log(`abcd: ${abcd}`)
76+
console.log(`abc-d: ${abc_d}`)
77+
console.log(`git-describe: ${git_describe}`)
78+
79+
console.log(`::set-output name=abc::${abc}`)
80+
console.log(`::set-output name=abcd::${abcd}`)
81+
console.log(`::set-output name=abc-d::${abc_d}`)
82+
console.log(`::set-output name=git-describe::${git_describe}`)
83+
})
84+
SCRIPT
85+
shell: bash
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Usage example:
2+
#
3+
# - steps:
4+
# - uses: ./.github/actions/verify-version
5+
# with:
6+
# tarantool-version: '1.10.12' # don't miss quotes!
7+
# from-cache: false
8+
9+
name: 'Verify tarantool version'
10+
description: 'Verify that installed tarantool has given version'
11+
inputs:
12+
tarantool-version:
13+
description: 'Expected tarantool version (version string prefix)'
14+
required: true
15+
from-cache:
16+
description: 'Expect tarantool from cache or from apt-get (if omitted, does not perform the check)'
17+
required: false
18+
default: ''
19+
runs:
20+
using: 'composite'
21+
steps:
22+
- name: Verify tarantool version
23+
run: |
24+
tarantool -e "assert(_TARANTOOL:startswith('${{ inputs.tarantool-version }}'), _TARANTOOL)"
25+
shell: bash
26+
27+
- name: Verify that tarantool is installed from the cache
28+
run: |
29+
if dpkg --status tarantool; then
30+
echo "Tarantool is installed by apt-get, but it is expected that"
31+
echo "tarantool will be installed from the cache"
32+
exit 1
33+
fi
34+
if: inputs.from-cache == 'true'
35+
shell: bash
36+
37+
- name: Verify that tarantool is installed by apt-get (not from the cache)
38+
run: |
39+
dpkg --status tarantool
40+
if: inputs.from-cache == 'false'
41+
shell: bash

.github/workflows/test.yml

+211
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,214 @@ jobs:
9090
uses: ./
9191
with:
9292
tarantool-version: '1.10'
93+
94+
# This test case performs basic test of the three digit version
95+
# support.
96+
#
97+
# It performs the following steps and checks.
98+
#
99+
# - install 1.10.12
100+
# - checks: version, non-cached
101+
# - uninstall tarantool
102+
# - install 1.10.12
103+
# - checks: version, cached
104+
# - install 1.10.LATEST
105+
# - checks: version, non-cached
106+
test-exact-version-basic:
107+
runs-on: ubuntu-latest
108+
env:
109+
TARANTOOL_CACHE_KEY_SUFFIX: -C-${{ github.run_id }}
110+
steps:
111+
- uses: actions/checkout@v2
112+
113+
- id: latest-version
114+
uses: ./.github/actions/latest-version
115+
with:
116+
tarantool-series: '1.10'
117+
118+
- name: Install 1.10.12 (non-cached)
119+
uses: ./
120+
with:
121+
tarantool-version: '1.10.12'
122+
nightly-build: false
123+
124+
- uses: ./.github/actions/verify-version
125+
with:
126+
tarantool-version: '1.10.12-0-'
127+
from-cache: false
128+
129+
- name: Uninstall tarantool
130+
run: sudo apt-get -y remove tarantool tarantool-dev tarantool-common
131+
132+
- name: Install 1.10.12 (cached)
133+
uses: ./
134+
with:
135+
tarantool-version: '1.10.12'
136+
nightly-build: false
137+
138+
- uses: ./.github/actions/verify-version
139+
with:
140+
tarantool-version: '1.10.12-0-'
141+
from-cache: true
142+
143+
- name: Install 1.10.LATEST (non-cached)
144+
uses: ./
145+
with:
146+
tarantool-version: '${{ steps.latest-version.outputs.abc }}'
147+
nightly-build: false
148+
149+
- uses: ./.github/actions/verify-version
150+
with:
151+
tarantool-version: '${{ steps.latest-version.outputs.git-describe }}'
152+
from-cache: false
153+
154+
# This test case verifies that a two digit version is installed
155+
# without any problem after a three digit version (not a latest
156+
# one).
157+
#
158+
# - install 1.10.12
159+
# - checks: version, non-cached
160+
# - uninstall tarantool
161+
# - install 1.10
162+
# - checks: version, non-cached
163+
test-exact-version-then-two-digit-version:
164+
runs-on: ubuntu-latest
165+
env:
166+
TARANTOOL_CACHE_KEY_SUFFIX: -D-${{ github.run_id }}
167+
steps:
168+
- uses: actions/checkout@v2
169+
170+
- id: latest-version
171+
uses: ./.github/actions/latest-version
172+
with:
173+
tarantool-series: '1.10'
174+
175+
- name: Install 1.10.12 (non-cached)
176+
uses: ./
177+
with:
178+
tarantool-version: '1.10.12'
179+
nightly-build: false
180+
181+
- uses: ./.github/actions/verify-version
182+
with:
183+
tarantool-version: '1.10.12-0-'
184+
from-cache: false
185+
186+
- name: Uninstall tarantool
187+
run: sudo apt-get -y remove tarantool tarantool-dev tarantool-common
188+
189+
- name: Install 1.10 (non-cached)
190+
uses: ./
191+
with:
192+
tarantool-version: '1.10'
193+
nightly-build: false
194+
195+
- uses: ./.github/actions/verify-version
196+
with:
197+
tarantool-version: '${{ steps.latest-version.outputs.git-describe }}'
198+
from-cache: false
199+
200+
# This test case verifies that a two digit version is installed
201+
# without any problem after a three digit version (the latest
202+
# one).
203+
#
204+
# - install 1.10.LATEST
205+
# - checks: version, non-cached
206+
# - uninstall tarantool
207+
# - install 1.10
208+
# - checks: version, cached
209+
test-exact-version-latest-then-two-digit-version:
210+
runs-on: ubuntu-latest
211+
env:
212+
TARANTOOL_CACHE_KEY_SUFFIX: -E-${{ github.run_id }}
213+
steps:
214+
- uses: actions/checkout@v2
215+
216+
- id: latest-version
217+
uses: ./.github/actions/latest-version
218+
with:
219+
tarantool-series: '1.10'
220+
221+
- name: Install 1.10.LATEST (non-cached)
222+
uses: ./
223+
with:
224+
tarantool-version: '${{ steps.latest-version.outputs.abc }}'
225+
nightly-build: false
226+
227+
- uses: ./.github/actions/verify-version
228+
with:
229+
tarantool-version: '${{ steps.latest-version.outputs.git-describe }}'
230+
from-cache: false
231+
232+
- name: Uninstall tarantool
233+
run: sudo apt-get -y remove tarantool tarantool-dev tarantool-common
234+
235+
- name: Install 1.10 (cached)
236+
uses: ./
237+
with:
238+
tarantool-version: '1.10'
239+
nightly-build: false
240+
241+
- uses: ./.github/actions/verify-version
242+
with:
243+
tarantool-version: '${{ steps.latest-version.outputs.git-describe }}'
244+
from-cache: true
245+
246+
# This test case performs basic test of four digit version
247+
# support (for nightly repositories).
248+
#
249+
# - install 1.10.LATEST.LATEST (nightly)
250+
# - checks: version, non-cached
251+
# - uninstall tarantool
252+
# - install 1.10.LATEST (nightly)
253+
# - checks: version, cached
254+
# - install 1.10 (nightly)
255+
# - checks: version, cached
256+
test-exact-version-nightly:
257+
runs-on: ubuntu-latest
258+
env:
259+
TARANTOOL_CACHE_KEY_SUFFIX: -F-${{ github.run_id }}
260+
steps:
261+
- uses: actions/checkout@v2
262+
263+
- id: latest-version
264+
uses: ./.github/actions/latest-version
265+
with:
266+
tarantool-series: '1.10'
267+
nightly-build: true
268+
269+
- name: Install 1.10.LATEST.LATEST (nightly, non-cached)
270+
uses: ./
271+
with:
272+
tarantool-version: '${{ steps.latest-version.outputs.abcd }}'
273+
nightly-build: true
274+
275+
- uses: ./.github/actions/verify-version
276+
with:
277+
tarantool-version: '${{ steps.latest-version.outputs.git-describe }}'
278+
from-cache: false
279+
280+
- name: Uninstall tarantool
281+
run: sudo apt-get -y remove tarantool tarantool-dev tarantool-common
282+
283+
- name: Install 1.10.LATEST (nightly, cached)
284+
uses: ./
285+
with:
286+
tarantool-version: '1.10'
287+
nightly-build: true
288+
289+
- uses: ./.github/actions/verify-version
290+
with:
291+
tarantool-version: '${{ steps.latest-version.outputs.git-describe }}'
292+
from-cache: true
293+
294+
- name: Install 1.10 (nightly, cached)
295+
uses: ./
296+
with:
297+
tarantool-version: '1.10'
298+
nightly-build: true
299+
300+
- uses: ./.github/actions/verify-version
301+
with:
302+
tarantool-version: '${{ steps.latest-version.outputs.git-describe }}'
303+
from-cache: true

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,24 @@ steps:
2424
- run: .rocks/bin/luatest -v
2525
```
2626
27+
### Install an exact version
28+
29+
```
30+
steps:
31+
- uses: actions/checkout@v2
32+
- uses: tarantool/setup-tarantool@v1
33+
with:
34+
tarantool-version: '2.6.1'
35+
```
36+
2737
### Install a nightly build
2838
2939
```yaml
3040
steps:
3141
- uses: actions/checkout@v2
3242
- uses: tarantool/setup-tarantool@v1
3343
with:
34-
tarantool-version: '2.6'
44+
tarantool-version: '2.6' # or, say, '2.6.1.0' for exact version
3545
nightly-build: true
3646
```
3747

0 commit comments

Comments
 (0)