Skip to content
Merged
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
11 changes: 6 additions & 5 deletions .github/workflows/__multi-language-autodetect.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .github/workflows/__swift-custom-build.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion pr-checks/checks/multi-language-autodetect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ operatingSystems:
- ubuntu
- os: macos
runner-image: macos-latest-xlarge
# Older CodeQL CLI versions only support Swift up to 6.1, which requires Xcode 16. That is
# not available on macOS 26, so run these versions on macOS 15 where we select Xcode 16
# below. See https://github.com/actions/runner-images/issues/14167.
- os: macos
runner-image: macos-15-xlarge
codeql-versions:
- stable-v2.19.4
- stable-v2.20.7
- stable-v2.21.4
- stable-v2.22.4
env:
CODEQL_ACTION_RESOLVE_SUPPORTED_LANGUAGES_USING_CLI: true
installGo: true
Expand All @@ -18,7 +28,8 @@ steps:
python-version: "3.13"

- name: Use Xcode 16
if: runner.os == 'macOS' && matrix.version != 'nightly-latest'
# Only the older CodeQL CLI versions need Xcode 16, and these run on macOS 15.
if: matrix.os == 'macos-15-xlarge'
run: sudo xcode-select -s "/Applications/Xcode_16.app"

- uses: ./../action/init
Expand Down
3 changes: 0 additions & 3 deletions pr-checks/checks/swift-custom-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ installDotNet: true
env:
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
steps:
- name: Use Xcode 16
if: runner.os == 'macOS' && matrix.version != 'nightly-latest'
run: sudo xcode-select -s "/Applications/Xcode_16.app"
- uses: ./../action/init
id: init
with:
Expand Down
43 changes: 42 additions & 1 deletion pr-checks/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ type OperatingSystem =
os: OperatingSystemIdentifier;
/** Optional runner image label. */
"runner-image"?: string;
/**
* Optional CodeQL versions to run on this entry. If specified, this entry runs only these
* versions. A sibling entry for the same OS that omits `codeql-versions` runs all versions
* not claimed by any sibling entry. This allows pinning specific CodeQL versions to a
* particular runner image while letting the remaining versions default to another.
*/
"codeql-versions"?: string[];
};

/**
Expand Down Expand Up @@ -352,6 +359,28 @@ function generateJobMatrix(
): Array<Record<string, any>> {
let matrix: Array<Record<string, any>> = [];

const operatingSystems = checkSpecification.operatingSystems ?? ["ubuntu"];

// For each OS, collect the CodeQL versions explicitly claimed by entries that specify
// `codeql-versions`. A sibling entry for the same OS that omits `codeql-versions` runs all
// versions not in this set.
const claimedVersionsByOs = new Map<string, Set<string>>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: This mapping is indexed by the .os key, which is shared among all siblings. The "claimedVersionsByOs" naming here is therefore a bit confusing because it seems to say something about which OS has claimed which versions. Changing this to e.g. handledVersionsByOS or similar might be slightly clearer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this as is so we can get the checks passing on main 👍

for (const operatingSystemConfig of operatingSystems) {
if (typeof operatingSystemConfig === "string") {
continue;
}
const entryVersions = operatingSystemConfig["codeql-versions"];
if (!entryVersions) {
continue;
}
const claimed =
claimedVersionsByOs.get(operatingSystemConfig.os) ?? new Set<string>();
for (const entryVersion of entryVersions) {
claimed.add(entryVersion);
}
claimedVersionsByOs.set(operatingSystemConfig.os, claimed);
}

for (const version of checkSpecification.versions ?? defaultTestVersions) {
if (version === "latest") {
throw new Error(
Expand All @@ -364,7 +393,6 @@ function generateJobMatrix(
"macos-latest",
"windows-latest",
];
const operatingSystems = checkSpecification.operatingSystems ?? ["ubuntu"];

for (const operatingSystemConfig of operatingSystems) {
const operatingSystem =
Expand All @@ -379,6 +407,19 @@ function generateJobMatrix(
continue;
}

// An entry that specifies `codeql-versions` runs only those versions. A sibling entry for
// the same OS that omits `codeql-versions` runs all versions not claimed by its siblings.
const entryVersions =
typeof operatingSystemConfig === "string"
? undefined
: operatingSystemConfig["codeql-versions"];
const runsThisVersion = entryVersions
? entryVersions.includes(version)
: !claimedVersionsByOs.get(operatingSystem)?.has(version);
if (!runsThisVersion) {
continue;
}

const runnerImagesForOs =
typeof operatingSystemConfig === "string" ||
operatingSystemConfig["runner-image"] === undefined
Expand Down
Loading