Test Erlang/OTP 26 + Elixir 1.14 on top Windows (#191)

145c80c · Paulo F. Oliveira · 2023-06-24 16:27

6 files +190 -46
Message
{commit_body(@commit)}

Files changed

modified .github/workflows/ubuntu.yml
+9 −1
@@ -20,6 +20,14 @@ jobs:
20 20 fail-fast: false
21 21 matrix:
22 22 combo:
23 + - otp-version: '26.0'
24 + elixir-version: 'v1.14-otp-25'
25 + os: 'ubuntu-latest'
26 + version-type: 'strict'
27 + - otp-version: '26.0'
28 + elixir-version: '1.14.5'
29 + os: 'ubuntu-latest'
30 + version-type: 'strict'
23 31 - otp-version: '25.2'
24 32 elixir-version: '1.14.3'
25 33 os: 'ubuntu-latest'
@@ -106,7 +114,7 @@ jobs:
106 114 - elixir-version: '1.10.3'
107 115 otp-version: '22.3.4.1'
108 116 os: 'ubuntu-20.04'
109 - elixir-version: 'master'
117 + - elixir-version: 'main'
110 118 otp-version: '23.1'
111 119 os: 'ubuntu-20.04'
112 120 - elixir-version: 'main'
modified .github/workflows/windows.yml
+13 −0
@@ -20,6 +20,18 @@ jobs:
20 20 fail-fast: false
21 21 matrix:
22 22 combo:
23 + - otp-version: '26.0'
24 + elixir-version: 'main'
25 + os: 'windows-latest'
26 + version-type: 'strict'
27 + - otp-version: '26.0'
28 + elixir-version: 'v1.14-otp-25'
29 + os: 'windows-latest'
30 + version-type: 'strict'
31 + - otp-version: '26.0'
32 + elixir-version: '1.14.5'
33 + os: 'windows-latest'
34 + version-type: 'strict'
23 35 - otp-version: '25'
24 36 rebar3-version: 'nightly'
25 37 os: 'windows-latest'
@@ -61,6 +73,7 @@ jobs:
61 73 elixir-version: ${{matrix.combo.elixir-version}}
62 74 gleam-version: ${{matrix.combo.gleam-version}}
63 75 rebar3-version: ${{matrix.combo.rebar3-version}}
76 + version-type: ${{matrix.combo.version-type}}
64 77 - name: Erlang/OTP version (action)
65 78 run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}"
66 79 - name: Elixir version (action)
modified dist/index.js
+78 −18
@@ -9719,6 +9719,9 @@ const os = __nccwpck_require__(2037)
9719 9719 * @param {string[]} hexMirrors
9720 9720 */
9721 9721 async function installOTP(osVersion, otpVersion, hexMirrors) {
9722 + let cmd
9723 + let args
9724 +
9722 9725 if (hexMirrors.length === 0) {
9723 9726 throw new Error(
9724 9727 `Could not install Erlang/OTP ${otpVersion} from any hex.pm mirror`,
@@ -9743,7 +9746,9 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
9743 9746 cachedPath = await tc.cacheDir(extractPath, 'otp', fullVersion)
9744 9747 }
9745 9748
9746 await exec(path.join(cachedPath, 'Install'), ['-minimal', cachedPath])
9749 + cmd = path.join(cachedPath, 'Install')
9750 + args = ['-minimal', cachedPath]
9751 + await exec(cmd, args)
9747 9752
9748 9753 const otpPath = path.join(cachedPath, 'bin')
9749 9754
@@ -9751,7 +9756,9 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
9751 9756 core.exportVariable('INSTALL_DIR_FOR_OTP', cachedPath)
9752 9757
9753 9758 core.info('Installed Erlang/OTP version')
9754 await exec(path.join(otpPath, 'erl'), ['-version'])
9759 + cmd = path.join(otpPath, 'erl')
9760 + args = ['-version']
9761 + await exec(cmd, args)
9755 9762 } else if (OS === 'win32') {
9756 9763 if (!cachedPath) {
9757 9764 const exePath = await tc.downloadTool(
@@ -9765,13 +9772,19 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
9765 9772 const otpPath = path.join(otpDir, 'bin')
9766 9773
9767 9774 await fs.promises.mkdir(otpDir, { recursive: true })
9768 await exec(path.join(cachedPath, 'otp.exe'), ['/S', `/D=${otpDir}`])
9775 +
9776 + cmd = path.join(cachedPath, 'otp.exe')
9777 + args = ['/S', `/D=${otpDir}`]
9778 + await exec(cmd, args)
9769 9779
9770 9780 core.addPath(otpPath)
9771 9781 core.exportVariable('INSTALL_DIR_FOR_OTP', otpDir)
9772 9782
9773 9783 core.info('Installed Erlang/OTP version')
9774 await exec(path.join(otpPath, 'erl'), ['+V'])
9784 +
9785 + cmd = path.join(otpPath, 'erl.exe')
9786 + args = ['+V']
9787 + await exec(cmd, args)
9775 9788 }
9776 9789 } catch (err) {
9777 9790 core.info(`Install OTP failed for mirror ${hexMirror}`)
@@ -9787,6 +9800,10 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
9787 9800 * @param {string[]} hexMirrors
9788 9801 */
9789 9802 async function installElixir(elixirVersion, hexMirrors) {
9803 + let cmd
9804 + let args
9805 + let options
9806 +
9790 9807 if (hexMirrors.length === 0) {
9791 9808 throw new Error(
9792 9809 `Could not install Elixir ${elixirVersion} from any hex.pm mirror`,
@@ -9796,6 +9813,7 @@ async function installElixir(elixirVersion, hexMirrors) {
9796 9813
9797 9814 try {
9798 9815 let cachedPath = tc.find('elixir', elixirVersion)
9816 + const OS = process.platform
9799 9817
9800 9818 if (!cachedPath) {
9801 9819 const zipPath = await tc.downloadTool(
@@ -9813,7 +9831,21 @@ async function installElixir(elixirVersion, hexMirrors) {
9813 9831 core.exportVariable('INSTALL_DIR_FOR_ELIXIR', cachedPath)
9814 9832
9815 9833 core.info('Installed Elixir version')
9816 await exec(path.join(elixirPath, 'elixir'), ['-v'])
9834 +
9835 + if (debugLoggingEnabled()) {
9836 + core.exportVariable('ELIXIR_CLI_ECHO', 'true')
9837 + }
9838 +
9839 + if (OS === 'linux') {
9840 + cmd = path.join(elixirPath, 'elixir')
9841 + args = ['-v']
9842 + options = {}
9843 + } else if (OS === 'win32') {
9844 + cmd = path.join(elixirPath, 'elixir.bat')
9845 + args = ['-v']
9846 + options = { windowsVerbatimArguments: true }
9847 + }
9848 + await exec(cmd, args, options)
9817 9849
9818 9850 await fs.promises.mkdir(escriptsPath, { recursive: true })
9819 9851 } catch (err) {
@@ -9829,12 +9861,18 @@ async function installElixir(elixirVersion, hexMirrors) {
9829 9861 * @param {string} gleamVersion
9830 9862 */
9831 9863 async function installGleam(gleamVersion) {
9864 + let cmd
9865 + let args
9866 +
9832 9867 const OS = process.platform
9833 9868 if (OS === 'linux') {
9834 await exec(__nccwpck_require__.ab + "install-gleam.sh", [gleamVersion])
9869 + cmd = __nccwpck_require__.ab + "install-gleam.sh"
9870 + args = [gleamVersion]
9871 + await exec(__nccwpck_require__.ab + "install-gleam.sh", args)
9835 9872 } else if (OS === 'win32') {
9836 const script = __nccwpck_require__.ab + "install-gleam.ps1"
9837 await exec(`pwsh.exe ${script} -VSN:${gleamVersion}`)
9873 + cmd = `pwsh.exe ${path.join(__dirname, 'install-gleam.ps1')}`
9874 + args = [`-VSN:${gleamVersion}`]
9875 + await exec(cmd, args)
9838 9876 }
9839 9877 }
9840 9878
@@ -9844,12 +9882,18 @@ async function installGleam(gleamVersion) {
9844 9882 * @param {string} rebar3Version
9845 9883 */
9846 9884 async function installRebar3(rebar3Version) {
9885 + let cmd
9886 + let args
9887 +
9847 9888 const OS = process.platform
9848 9889 if (OS === 'linux') {
9849 await exec(__nccwpck_require__.ab + "install-rebar3.sh", [rebar3Version])
9890 + cmd = __nccwpck_require__.ab + "install-rebar3.sh"
9891 + args = [rebar3Version]
9892 + await exec(__nccwpck_require__.ab + "install-rebar3.sh", args)
9850 9893 } else if (OS === 'win32') {
9851 const script = __nccwpck_require__.ab + "install-rebar3.ps1"
9852 await exec(`pwsh.exe ${script} -VSN:${rebar3Version}`)
9894 + cmd = `pwsh.exe ${path.join(__dirname, 'install-rebar3.ps1')}`
9895 + args = [`-VSN:${rebar3Version}`]
9896 + await exec(cmd, args)
9853 9897 }
9854 9898 }
9855 9899
@@ -9861,6 +9905,10 @@ function checkPlatform() {
9861 9905 }
9862 9906 }
9863 9907
9908 +function debugLoggingEnabled() {
9909 + return !!process.env.RUNNER_DEBUG
9910 +}
9911 +
9864 9912 module.exports = {
9865 9913 installOTP,
9866 9914 installElixir,
@@ -10128,7 +10176,6 @@ async function getOTPVersions(osVersion, hexMirrors) {
10128 10176 'https://api.github.com/repos/erlang/otp/releases?per_page=100'
10129 10177 otpVersionsListings = await get(originListing, [1, 2, 3])
10130 10178 }
10131 debugLog(`OTP versions listings from ${originListing}`, otpVersionsListings)
10132 10179
10133 10180 const otpVersions = new Map()
10134 10181
@@ -10141,6 +10188,7 @@ async function getOTPVersions(osVersion, hexMirrors) {
10141 10188 .match(/^([^ ]+)?( .+)/)[1]
10142 10189 .match(/^([^-]+-)?(.+)$/)
10143 10190 const otpVersion = otpMatch[2]
10191 + debugLog('OTP line and parsing', [line, otpVersion, otpMatch])
10144 10192 otpVersions.set(otpVersion, otpMatch[0]) // we keep the original for later reference
10145 10193 })
10146 10194 } else if (process.platform === 'win32') {
@@ -10152,10 +10200,17 @@ async function getOTPVersions(osVersion, hexMirrors) {
10152 10200 .forEach((x) => {
10153 10201 const otpMatch = x.name.match(/^otp_win64_(.*).exe$/)
10154 10202 const otpVersion = otpMatch[1]
10203 + debugLog('OTP line and parsing', [otpMatch, otpVersion])
10155 10204 otpVersions.set(otpVersion, otpVersion)
10156 10205 })
10157 10206 })
10158 10207 }
10208 +
10209 + debugLog(
10210 + `OTP versions from ${originListing}`,
10211 + JSON.stringify([...otpVersions.entries()]),
10212 + )
10213 +
10159 10214 return otpVersions
10160 10215 }
10161 10216
@@ -10262,7 +10317,7 @@ function maybeCoerced(v) {
10262 10317 try {
10263 10318 ret = semver.coerce(v).version
10264 10319 } catch {
10265 // some stuff can't be coerced, like 'master'
10320 + // some stuff can't be coerced, like 'main'
10266 10321 ret = v
10267 10322 }
10268 10323
@@ -10445,11 +10500,16 @@ function jsonParseAsList(maybeJson) {
10445 10500 }
10446 10501
10447 10502 function debugLog(groupName, message) {
10448 if (process.env.RUNNER_DEBUG) {
10449 core.startGroup(`Debugging for ${groupName}`)
10450 core.debug(message)
10451 core.endGroup()
10452 }
10503 + const group = `Debugging for ${groupName}`
10504 + core.debug(
10505 + '┌──────────────────────────────────────────────────────────────────────────',
10506 + )
10507 + core.debug(`│ ${group} - start`)
10508 + core.debug(message)
10509 + core.debug(`│ ${group} - stop`)
10510 + core.debug(
10511 + '└──────────────────────────────────────────────────────────────────────────',
10512 + )
10453 10513 }
10454 10514
10455 10515 module.exports = {
modified src/installer.js
+59 −11
@@ -13,6 +13,9 @@ const os = require('os')
13 13 * @param {string[]} hexMirrors
14 14 */
15 15 async function installOTP(osVersion, otpVersion, hexMirrors) {
16 + let cmd
17 + let args
18 +
16 19 if (hexMirrors.length === 0) {
17 20 throw new Error(
18 21 `Could not install Erlang/OTP ${otpVersion} from any hex.pm mirror`,
@@ -37,7 +40,9 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
37 40 cachedPath = await tc.cacheDir(extractPath, 'otp', fullVersion)
38 41 }
39 42
40 await exec(path.join(cachedPath, 'Install'), ['-minimal', cachedPath])
43 + cmd = path.join(cachedPath, 'Install')
44 + args = ['-minimal', cachedPath]
45 + await exec(cmd, args)
41 46
42 47 const otpPath = path.join(cachedPath, 'bin')
43 48
@@ -45,7 +50,9 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
45 50 core.exportVariable('INSTALL_DIR_FOR_OTP', cachedPath)
46 51
47 52 core.info('Installed Erlang/OTP version')
48 await exec(path.join(otpPath, 'erl'), ['-version'])
53 + cmd = path.join(otpPath, 'erl')
54 + args = ['-version']
55 + await exec(cmd, args)
49 56 } else if (OS === 'win32') {
50 57 if (!cachedPath) {
51 58 const exePath = await tc.downloadTool(
@@ -59,13 +66,19 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
59 66 const otpPath = path.join(otpDir, 'bin')
60 67
61 68 await fs.promises.mkdir(otpDir, { recursive: true })
62 await exec(path.join(cachedPath, 'otp.exe'), ['/S', `/D=${otpDir}`])
69 +
70 + cmd = path.join(cachedPath, 'otp.exe')
71 + args = ['/S', `/D=${otpDir}`]
72 + await exec(cmd, args)
63 73
64 74 core.addPath(otpPath)
65 75 core.exportVariable('INSTALL_DIR_FOR_OTP', otpDir)
66 76
67 77 core.info('Installed Erlang/OTP version')
68 await exec(path.join(otpPath, 'erl'), ['+V'])
78 +
79 + cmd = path.join(otpPath, 'erl.exe')
80 + args = ['+V']
81 + await exec(cmd, args)
69 82 }
70 83 } catch (err) {
71 84 core.info(`Install OTP failed for mirror ${hexMirror}`)
@@ -81,6 +94,10 @@ async function installOTP(osVersion, otpVersion, hexMirrors) {
81 94 * @param {string[]} hexMirrors
82 95 */
83 96 async function installElixir(elixirVersion, hexMirrors) {
97 + let cmd
98 + let args
99 + let options
100 +
84 101 if (hexMirrors.length === 0) {
85 102 throw new Error(
86 103 `Could not install Elixir ${elixirVersion} from any hex.pm mirror`,
@@ -90,6 +107,7 @@ async function installElixir(elixirVersion, hexMirrors) {
90 107
91 108 try {
92 109 let cachedPath = tc.find('elixir', elixirVersion)
110 + const OS = process.platform
93 111
94 112 if (!cachedPath) {
95 113 const zipPath = await tc.downloadTool(
@@ -107,7 +125,21 @@ async function installElixir(elixirVersion, hexMirrors) {
107 125 core.exportVariable('INSTALL_DIR_FOR_ELIXIR', cachedPath)
108 126
109 127 core.info('Installed Elixir version')
110 await exec(path.join(elixirPath, 'elixir'), ['-v'])
128 +
129 + if (debugLoggingEnabled()) {
130 + core.exportVariable('ELIXIR_CLI_ECHO', 'true')
131 + }
132 +
133 + if (OS === 'linux') {
134 + cmd = path.join(elixirPath, 'elixir')
135 + args = ['-v']
136 + options = {}
137 + } else if (OS === 'win32') {
138 + cmd = path.join(elixirPath, 'elixir.bat')
139 + args = ['-v']
140 + options = { windowsVerbatimArguments: true }
141 + }
142 + await exec(cmd, args, options)
111 143
112 144 await fs.promises.mkdir(escriptsPath, { recursive: true })
113 145 } catch (err) {
@@ -123,12 +155,18 @@ async function installElixir(elixirVersion, hexMirrors) {
123 155 * @param {string} gleamVersion
124 156 */
125 157 async function installGleam(gleamVersion) {
158 + let cmd
159 + let args
160 +
126 161 const OS = process.platform
127 162 if (OS === 'linux') {
128 await exec(path.join(__dirname, 'install-gleam.sh'), [gleamVersion])
163 + cmd = path.join(__dirname, 'install-gleam.sh')
164 + args = [gleamVersion]
165 + await exec(cmd, args)
129 166 } else if (OS === 'win32') {
130 const script = path.join(__dirname, 'install-gleam.ps1')
131 await exec(`pwsh.exe ${script} -VSN:${gleamVersion}`)
167 + cmd = `pwsh.exe ${path.join(__dirname, 'install-gleam.ps1')}`
168 + args = [`-VSN:${gleamVersion}`]
169 + await exec(cmd, args)
132 170 }
133 171 }
134 172
@@ -138,12 +176,18 @@ async function installGleam(gleamVersion) {
138 176 * @param {string} rebar3Version
139 177 */
140 178 async function installRebar3(rebar3Version) {
179 + let cmd
180 + let args
181 +
141 182 const OS = process.platform
142 183 if (OS === 'linux') {
143 await exec(path.join(__dirname, 'install-rebar3.sh'), [rebar3Version])
184 + cmd = path.join(__dirname, 'install-rebar3.sh')
185 + args = [rebar3Version]
186 + await exec(cmd, args)
144 187 } else if (OS === 'win32') {
145 const script = path.join(__dirname, 'install-rebar3.ps1')
146 await exec(`pwsh.exe ${script} -VSN:${rebar3Version}`)
188 + cmd = `pwsh.exe ${path.join(__dirname, 'install-rebar3.ps1')}`
189 + args = [`-VSN:${rebar3Version}`]
190 + await exec(cmd, args)
147 191 }
148 192 }
149 193
@@ -155,6 +199,10 @@ function checkPlatform() {
155 199 }
156 200 }
157 201
202 +function debugLoggingEnabled() {
203 + return !!process.env.RUNNER_DEBUG
204 +}
205 +
158 206 module.exports = {
159 207 installOTP,
160 208 installElixir,
modified src/setup-beam.js
+19 −7
@@ -256,7 +256,6 @@ async function getOTPVersions(osVersion, hexMirrors) {
256 256 'https://api.github.com/repos/erlang/otp/releases?per_page=100'
257 257 otpVersionsListings = await get(originListing, [1, 2, 3])
258 258 }
259 debugLog(`OTP versions listings from ${originListing}`, otpVersionsListings)
260 259
261 260 const otpVersions = new Map()
262 261
@@ -269,6 +268,7 @@ async function getOTPVersions(osVersion, hexMirrors) {
269 268 .match(/^([^ ]+)?( .+)/)[1]
270 269 .match(/^([^-]+-)?(.+)$/)
271 270 const otpVersion = otpMatch[2]
271 + debugLog('OTP line and parsing', [line, otpVersion, otpMatch])
272 272 otpVersions.set(otpVersion, otpMatch[0]) // we keep the original for later reference
273 273 })
274 274 } else if (process.platform === 'win32') {
@@ -280,10 +280,17 @@ async function getOTPVersions(osVersion, hexMirrors) {
280 280 .forEach((x) => {
281 281 const otpMatch = x.name.match(/^otp_win64_(.*).exe$/)
282 282 const otpVersion = otpMatch[1]
283 + debugLog('OTP line and parsing', [otpMatch, otpVersion])
283 284 otpVersions.set(otpVersion, otpVersion)
284 285 })
285 286 })
286 287 }
288 +
289 + debugLog(
290 + `OTP versions from ${originListing}`,
291 + JSON.stringify([...otpVersions.entries()]),
292 + )
293 +
287 294 return otpVersions
288 295 }
289 296
@@ -390,7 +397,7 @@ function maybeCoerced(v) {
390 397 try {
391 398 ret = semver.coerce(v).version
392 399 } catch {
393 // some stuff can't be coerced, like 'master'
400 + // some stuff can't be coerced, like 'main'
394 401 ret = v
395 402 }
396 403
@@ -573,11 +580,16 @@ function jsonParseAsList(maybeJson) {
573 580 }
574 581
575 582 function debugLog(groupName, message) {
576 if (process.env.RUNNER_DEBUG) {
577 core.startGroup(`Debugging for ${groupName}`)
578 core.debug(message)
579 core.endGroup()
580 }
583 + const group = `Debugging for ${groupName}`
584 + core.debug(
585 + '┌──────────────────────────────────────────────────────────────────────────',
586 + )
587 + core.debug(`│ ${group} - start`)
588 + core.debug(message)
589 + core.debug(`│ ${group} - stop`)
590 + core.debug(
591 + '└──────────────────────────────────────────────────────────────────────────',
592 + )
581 593 }
582 594
583 595 module.exports = {
modified test/setup-beam.test.js
+12 −9
@@ -199,7 +199,7 @@ async function testElixirVersions() {
199 199
200 200 before = simulateInput('version-type', 'strict')
201 201 spec = '1.14.0'
202 otpVersion = 'master'
202 + otpVersion = 'main'
203 203 expected = 'v1.14.0'
204 204 got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
205 205 assert.deepStrictEqual(got, expected)
@@ -213,6 +213,14 @@ async function testElixirVersions() {
213 213 assert.deepStrictEqual(got, expected)
214 214 simulateInput('version-type', before)
215 215
216 + before = simulateInput('version-type', 'strict')
217 + spec = 'v1.11.0-rc.0-otp-23'
218 + otpVersion = 'OTP-23'
219 + expected = 'v1.11.0-rc.0-otp-23'
220 + got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
221 + assert.deepStrictEqual(got, expected)
222 + simulateInput('version-type', before)
223 +
216 224 before = simulateInput('version-type', 'strict')
217 225 spec = 'v1.11.0'
218 226 otpVersion = '22.3.4.2'
@@ -309,7 +317,7 @@ async function testGetVersionFromSpec() {
309 317 '22.3.4.9.1',
310 318 '22.3.4.12.1',
311 319 '22.3.4.10.1',
312 'master',
320 + 'main',
313 321 'v11.11.0-rc.0-otp-23',
314 322 '22.3.4.2',
315 323 ]
@@ -396,17 +404,12 @@ async function testGetVersionFromSpec() {
396 404 assert.deepStrictEqual(got, expected)
397 405
398 406 before = simulateInput('version-type', 'strict')
399 spec = 'master'
400 expected = 'master'
407 + spec = 'main'
408 + expected = 'main'
401 409 got = setupBeam.getVersionFromSpec(spec, versions)
402 410 assert.deepStrictEqual(got, expected)
403 411 simulateInput('version-type', before)
404 412
405 spec = 'master'
406 expected = 'master'
407 got = setupBeam.getVersionFromSpec(spec, versions)
408 assert.deepStrictEqual(got, expected)
409
410 413 before = simulateInput('version-type', 'strict')
411 414 spec = '22.3.4.2'
412 415 expected = '22.3.4.2'

Parents: 61e01a4