Skip to content

Commit 9aa4486

Browse files
authored
Merge branch 'electron:main' into main
2 parents cc14a6f + d123da0 commit 9aa4486

29 files changed

+9639
-5677
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Check SDK Version
2+
3+
on:
4+
schedule:
5+
# Run daily at 9 AM UTC
6+
- cron: '0 9 * * *'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
issues: write
12+
13+
jobs:
14+
check-sdk:
15+
name: Check for new macOS SDK
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout electron-build-tools
19+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # tag: v6.0.0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # tag: v6.0.0
23+
with:
24+
node-version: lts/-1
25+
26+
- name: Install dependencies
27+
run: yarn install --frozen-lockfile
28+
29+
- name: Fetch Chromium mac_toolchain.py
30+
run: |
31+
curl -sSL "https://chromium.googlesource.com/chromium/src/+/main/build/mac_toolchain.py?format=TEXT" | base64 -d > mac_toolchain.py
32+
33+
- name: Check for new SDK version
34+
id: check-sdk
35+
run: node .github/workflows/scripts/check-sdk-version.js mac_toolchain.py
36+
37+
- name: Create issue for new SDK
38+
if: steps.check-sdk.outputs.new-sdk == 'true'
39+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # tag: v7.0.1
40+
with:
41+
script: |
42+
const newVersion = process.env.NEW_SDK_VERSION;
43+
const title = `Add macOS SDK ${newVersion} to Azure`;
44+
45+
const issues = await github.rest.issues.listForRepo({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
state: 'open',
49+
labels: 'wg-infra'
50+
});
51+
52+
const existingIssue = issues.data.find(issue =>
53+
issue.title.includes(`macOS SDK ${newVersion}`)
54+
);
55+
56+
if (existingIssue) {
57+
console.log(`Issue already exists: ${existingIssue.html_url}`);
58+
return;
59+
}
60+
61+
const issue = await github.rest.issues.create({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
title: title,
65+
body: `A new macOS SDK version **${newVersion}** has been detected in Chromium's \`build/mac_toolchain.py\` that is not present in \`src/utils/sdks.json\`.\n\nPlease add the macOS SDK ${newVersion} to Azure storage.\n\nFollow the [upgrade steps](https://github.com/electron/infra-private/blob/main/resources/updating-xcode-version.md) to add the new SDK version.`,
66+
labels: ['wg-infra']
67+
});
68+
69+
console.log(`Created issue: ${issue.data.html_url}`);
70+
env:
71+
NEW_SDK_VERSION: ${{ steps.check-sdk.outputs.sdk-version }}

