Skip to content

Commit cdb0a95

Browse files
authored
feat: added caching support for newer toolchains on Windows (#489)
1 parent f442f6e commit cdb0a95

33 files changed

Lines changed: 2302 additions & 1751 deletions

.devcontainer/devcontainer.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/universal:5-noble",
3-
"customizations": {
4-
"vscode": {
5-
"extensions": [
6-
"eamodio.gitlens",
7-
"ms-vscode.vscode-typescript-next",
8-
"vitest.explorer",
9-
"dbaeumer.vscode-eslint",
10-
"esbenp.prettier-vscode",
11-
"github.vscode-github-actions"
12-
]
13-
}
14-
},
15-
"postCreateCommand": "npm install --legacy-peer-deps"
2+
"image": "mcr.microsoft.com/devcontainers/universal:5-noble",
3+
"customizations": {
4+
"vscode": {
5+
"extensions": [
6+
"eamodio.gitlens",
7+
"ms-vscode.vscode-typescript-next",
8+
"vitest.explorer",
9+
"dbaeumer.vscode-eslint",
10+
"esbenp.prettier-vscode",
11+
"github.vscode-github-actions"
12+
]
13+
}
14+
},
15+
"postCreateCommand": "npm install --legacy-peer-deps"
1616
}

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ liberapay: soumyamahunt
1010
issuehunt: # Replace with a single IssueHunt username
1111
otechie: # Replace with a single Otechie username
1212
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: "[Bug] "
4+
title: '[Bug] '
55
labels: bug
66
assignees: ''
7-
87
---
98

109
- [ ] I have gone through the action [README](https://github.com/SwiftyLab/setup-swift/blob/main/README.md), [documentation](https://github.com/SwiftyLab/setup-swift/blob/main/action.yml) and [wiki](https://github.com/SwiftyLab/setup-swift/wiki).
@@ -15,6 +14,7 @@ A clear and concise description of what the bug is.
1514

1615
**To Reproduce**
1716
Steps to reproduce the behavior:
17+
1818
1. Choose runner '...'
1919
1. Provide action input '...'
2020
1. Run action with environment variables '...'
@@ -30,9 +30,10 @@ Action run log, either link to action run or log file.
3030
If applicable, add screenshots to help explain your problem.
3131

3232
**Runner (please complete the following information):**
33-
- Name: [e.g. macos-13]
34-
- OS: [e.g. macOS]
35-
- Version [e.g. 13.0]
33+
34+
- Name: [e.g. macos-13]
35+
- OS: [e.g. macOS]
36+
- Version [e.g. 13.0]
3637

3738
**Additional context**
3839
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: "[Feature Request] "
4+
title: '[Feature Request] '
55
labels: enhancement
66
assignees: ''
7-
87
---
98

109
- [ ] I have gone through the action [README](https://github.com/SwiftyLab/setup-swift/blob/main/README.md), [documentation](https://github.com/SwiftyLab/setup-swift/blob/main/action.yml) and [wiki](https://github.com/SwiftyLab/setup-swift/wiki).

.github/changelog/config.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
const config = require('conventional-changelog-conventionalcommits');
2+
const config = require('conventional-changelog-conventionalcommits')
33

44
module.exports = config({
55
types: [
@@ -18,4 +18,4 @@ module.exports = config({
1818
{type: 'wip', hidden: true},
1919
{type: 'chore', hidden: true}
2020
]
21-
});
21+
})
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict'
2-
const semver = require('semver');
3-
const core = require('@actions/core');
2+
const semver = require('semver')
3+
const core = require('@actions/core')
44

5-
exports.preVersionGeneration = (version) => {
6-
const {VERSION} = process.env;
7-
core.info(`Computed version bump: ${version}`);
5+
exports.preVersionGeneration = version => {
6+
const {VERSION} = process.env
7+
core.info(`Computed version bump: ${version}`)
88

9-
const newVersion = semver.valid(VERSION);
9+
const newVersion = semver.valid(VERSION)
1010
if (newVersion) {
11-
version = newVersion;
12-
core.info(`Using provided version: ${version}`);
11+
version = newVersion
12+
core.info(`Using provided version: ${version}`)
1313
}
14-
return version;
15-
};
14+
return version
15+
}
1616

17-
exports.preTagGeneration = (tag) => {};
17+
exports.preTagGeneration = _tag => {}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
2-
const {exec} = require('child_process');
3-
const {promisify} = require('util');
2+
const {exec} = require('child_process')
3+
const {promisify} = require('util')
44

5-
const execAsync = promisify(exec);
5+
const execAsync = promisify(exec)
66

7-
exports.preCommit = async (props) => {
8-
console.log('Bundling');
9-
await execAsync('npm install --legacy-peer-deps');
10-
await execAsync('npm run package');
11-
};
7+
exports.preCommit = async _props => {
8+
console.log('Bundling')
9+
await execAsync('npm install --legacy-peer-deps')
10+
await execAsync('npm run package')
11+
}

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ closes/fixes/resolves #[...]
22

33
## Description
44

5-
A clear and concise description of what this pull request addresses. [...]
5+
A clear and concise description of what this pull request addresses. [...]

.github/utils/update_metadata.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@ interface SnapshotEntry {
1919

2020
interface SwiftorgMetadata {
2121
commit: string
22+
commits: Record<string, string>
2223
release: SwiftRelease
2324
dev: SwiftRelease
2425
snapshot: {date: string; tag: string}
2526
}
2627

28+
async function swiftorgContractVersion(): Promise<string> {
29+
const data = await fs.readFile('package.json', 'utf-8')
30+
const packageJson = JSON.parse(data)
31+
return packageJson['swiftorg-contract-version']
32+
}
33+
2734
const SWIFT_ORG = 'swiftorg'
2835
const SWIFT_ORG_BUILD = path.join(SWIFT_ORG, '_data', 'builds')
2936
const SWIFT_ORG_CWD = {cwd: SWIFT_ORG}
@@ -82,7 +89,16 @@ export async function update(): Promise<string> {
8289
const dev = await latestDevRelease()
8390
const snapshot = await latestSnapshot()
8491

85-
const swiftorg: SwiftorgMetadata = {commit, release, dev, snapshot}
92+
const existing = await currentData()
93+
const version = await swiftorgContractVersion()
94+
const commits = {...existing.commits, [version]: commit}
95+
const swiftorg: SwiftorgMetadata = {
96+
commit: existing.commit,
97+
commits,
98+
release,
99+
dev,
100+
snapshot
101+
}
86102
const data = JSON.stringify(swiftorg)
87103
core.info(`Updating swiftorg metadata to "${data}"`)
88104
const metadata = path.join('pages', 'metadata.json')
@@ -137,11 +153,15 @@ export async function fetch(): Promise<void> {
137153
process.env.SETUPSWIFT_SWIFTORG_METADATA
138154
) as SwiftorgMetadata
139155
}
140-
if (!checkoutData || !checkoutData.commit) {
156+
const version = await swiftorgContractVersion()
157+
if (
158+
!checkoutData ||
159+
(!checkoutData.commits?.[version] && !checkoutData.commit)
160+
) {
141161
checkoutData = await currentData()
142162
}
143163
const origin = 'https://github.com/apple/swift-org-website.git'
144-
const ref = checkoutData.commit
164+
const ref = checkoutData.commits?.[version] ?? checkoutData.commit
145165
await exec('git', ['init', SWIFT_ORG])
146166
await exec(
147167
'git',

0 commit comments

Comments
 (0)