Compare commits

...

5 Commits

Author SHA1 Message Date
Paulo F. Oliveira b60baf4753 Add known branch exceptions to version matching (#242) 2024-01-17 23:37:13 +00:00
GitHub Actions 213ca2eceb Automation: update setup-beam version output to bc84950 2024-01-17 23:33:13 +00:00
Paulo F. Oliveira bc84950393 Bump semver to 7.5.4 (#240) 2024-01-17 23:32:48 +00:00
GitHub Actions 980f47ea52 Update setup-beam version output to 4678b57 2024-01-12 19:46:30 +00:00
Paulo F. Oliveira 4678b57fab Have the action output a versioning element so it could be used as part of the cache restore key (#239)
* Do a bit of YAMLlint'ing

* Ease consumer cache invalidation

By providing an output with the action version we ease
cache invalidation on consumer, due to the fact we can
now stop worrying about changes to the action's cache itself

Might also be interesting for self-hosted runners...

* Remove duplicates

* Do further validations for robustness
2024-01-12 13:46:16 -06:00
9 changed files with 84 additions and 30 deletions
+21
View File
@@ -7,9 +7,30 @@ env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs: jobs:
version:
name: Version with commit unique id
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Version it!
run: |
# We expect a string such as const setupBeamVersion = 'undefined' in the code
SHA=$(git rev-parse --short HEAD)
sed -i'.bak' \
-e "s/const setupBeamVersion = '.*'/const setupBeamVersion = '${SHA}'/g" \
src/setup-beam.js
npm run build-dist
git config user.name "GitHub Actions"
git config user.email "actions@user.noreply.github.com"
git add src/setup-beam.js
git add dist/index.js
git commit -m "Automation: update setup-beam version output to ${SHA}"
git push origin main
check_integrity: check_integrity:
name: Expected local npm actions name: Expected local npm actions
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
+4 -20
View File
@@ -24,7 +24,7 @@ jobs:
os: 'ubuntu-latest' os: 'ubuntu-latest'
version-type: 'strict' version-type: 'strict'
- otp-version: '25.2' - otp-version: '25.2'
elixir-version: '1.14.3' elixir-version: '1.14.2'
os: 'ubuntu-latest' os: 'ubuntu-latest'
- otp-version: '25.2' - otp-version: '25.2'
elixir-version: '1.14.3' elixir-version: '1.14.3'
@@ -66,14 +66,6 @@ jobs:
otp-version: '21' otp-version: '21'
rebar3-version: '3.12' rebar3-version: '3.12'
os: 'ubuntu-20.04' os: 'ubuntu-20.04'
- elixir-version: 'v1.6'
otp-version: '21'
rebar3-version: '3.12'
os: 'ubuntu-20.04'
- elixir-version: 'v1.7'
otp-version: '22'
rebar3-version: '3.13'
os: 'ubuntu-20.04'
- elixir-version: 'v1.7' - elixir-version: 'v1.7'
otp-version: '22' otp-version: '22'
rebar3-version: '3.13' rebar3-version: '3.13'
@@ -86,18 +78,10 @@ jobs:
otp-version: '25.0.2' otp-version: '25.0.2'
rebar3-version: '3.19' rebar3-version: '3.19'
os: 'ubuntu-20.04' os: 'ubuntu-20.04'
- elixir-version: 'v1.10'
otp-version: '23'
rebar3-version: '3.14'
os: 'ubuntu-20.04'
- elixir-version: 'v1.12' - elixir-version: 'v1.12'
otp-version: '24' otp-version: '24'
rebar3-version: '3.15' rebar3-version: '3.15'
os: 'ubuntu-20.04' os: 'ubuntu-20.04'
- elixir-version: 'v1.13.4'
otp-version: '25.0.2'
rebar3-version: '3.19'
os: 'ubuntu-20.04'
- elixir-version: 'v1.11.0' - elixir-version: 'v1.11.0'
otp-version: '22.3.4.2' otp-version: '22.3.4.2'
os: 'ubuntu-20.04' os: 'ubuntu-20.04'
@@ -108,11 +92,11 @@ jobs:
version-type: 'strict' version-type: 'strict'
- elixir-version: 'main' - elixir-version: 'main'
otp-version: '23.1' otp-version: '23.1'
os: 'ubuntu-20.04' os: 'ubuntu-20.04'
version-type: 'strict' version-type: 'strict'
- elixir-version: 'main' - elixir-version: 'main'
otp-version: '25' otp-version: '25'
os: 'ubuntu-20.04' os: 'ubuntu-20.04'
version-type: 'strict' version-type: 'strict'
- gleam-version: '0.23' - gleam-version: '0.23'
otp-version: '24' otp-version: '24'
@@ -126,7 +110,7 @@ jobs:
otp-version: false otp-version: false
os: 'ubuntu-latest' os: 'ubuntu-latest'
disable_problem_matchers: true disable_problem_matchers: true
- gleam-version: '0.22.0' # Version with Gleam's old archive naming convention - gleam-version: '0.22.0' # Version with Gleam's old archive naming convention
otp-version: '24' otp-version: '24'
os: 'ubuntu-latest' os: 'ubuntu-latest'
disable_problem_matchers: true disable_problem_matchers: true
+15
View File
@@ -88,6 +88,21 @@ jobs:
... ...
``` ```
### Outputs
The action provides the following outputs:
| Output | Content
|- |-
| otp-version | The Erlang version, e.g. `OTP-26.0`
| elixir-version | The Elixir version, e.g. `v1.14-otp-26`
| gleam-version | The Gleam version, e.g. `v0.23.0`
| rebar3-version | The `rebar3` version, e.g. `3.18.0`
| setup-beam-version | The commit unique id of the executed action version, e.g. `a34c98f`
accessible as `${{steps.<setup-beam-step-id>.outputs.<Output>}}`,
e.g. `${{steps.setup-beam.outputs.erlang-version}}`
### Version file ### Version file
A version file is specified via input `version-file` (e.g.`.tool-versions`). This A version file is specified via input `version-file` (e.g.`.tool-versions`). This
+2
View File
@@ -58,6 +58,8 @@ outputs:
description: Exact version of Gleam that was installed description: Exact version of Gleam that was installed
rebar3-version: rebar3-version:
description: Exact version of rebar3 that was installed description: Exact version of rebar3 that was installed
setup-beam-version:
description: The commit unique id of the execution action version
runs: runs:
using: node16 using: node16
main: dist/index.js main: dist/index.js
+16 -4
View File
@@ -6161,7 +6161,7 @@ class Range {
this.set = this.raw this.set = this.raw
.split('||') .split('||')
// map the range to a 2d array of comparators // map the range to a 2d array of comparators
.map(r => this.parseRange(r)) .map(r => this.parseRange(r.trim()))
// throw out any comparator lists that are empty // throw out any comparator lists that are empty
// this generally means that it was not a valid range, which is allowed // this generally means that it was not a valid range, which is allowed
// in loose mode, but will still throw if the WHOLE range is invalid. // in loose mode, but will still throw if the WHOLE range is invalid.
@@ -7633,7 +7633,11 @@ module.exports = parseOptions
/***/ 9523: /***/ 9523:
/***/ ((module, exports, __nccwpck_require__) => { /***/ ((module, exports, __nccwpck_require__) => {
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH } = __nccwpck_require__(2293) const {
MAX_SAFE_COMPONENT_LENGTH,
MAX_SAFE_BUILD_LENGTH,
MAX_LENGTH,
} = __nccwpck_require__(2293)
const debug = __nccwpck_require__(427) const debug = __nccwpck_require__(427)
exports = module.exports = {} exports = module.exports = {}
@@ -7654,7 +7658,7 @@ const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
// all input should have extra whitespace removed. // all input should have extra whitespace removed.
const safeRegexReplacements = [ const safeRegexReplacements = [
['\\s', 1], ['\\s', 1],
['\\d', MAX_SAFE_COMPONENT_LENGTH], ['\\d', MAX_LENGTH],
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH], [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
] ]
@@ -9868,6 +9872,10 @@ async function main() {
await maybeInstallGleam(gleamSpec) await maybeInstallGleam(gleamSpec)
await maybeInstallRebar3(rebar3Spec) await maybeInstallRebar3(rebar3Spec)
// undefined is replaced by a function, post- main branch merge
const setupBeamVersion = 'bc84950'
core.setOutput('setup-beam-version', setupBeamVersion)
} }
async function installOTP(otpSpec, osVersion) { async function installOTP(otpSpec, osVersion) {
@@ -10216,7 +10224,7 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax) const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null let version = null
if (isStrictVersion() || isRC(spec0)) { if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (versions0[spec]) { if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly // If `version-type: strict` or version is RC, we obtain it directly
version = versions0[spec] version = versions0[spec]
@@ -10288,6 +10296,10 @@ function isRC(ver) {
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)')) return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
} }
function isKnownBranch(ver) {
return ['main', 'master', 'maint'].includes(ver)
}
function getRunnerOSVersion() { function getRunnerOSVersion() {
const ImageOSToContainer = { const ImageOSToContainer = {
ubuntu18: 'ubuntu-18.04', ubuntu18: 'ubuntu-18.04',
+4 -4
View File
@@ -11,7 +11,7 @@
"@actions/exec": "1.1.1", "@actions/exec": "1.1.1",
"@actions/http-client": "2.1.0", "@actions/http-client": "2.1.0",
"@actions/tool-cache": "2.0.1", "@actions/tool-cache": "2.0.1",
"semver": "7.5.3" "semver": "7.5.4"
}, },
"devDependencies": { "devDependencies": {
"@vercel/ncc": "0.36.1", "@vercel/ncc": "0.36.1",
@@ -2290,9 +2290,9 @@
} }
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.5.3", "version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
"integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dependencies": { "dependencies": {
"lru-cache": "^6.0.0" "lru-cache": "^6.0.0"
}, },
+1 -1
View File
@@ -18,7 +18,7 @@
"@actions/exec": "1.1.1", "@actions/exec": "1.1.1",
"@actions/http-client": "2.1.0", "@actions/http-client": "2.1.0",
"@actions/tool-cache": "2.0.1", "@actions/tool-cache": "2.0.1",
"semver": "7.5.3" "semver": "7.5.4"
}, },
"devDependencies": { "devDependencies": {
"@vercel/ncc": "0.36.1", "@vercel/ncc": "0.36.1",
+9 -1
View File
@@ -47,6 +47,10 @@ async function main() {
await maybeInstallGleam(gleamSpec) await maybeInstallGleam(gleamSpec)
await maybeInstallRebar3(rebar3Spec) await maybeInstallRebar3(rebar3Spec)
// undefined is replaced by a function, post- main branch merge
const setupBeamVersion = 'bc84950'
core.setOutput('setup-beam-version', setupBeamVersion)
} }
async function installOTP(otpSpec, osVersion) { async function installOTP(otpSpec, osVersion) {
@@ -400,7 +404,7 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax) const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null let version = null
if (isStrictVersion() || isRC(spec0)) { if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (versions0[spec]) { if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly // If `version-type: strict` or version is RC, we obtain it directly
version = versions0[spec] version = versions0[spec]
@@ -472,6 +476,10 @@ function isRC(ver) {
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)')) return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
} }
function isKnownBranch(ver) {
return ['main', 'master', 'maint'].includes(ver)
}
function getRunnerOSVersion() { function getRunnerOSVersion() {
const ImageOSToContainer = { const ImageOSToContainer = {
ubuntu18: 'ubuntu-18.04', ubuntu18: 'ubuntu-18.04',
+12
View File
@@ -182,6 +182,18 @@ async function testOTPVersions() {
expected = 'OTP-20.0.5' expected = 'OTP-20.0.5'
got = await setupBeam.getOTPVersion(spec, osVersion) got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected) assert.deepStrictEqual(got, expected)
spec = 'maint'
osVersion = 'ubuntu-22.04'
expected = 'maint'
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
spec = 'master'
osVersion = 'ubuntu-22.04'
expected = 'master'
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
} }
if (process.platform === 'win32') { if (process.platform === 'win32') {