Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ jobs:
...
```

For Windows images, suffix variants are canonicalized to the base `winNN` value.
For example, `win25-vs2026` is treated as `win25`.
This handles runner label-to-image issues discussed in
[`actions/runner-images#14004`](https://github.com/actions/runner-images/issues/14004).

### Outputs

The action provides the following outputs:
Expand Down
17 changes: 14 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55353,6 +55353,14 @@ function getRunnerOSArchitecture() {
)
}

/**
* Strip Windows runner-image variant suffixes (e.g. "win25-vs2026" → "win25").
* Deliberately only targets Windows; see actions/runner-images#14004.
*/
function canonicalizeImageOS(imageOS) {
return imageOS.replace(/^(win\d{2})-.+$/, '$1')
}

function getRunnerOSVersion() {
// List from https://github.com/actions/runner-images?tab=readme-ov-file#available-images
const ImageOSToContainer = {
Expand All @@ -55370,10 +55378,12 @@ function getRunnerOSVersion() {
ubuntu18: 'ubuntu-18.04',
ubuntu20: 'ubuntu-20.04',
}
const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS]
const imageOS = process.env.ImageOS || ''
const canonicalImageOS = canonicalizeImageOS(imageOS)
const containerFromEnvImageOS = ImageOSToContainer[canonicalImageOS]
if (!containerFromEnvImageOS) {
const deprecatedContainerFromEnvImageOS =
deprecatedImageOSToContainer[process.env.ImageOS]
deprecatedImageOSToContainer[canonicalImageOS]
if (deprecatedContainerFromEnvImageOS) {
warning(
`You are using deprecated ImageOS ${deprecatedContainerFromEnvImageOS}. ` +
Expand All @@ -55385,7 +55395,7 @@ function getRunnerOSVersion() {
} else {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS' (got " +
`${process.env.ImageOS}` +
`${imageOS}` +
"), but failed. If you're using a " +
"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
Expand Down Expand Up @@ -55988,6 +55998,7 @@ function debugLoggingEnabled() {
}

/* harmony default export */ const setup_beam = ({
canonicalizeImageOS,
get,
getElixirVersion,
getGleamVersion,
Expand Down
17 changes: 14 additions & 3 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,14 @@ function getRunnerOSArchitecture() {
)
}

/**
* Strip Windows runner-image variant suffixes (e.g. "win25-vs2026" → "win25").
* Deliberately only targets Windows; see actions/runner-images#14004.
*/
function canonicalizeImageOS(imageOS) {
return imageOS.replace(/^(win\d{2})-.+$/, '$1')
}

function getRunnerOSVersion() {
// List from https://github.com/actions/runner-images?tab=readme-ov-file#available-images
const ImageOSToContainer = {
Expand All @@ -676,10 +684,12 @@ function getRunnerOSVersion() {
ubuntu18: 'ubuntu-18.04',
ubuntu20: 'ubuntu-20.04',
}
const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS]
const imageOS = process.env.ImageOS || ''
const canonicalImageOS = canonicalizeImageOS(imageOS)
const containerFromEnvImageOS = ImageOSToContainer[canonicalImageOS]
if (!containerFromEnvImageOS) {
const deprecatedContainerFromEnvImageOS =
deprecatedImageOSToContainer[process.env.ImageOS]
deprecatedImageOSToContainer[canonicalImageOS]
if (deprecatedContainerFromEnvImageOS) {
core.warning(
`You are using deprecated ImageOS ${deprecatedContainerFromEnvImageOS}. ` +
Expand All @@ -691,7 +701,7 @@ function getRunnerOSVersion() {
} else {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS' (got " +
`${process.env.ImageOS}` +
`${imageOS}` +
"), but failed. If you're using a " +
"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
Expand Down Expand Up @@ -1294,6 +1304,7 @@ function debugLoggingEnabled() {
}

export default {
canonicalizeImageOS,
get,
getElixirVersion,
getGleamVersion,
Expand Down
22 changes: 22 additions & 0 deletions test/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,28 @@ describe('.get(_)', () => {
})
})

describe('.canonicalizeImageOS()', () => {
it('passes through a standard ImageOS value unchanged', () => {
assert.equal(setupBeam.canonicalizeImageOS('ubuntu24'), 'ubuntu24')
assert.equal(setupBeam.canonicalizeImageOS('macos15'), 'macos15')
assert.equal(setupBeam.canonicalizeImageOS('win25'), 'win25')
})

it('strips Windows runner-image variant suffixes', () => {
assert.equal(setupBeam.canonicalizeImageOS('win25-vs2026'), 'win25')
assert.equal(setupBeam.canonicalizeImageOS('win22-vs2022'), 'win22')
})

it('does not alter non-Windows suffixed values', () => {
assert.equal(setupBeam.canonicalizeImageOS('macos15'), 'macos15')
assert.equal(setupBeam.canonicalizeImageOS('ubuntu24'), 'ubuntu24')
})

it('handles empty string', () => {
assert.equal(setupBeam.canonicalizeImageOS(''), '')
})
})

describe("Elixir Mix matcher's", () => {
it('errors are properly matched', async () => {
const [matcher] = problemMatcher.find(
Expand Down