.github/workflows/lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ jobs:
2424
run: |
2525
git config --global core.autocrlf false
2626
git config --global core.eol lf
27-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2
27+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # tag: v6.0.1
2828
- name: Setup Node.js
29-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # tag: v4.4.0
29+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # tag: v6.1.0
3030
with:
3131
node-version: lts/-1
3232
- name: Cache node_modules
3333
id: cache-node-modules
34-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # tag: v4.2.3
34+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # tag: v5.0.1
3535
with:
3636
path: node_modules
3737
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-node-modules
3838
- name: Install
3939
if: steps.cache-node-modules.outputs.cache-hit != 'true'
40-
run: yarn install
40+
run: yarn install --immutable
4141
- name: Lint
4242
run: yarn lint
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const { extractSDKVersion } = require('../../../src/utils/sdk');
6+
7+
function getKnownSDKs() {
8+
const sdkPath = path.resolve(__dirname, '../../../src/utils/sdks.json');
9+
const sdks = JSON.parse(fs.readFileSync(sdkPath, 'utf8'));
10+
return Object.keys(sdks);
11+
}
12+
13+
function isNewerVersion(v1, v2) {
14+
const [major1, minor1] = v1.split('.').map(Number);
15+
const [major2, minor2] = v2.split('.').map(Number);
16+
17+
if (major1 !== major2) {
18+
return major1 > major2;
19+
}
20+
return minor1 > minor2;
21+
}
22+
23+
function main() {
24+
try {
25+
const macToolchainPath = process.argv[2];
26+
27+
if (!macToolchainPath || !fs.existsSync(macToolchainPath)) {
28+
console.error(`Error: Could not find ${macToolchainPath || 'mac_toolchain.py'}`);
29+
console.error('Usage: node check-sdk-version.js <path-to-mac_toolchain.py>');
30+
process.exit(1);
31+
}
32+
33+
const chromiumSDK = extractSDKVersion(macToolchainPath);
34+
console.log(`Chromium SDK version: ${chromiumSDK}`);
35+
36+
if (!chromiumSDK) {
37+
console.error('Error: Could not extract SDK version from mac_toolchain.py');
38+
process.exit(1);
39+
}
40+
41+
const knownSDKs = getKnownSDKs();
42+
console.log(`Known SDK versions: ${knownSDKs.join(', ')}`);
43+
44+
if (knownSDKs.includes(chromiumSDK)) {
45+
console.log(`✓ SDK ${chromiumSDK} is already in sdks.json`);
46+
fs.appendFileSync(process.env.GITHUB_OUTPUT || '/dev/null', 'new-sdk=false\n');
47+
process.exit(0);
48+
}
49+
50+
const latestKnownSDK = knownSDKs.sort((a, b) => {
51+
const [major1, minor1] = a.split('.').map(Number);
52+
const [major2, minor2] = b.split('.').map(Number);
53+
if (major1 !== major2) return major2 - major1;
54+
return minor2 - minor1;
55+
})[0];
56+
57+
console.log(`Latest known SDK: ${latestKnownSDK}`);
58+
59+
if (isNewerVersion(chromiumSDK, latestKnownSDK)) {
60+
console.log(`✗ New SDK detected: ${chromiumSDK} is newer than ${latestKnownSDK}`);
61+
fs.appendFileSync(process.env.GITHUB_OUTPUT || '/dev/null', `new-sdk=true\n`);
62+
fs.appendFileSync(process.env.GITHUB_OUTPUT || '/dev/null', `sdk-version=${chromiumSDK}\n`);
63+
process.exit(0);
64+
} else {
65+
console.log(
66+
`Note: SDK ${chromiumSDK} is not in sdks.json but is not newer than ${latestKnownSDK}`,
67+
);
68+
fs.appendFileSync(process.env.GITHUB_OUTPUT || '/dev/null', 'new-sdk=false\n');
69+
process.exit(0);
70+
}
71+
} catch (error) {
72+
console.error('Error:', error.message);
73+
process.exit(1);
74+
}
75+
}
76+
77+
main();

.github/workflows/semantic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: semantic-pull-request
22-
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # tag: v5
22+
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # tag: v5
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525
with:

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ jobs:
3333
git config --global core.longpaths true
3434
git config --global core.preloadindex true
3535
git config --global branch.autosetuprebase always
36-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2
36+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # tag: v6.0.1
3737
with:
3838
fetch-depth: 1
3939
- name: Setup Node.js
40-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # tag: v4.4.0
40+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # tag: v6.1.0
4141
with:
4242
node-version: lts/-1
4343
- name: Cache node_modules
4444
id: cache-node-modules
45-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # tag: v4.2.3
45+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # tag: v5.0.1
4646
with:
4747
path: node_modules
4848
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-node-modules
4949
- name: Install
5050
if: steps.cache-node-modules.outputs.cache-hit != 'true'
51-
run: yarn install
51+
run: yarn install --immutable
5252
- name: Test
5353
run: yarn test

.github/workflows/validate-configs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1818
- name: Validate JSON schema
1919
uses: dsanders11/json-schema-validate-action@79b2d95a446a0d786f7f244ae7764f8370ff3657 # v1.4.0
2020
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ third_party
99
.disable-auto-updates
1010
/*.yml
1111
generated.env.sh
12+
!.yarnrc.yml
13+
.yarn/install-state.gz

0 commit comments

Comments
 (0)