Improve on "Add Windows to the mix" (#52)

d8a37f5 · Paulo F. Oliveira · 2021-07-08 14:35

26 files +499 -258
Message
{commit_body(@commit)}

Files changed

renamed .github/workflows/ci.yml → .github/workflows/action.yml
+12 −2
@@ -1,5 +1,5 @@
1 1 ---
2 −name: ci
2 +name: action
3 3
4 4 on:
5 5 push:
@@ -11,7 +11,7 @@ on:
11 11
12 12 jobs:
13 13 check_integrity:
14 − name: Make sure expected pre-release actions are performed
14 + name: Expected local npm actions
15 15 runs-on: ubuntu-latest
16 16 steps:
17 17 - uses: actions/checkout@v2
@@ -30,3 +30,13 @@ jobs:
30 30 - run: npm run licenses
31 31 - name: Check if build left artifacts
32 32 run: git diff --exit-code
33 +
34 + unit_test:
35 + name: Unit tests
36 + runs-on: ubuntu-latest
37 + steps:
38 + - uses: actions/checkout@v2
39 + - uses: actions/setup-node@v1
40 + with: {node-version: '12'}
41 + - run: npm ci
42 + - run: npm test
renamed .github/workflows/test.yml → .github/workflows/ubuntu.yml
+5 −57
@@ -1,5 +1,5 @@
1 1 ---
2 −name: test
2 +name: ubuntu
3 3
4 4 on:
5 5 push:
@@ -10,23 +10,11 @@ on:
10 10 - main
11 11
12 12 jobs:
13 − unit_test:
14 − name: Pre-release unit tests
15 − runs-on: ubuntu-latest
16 − steps:
17 − - uses: actions/checkout@v2
18 − - uses: actions/setup-node@v1
19 − with: {node-version: '12'}
20 − - run: npm ci
21 − - run: npm test
22 −
23 − integration_test_ubuntu:
13 + integration_test:
24 14 name: >
25 − Pre-release integration tests
26 − (Ubuntu ${{matrix.combo.os}},
27 − Erlang/OTP ${{matrix.combo.otp-version}},
28 − Elixir ${{matrix.combo.elixir-version}},
29 − rebar3 ${{matrix.combo.rebar3-version}})
15 + OTP ${{matrix.combo.otp-version}},
16 + Elixir ${{matrix.combo.elixir-version}},
17 + rebar3 ${{matrix.combo.rebar3-version}}
30 18 runs-on: ${{matrix.combo.os}}
31 19 strategy:
32 20 fail-fast: false
@@ -138,43 +126,3 @@ jobs:
138 126 cd test-projects/rebar3
139 127 rebar3 ct
140 128 if: ${{matrix.combo.rebar3-version}}
141 −
142 − integration_test_windows:
143 − name: >
144 − Pre-release integration tests
145 − (Windows ${{matrix.combo.os}},
146 − Erlang/OTP ${{matrix.combo.otp-version}},
147 − rebar3 ${{matrix.combo.rebar3-version}})
148 − runs-on: ${{matrix.combo.os}}
149 − strategy:
150 − fail-fast: false
151 − matrix:
152 − combo:
153 − - otp-version: '24.0.2'
154 − rebar3-version: '3.16'
155 − os: 'windows-2019'
156 − - otp-version: '23.0'
157 − rebar3-version: '3.15'
158 − os: 'windows-2019'
159 − - otp-version: '24.0.2'
160 − rebar3-version: '3.16'
161 − os: 'windows-2016'
162 − - otp-version: '23.0'
163 − rebar3-version: '3.15'
164 − os: 'windows-2016'
165 − steps:
166 − - uses: actions/checkout@v2
167 − - name: Use erlef/setup-beam
168 − id: setup-beam
169 − uses: ./
170 − with:
171 − otp-version: ${{matrix.combo.otp-version}}
172 − rebar3-version: ${{matrix.combo.rebar3-version}}
173 − - name: Erlang/OTP version (action)
174 − run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}"
175 − - name: rebar3 version (action)
176 − run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}"
177 − - name: Run rebar3 project tests
178 − run: |
179 − cd test-projects/rebar3
180 − rebar3 ct
added .github/workflows/windows.yml
+87 −0
@@ -0,0 +1,87 @@
1 +---
2 +name: windows
3 +
4 +on:
5 + push:
6 + branches:
7 + - main
8 + pull_request:
9 + branches:
10 + - main
11 +
12 +jobs:
13 + integration_test:
14 + name: >
15 + OTP ${{matrix.combo.otp-version}},
16 + Elixir ${{matrix.combo.elixir-version}},
17 + rebar3 ${{matrix.combo.rebar3-version}}
18 + runs-on: ${{matrix.combo.os}}
19 + strategy:
20 + fail-fast: false
21 + matrix:
22 + combo:
23 + - otp-version: '24.0.2'
24 + rebar3-version: '3.16'
25 + os: 'windows-2019'
26 + - otp-version: '23.0'
27 + rebar3-version: '3.15'
28 + os: 'windows-2019'
29 + - otp-version: '24.0.2'
30 + rebar3-version: '3.16'
31 + os: 'windows-2016'
32 + - otp-version: '23.0'
33 + rebar3-version: '3.15'
34 + os: 'windows-2016'
35 + - otp-version: '22.3'
36 + rebar3-version: '3.15'
37 + os: 'windows-2016'
38 + - otp-version: '22.0'
39 + rebar3-version: '3.15'
40 + os: 'windows-2016'
41 + - otp-version: '21.3'
42 + rebar3-version: '3.15'
43 + os: 'windows-2016'
44 + - otp-version: '21.0'
45 + rebar3-version: '3.15'
46 + os: 'windows-2016'
47 + - elixir-version: 'v1.10'
48 + otp-version: '23'
49 + rebar3-version: '3.14'
50 + os: 'windows-latest'
51 + - elixir-version: 'v1.11'
52 + otp-version: '24'
53 + rebar3-version: '3.15'
54 + os: 'windows-latest'
55 + steps:
56 + - uses: actions/checkout@v2
57 + - name: Use erlef/setup-beam
58 + id: setup-beam
59 + uses: ./
60 + with:
61 + otp-version: ${{matrix.combo.otp-version}}
62 + elixir-version: ${{matrix.combo.elixir-version}}
63 + rebar3-version: ${{matrix.combo.rebar3-version}}
64 + - name: Erlang/OTP version (action)
65 + run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}"
66 + - name: Elixir version (action)
67 + run: echo "Elixir ${{steps.setup-beam.outputs.elixir-version}}"
68 + if: ${{matrix.combo.elixir-version}}
69 + - name: rebar3 version (action)
70 + run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}"
71 + - name: mix version and help (CLI)
72 + run: |
73 + mix -v
74 + mix help local.rebar
75 + mix help local.hex
76 + if: ${{matrix.combo.elixir-version}}
77 + - name: Run Mix project tests
78 + run: |
79 + cd test-projects/mix
80 + mix deps.get
81 + mix test
82 + if: ${{matrix.combo.elixir-version}}
83 + - name: Run rebar3 project tests
84 + run: |
85 + cd test-projects/rebar3
86 + rebar3 ct
87 + if: ${{matrix.combo.rebar3-version}}
modified README.md
+28 −23
@@ -1,10 +1,12 @@
1 1 <!-- markdownlint-disable MD013 -->
2 −# setup-beam [![GitHub Actions Test][test-img]][test] [![GitHub Actions CI][ci-img]][ci]
2 +# setup-beam [![GitHub Actions][action-img]][action] [![GitHub Actions][ubuntu-img]][ubuntu] [![GitHub Actions][windows-img]][windows]
3 3
4 −[test]: https://github.com/erlef/setup-beam
5 −[test-img]: https://github.com/erlef/setup-beam/workflows/test/badge.svg
6 −[ci]: https://github.com/erlef/setup-beam
7 −[ci-img]: https://github.com/erlef/setup-beam/workflows/ci/badge.svg
4 +[action]: https://github.com/erlef/setup-beam
5 +[action-img]: https://github.com/erlef/setup-beam/workflows/action/badge.svg
6 +[ubuntu]: https://github.com/erlef/setup-beam
7 +[ubuntu-img]: https://github.com/erlef/setup-beam/workflows/ubuntu/badge.svg
8 +[windows]: https://github.com/erlef/setup-beam
9 +[windows-img]: https://github.com/erlef/setup-beam/workflows/windows/badge.svg
8 10
9 11 This action sets up an Erlang/OTP environment for use in a GitHub Actions
10 12 workflow by:
@@ -14,7 +16,7 @@ workflow by:
14 16 - optionally, installing `rebar3`
15 17 - optionally, installing `hex`
16 18
17 −**Note** Currently, this action only supports Actions' `ubuntu-` runtimes.
19 +**Note** Currently, this action only supports Actions' `ubuntu-` and `windows-` runtimes.
18 20
19 21 ## Usage
20 22
@@ -23,9 +25,10 @@ See [action.yml](action.yml) for the action's specification.
23 25 **Note**: The Erlang/OTP release version specification is [relatively
24 26 complex](http://erlang.org/doc/system_principles/versions.html#version-scheme).
25 27 For best results, we recommend specifying exact Erlang/OTP, Elixir versions, and
26 −`rebar3` versions.
28 +`rebar3` versions, and setting option `version-type` to `strict`.
27 29 However, values like `22.x`, or even `>22`, are also accepted, and we attempt to resolve them
28 −according to semantic versioning rules.
30 +according to semantic versioning rules. This implicitly means `version-type` is `loose`,
31 +which is also the default value for this option.
29 32
30 33 Additionally, it is recommended that one specifies Erlang/OTP, Elixir and `rebar3` versions
31 34 using YAML strings, as these examples do, so that numbers like `23.0` don't
@@ -35,20 +38,22 @@ For pre-release Elixir versions, such as `1.11.0-rc.0`, use the full version
35 38 specifier (`1.11.0-rc.0`). Pre-release versions are opt-in, so `1.11.x` will
36 39 not match a pre-release.
37 40
38 −### Compatibility between Ubuntu and Erlang/OTP
41 +### Compatibility between Operating System and Erlang/OTP
39 42
40 −This list presents the known working version combos between Ubuntu
43 +This list presents the known working version combos between the target operating system
41 44 and Erlang/OTP.
42 45
43 −| Ubuntu | Erlang/OTP | Status
44 −|- |- |-
45 −| ubuntu-16.04 | 17 - 24 | ✅
46 −| ubuntu-18.04 | 17 - 24 | ✅
47 −| ubuntu-20.04 | 20 - 24 | ✅
48 −| windows-2016 | 23 - 24 | ✅
49 −| windows-2019 | 23 - 24 | ✅
46 +| Operating system | Erlang/OTP | Status
47 +|- |- |-
48 +| ubuntu-16.04 | 17 - 24 | ✅
49 +| ubuntu-18.04 | 17 - 24 | ✅
50 +| ubuntu-20.04 | 20 - 24 | ✅
51 +| windows-2016 | 21* - 24 | ✅
52 +| windows-2019 | 21* - 24 | ✅
50 53
51 −### Basic example (Elixir)
54 +**Note** *: prior to 23, Windows builds are only available for minor versions, e.g. 21.0, 21.3, 22.0, etc.
55 +
56 +### Basic example (Erlang/OTP + Elixir, on Ubuntu)
52 57
53 58 ```yaml
54 59 # create this in .github/workflows/ci.yml
@@ -67,7 +72,7 @@ jobs:
67 72 - run: mix test
68 73 ```
69 74
70 −### Basic example (`rebar3`)
75 +### Basic example (Erlang/OTP + `rebar3`, on Ubuntu)
71 76
72 77 ```yaml
73 78 # create this in .github/workflows/ci.yml
@@ -85,7 +90,7 @@ jobs:
85 90 - run: rebar3 ct
86 91 ```
87 92
88 −### Matrix example (Elixir)
93 +### Matrix example (Erlang/OTP + Elixir, on Ubuntu)
89 94
90 95 ```yaml
91 96 # create this in .github/workflows/ci.yml
@@ -109,7 +114,7 @@ jobs:
109 114 - run: mix test
110 115 ```
111 116
112 −### Matrix example (`rebar3`)
117 +### Matrix example (Erlang/OTP + `rebar3`, on Ubuntu)
113 118
114 119 ```yaml
115 120 # create this in .github/workflows/ci.yml
@@ -132,7 +137,7 @@ jobs:
132 137 - run: rebar3 ct
133 138 ```
134 139
135 −### Basic example (`rebar3` on Windows 2016)
140 +### Basic example (Erlang/OTP + `rebar3`, on Windows)
136 141
137 142 ```yaml
138 143 # create this in .github/workflows/ci.yml
@@ -145,7 +150,7 @@ jobs:
145 150 - uses: actions/checkout@v2
146 151 - uses: erlef/setup-beam@v1
147 152 with:
148 − otp-version: '24.0.2'
153 + otp-version: '24'
149 154 rebar3-version: '3.16.1'
150 155 - run: rebar3 ct
151 156 ```
modified __tests__/setup-beam.test.js
+158 −11
@@ -16,6 +16,8 @@ async function all() {
16 16 await testOTPVersions()
17 17 await testElixirVersions()
18 18 await testRebar3Versions()
19 +
20 + await testGetVersionFromSpec()
19 21 }
20 22
21 23 async function testFailInstallOTP() {
@@ -84,37 +86,37 @@ async function testOTPVersions() {
84 86 if (process.platform === 'linux') {
85 87 spec = '19.3.x'
86 88 osVersion = 'ubuntu-16.04'
87 − expected = 'OTP-19.3.6'
89 + expected = 'OTP-19.3.6.13'
88 90 got = await setupBeam.getOTPVersion(spec, osVersion)
89 91 assert.deepStrictEqual(got, expected)
90 92
91 93 spec = '^19.3.6'
92 94 osVersion = 'ubuntu-16.04'
93 − expected = 'OTP-19.3.6'
95 + expected = 'OTP-19.3.6.13'
94 96 got = await setupBeam.getOTPVersion(spec, osVersion)
95 97 assert.deepStrictEqual(got, expected)
96 98
97 99 spec = '^19.3'
98 100 osVersion = 'ubuntu-18.04'
99 − expected = 'OTP-19.3.6'
101 + expected = 'OTP-19.3.6.13'
100 102 got = await setupBeam.getOTPVersion(spec, osVersion)
101 103 assert.deepStrictEqual(got, expected)
102 104
103 105 spec = '20'
104 106 osVersion = 'ubuntu-20.04'
105 − expected = 'OTP-20.3.8'
107 + expected = 'OTP-20.3.8.26'
106 108 got = await setupBeam.getOTPVersion(spec, osVersion)
107 109 assert.deepStrictEqual(got, expected)
108 110
109 111 spec = '20.x'
110 112 osVersion = 'ubuntu-20.04'
111 − expected = 'OTP-20.3.8'
113 + expected = 'OTP-20.3.8.26'
112 114 got = await setupBeam.getOTPVersion(spec, osVersion)
113 115 assert.deepStrictEqual(got, expected)
114 116
115 117 spec = '20.0'
116 118 osVersion = 'ubuntu-20.04'
117 − expected = 'OTP-20.0'
119 + expected = 'OTP-20.0.5'
118 120 got = await setupBeam.getOTPVersion(spec, osVersion)
119 121 assert.deepStrictEqual(got, expected)
120 122
@@ -134,13 +136,13 @@ async function testOTPVersions() {
134 136
135 137 spec = '23.2.x'
136 138 osVersion = 'windows-2016'
137 − expected = '23.2.7'
139 + expected = '23.2.7.4'
138 140 got = await setupBeam.getOTPVersion(spec, osVersion)
139 141 assert.deepStrictEqual(got, expected)
140 142
141 143 spec = '23.0'
142 144 osVersion = 'windows-2019'
143 − expected = '23.0'
145 + expected = '23.0.4'
144 146 got = await setupBeam.getOTPVersion(spec, osVersion)
145 147 assert.deepStrictEqual(got, expected)
146 148 }
@@ -164,11 +166,13 @@ async function testElixirVersions() {
164 166 got = await setupBeam.getElixirVersion(spec, otpVersion)
165 167 assert.deepStrictEqual(got, expected)
166 168
167 − spec = '1.11.0-rc.0'
169 + simulateInput('version-type', 'strict')
170 + spec = 'v1.11.0-rc.0'
168 171 otpVersion = 'OTP-23'
169 172 expected = 'v1.11.0-rc.0-otp-23'
170 173 got = await setupBeam.getElixirVersion(spec, otpVersion)
171 174 assert.deepStrictEqual(got, expected)
175 + simulateInput('version-type', 'loose')
172 176 }
173 177
174 178 async function testRebar3Versions() {
@@ -181,8 +185,8 @@ async function testRebar3Versions() {
181 185 got = await setupBeam.getRebar3Version(spec)
182 186 assert.deepStrictEqual(got, expected)
183 187
184 − spec = '3.10.0'
185 − expected = '3.10.0'
188 + spec = '3.11'
189 + expected = '3.11.1'
186 190 got = await setupBeam.getRebar3Version(spec)
187 191 assert.deepStrictEqual(got, expected)
188 192
@@ -192,6 +196,149 @@ async function testRebar3Versions() {
192 196 assert.deepStrictEqual(got, expected)
193 197 }
194 198
199 +async function testGetVersionFromSpec() {
200 + let got
201 + let expected
202 + let spec
203 + const versions = [
204 + '3.2.30.5',
205 + '3.2.3.5',
206 + '1',
207 + '2',
208 + '3.2.3.4.1',
209 + '1.0.9',
210 + '3.2.3.40.1',
211 + '1.0.2',
212 + '2.0',
213 + '2.10',
214 + '2.9',
215 + '1.0',
216 + '3.2.3.4.2',
217 + '1.1.0',
218 + '3.4.5.4',
219 + '3.4.5.3',
220 + '3.4.5.4.1',
221 + '24.0-rc3',
222 + '24.0-rc2',
223 + '24.0',
224 + '23.3.4',
225 + '23.3.3',
226 + '22.3.4.9.1',
227 + '22.3.4.12.1',
228 + '22.3.4.10.1',
229 + 'master',
230 + 'v11.11.0-rc.0-otp-23',
231 + ]
232 +
233 + spec = '1'
234 + expected = '1.1.0'
235 + got = setupBeam.getVersionFromSpec(spec, versions)
236 + assert.deepStrictEqual(got, expected)
237 +
238 + spec = '1.0'
239 + expected = '1.0.9'
240 + got = setupBeam.getVersionFromSpec(spec, versions)
241 + assert.deepStrictEqual(got, expected)
242 +
243 + simulateInput('version-type', 'strict')
244 + spec = '1'
245 + expected = '1'
246 + got = setupBeam.getVersionFromSpec(spec, versions)
247 + assert.deepStrictEqual(got, expected)
248 + simulateInput('version-type', 'loose')
249 +
250 + simulateInput('version-type', 'strict')
251 + spec = '1.0'
252 + expected = '1.0'
253 + got = setupBeam.getVersionFromSpec(spec, versions)
254 + assert.deepStrictEqual(got, expected)
255 + simulateInput('version-type', 'loose')
256 +
257 + spec = '2'
258 + expected = '2.10'
259 + got = setupBeam.getVersionFromSpec(spec, versions)
260 + assert.deepStrictEqual(got, expected)
261 +
262 + spec = '3'
263 + expected = '3.4.5.4.1'
264 + got = setupBeam.getVersionFromSpec(spec, versions)
265 + assert.deepStrictEqual(got, expected)
266 +
267 + spec = '3.2'
268 + expected = '3.2.30.5'
269 + got = setupBeam.getVersionFromSpec(spec, versions)
270 + assert.deepStrictEqual(got, expected)
271 +
272 + spec = '>20'
273 + expected = '24.0'
274 + got = setupBeam.getVersionFromSpec(spec, versions)
275 + assert.deepStrictEqual(got, expected)
276 +
277 + spec = '24.0'
278 + expected = '24.0'
279 + got = setupBeam.getVersionFromSpec(spec, versions)
280 + assert.deepStrictEqual(got, expected)
281 +
282 + simulateInput('version-type', 'strict')
283 + spec = '24.0-rc3'
284 + expected = '24.0-rc3'
285 + got = setupBeam.getVersionFromSpec(spec, versions)
286 + assert.deepStrictEqual(got, expected)
287 + simulateInput('version-type', 'loose')
288 +
289 + spec = '22.3'
290 + expected = '22.3.4.12.1'
291 + got = setupBeam.getVersionFromSpec(spec, versions)
292 + assert.deepStrictEqual(got, expected)
293 +
294 + spec = '23.3.3'
295 + expected = '23.3.3'
296 + got = setupBeam.getVersionFromSpec(spec, versions)
297 + assert.deepStrictEqual(got, expected)
298 +
299 + spec = '24'
300 + expected = '24.0'
301 + got = setupBeam.getVersionFromSpec(spec, versions)
302 + assert.deepStrictEqual(got, expected)
303 +
304 + spec = '23.3'
305 + expected = '23.3.4'
306 + got = setupBeam.getVersionFromSpec(spec, versions)
307 + assert.deepStrictEqual(got, expected)
308 +
309 + simulateInput('version-type', 'strict')
310 + spec = 'master'
311 + expected = 'master'
312 + got = setupBeam.getVersionFromSpec(spec, versions)
313 + assert.deepStrictEqual(got, expected)
314 + simulateInput('version-type', 'loose')
315 +
316 + spec = 'master'
317 + expected = 'master'
318 + got = setupBeam.getVersionFromSpec(spec, versions)
319 + assert.deepStrictEqual(got, expected)
320 +
321 + spec = '11.11'
322 + expected = 'v11.11.0-rc.0-otp-23'
323 + got = setupBeam.getVersionFromSpec(spec, versions)
324 + assert.deepStrictEqual(got, expected)
325 +
326 + spec = '11.11.0'
327 + expected = 'v11.11.0-rc.0-otp-23'
328 + got = setupBeam.getVersionFromSpec(spec, versions)
329 + assert.deepStrictEqual(got, expected)
330 +
331 + spec = 'v11.11'
332 + expected = 'v11.11.0-rc.0-otp-23'
333 + got = setupBeam.getVersionFromSpec(spec, versions)
334 + assert.deepStrictEqual(got, expected)
335 +
336 + spec = 'v11.11.0'
337 + expected = 'v11.11.0-rc.0-otp-23'
338 + got = setupBeam.getVersionFromSpec(spec, versions)
339 + assert.deepStrictEqual(got, expected)
340 +}
341 +
195 342 function simulateInput(key, value) {
196 343 process.env[`INPUT_${key.replace(/ /g, '_').toUpperCase()}`] = value
197 344 }
modified action.yml
+7 −3

Click to load diff…

modified dist/index.js
+81 −62

Click to load diff…

modified dist/install-elixir.ps1
+16 −2

Click to load diff…

modified dist/install-elixir.sh
+0 −4

Click to load diff…

modified dist/install-otp.ps1
+4 −3

Click to load diff…

modified dist/install-otp.sh
+0 −4

Click to load diff…

modified dist/install-rebar3.ps1
+0 −3

Click to load diff…

modified dist/install-rebar3.sh
+0 −3

Click to load diff…

modified src/install-elixir.ps1
+16 −2

Click to load diff…

modified src/install-elixir.sh
+0 −4

Click to load diff…

modified src/install-otp.ps1
+4 −3

Click to load diff…

modified src/install-otp.sh
+0 −4

Click to load diff…

modified src/install-rebar3.ps1
+0 −3

Click to load diff…

modified src/install-rebar3.sh
+0 −3

Click to load diff…

modified src/installer.js
+3 −3

Click to load diff…

modified src/setup-beam.js
+78 −59

Click to load diff…

Parents: 82b4475