Skip to content

Commit ada4997

Browse files
authored
Merge branch 'main' into patch-1
2 parents c8f38d6 + ed6bdea commit ada4997

File tree

16 files changed

+10680
-1992
lines changed

16 files changed

+10680
-1992
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ assignees: fwal
1111
A clear and concise description of what the bug is.
1212

1313
**Workflow configuration (please complete the following information):**
14+
- Action version (`uses`): [e.g. swift-actions/setup-swift@v1]
1415
- Platform (`runs-on`): [e.g. ubuntu-latest]
15-
- Swift version (`swift-version`): [e.g. 5.2]
16+
- Swift version (`swift-version`): [e.g. 5.7]

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ jobs:
2222
runs-on: ${{ matrix.os }}
2323
strategy:
2424
matrix:
25-
os: [ubuntu-latest, macos-latest]
26-
swift: ["5.6.1"]
25+
os: [ubuntu-latest, macos-latest, windows-latest]
26+
swift: ["5.6.3"]
27+
include:
28+
- os: windows-latest
29+
swift: "5.3"
2730
steps:
2831
- uses: actions/checkout@v3
2932
- run: npm install

.github/workflows/stability.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, macos-latest]
14-
swift: ["5.6.1"]
14+
swift: ["5.6.3"]
1515
steps:
1616
- uses: swift-actions/setup-swift@v1
1717
with:
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
matrix:
2727
os: [ubuntu-latest, macos-latest]
28-
swift: ["5.6.1"]
28+
swift: ["5.6.3"]
2929
steps:
3030
- uses: swift-actions/setup-swift@main
3131
with:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<img src="https://img.shields.io/badge/GitHub-Action-blue?logo=github" alt="GitHub Action" />
55
</a>
66
<a href="https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources">
7-
<img src="https://img.shields.io/badge/platform-macOS%20%7C%20Ubuntu-lightgray" alt="Supports macOS and Ubuntu" />
7+
<img src="https://img.shields.io/badge/platform-macOS%20%7C%20Ubuntu%20%7C%20Windows-lightgray" alt="Supports macOS, Ubuntu & Windows" />
88
</a>
99
<a href="https://swift.org">
10-
<img src="https://img.shields.io/badge/Swift-5.6.1-F05138?logo=swift&logoColor=white" alt="Swift 5.6.1" />
10+
<img src="https://img.shields.io/badge/Swift-5.6.3-F05138?logo=swift&logoColor=white" alt="Swift 5.6.3" />
1111
</a>
1212
<a href="https://github.com/swift-actions/setup-swift/releases/latest">
1313
<img src="https://img.shields.io/github/v/release/swift-actions/setup-swift?sort=semver" alt="Latest release" />
@@ -28,7 +28,7 @@ After the environment is configured you can run swift commands using the standar
2828
```yaml
2929
- uses: swift-actions/setup-swift@v1
3030
- name: Get swift version
31-
run: swift --version # Swift 5.6.1
31+
run: swift --version # Swift 5.6.3
3232
```
3333

3434
A specific Swift version can be set using the `swift-version` input:

__tests__/os.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ describe("os resolver", () => {
1919
expect(mac.os).toBe(os.OS.MacOS);
2020
expect(mac.version).toBe("latest");
2121
expect(mac.name).toBe("macOS");
22+
23+
setSystem({ os: "win32", dist: "Windows", release: "latest" });
24+
25+
let windows = await os.getSystem();
26+
expect(windows.os).toBe(os.OS.Windows);
27+
expect(windows.version).toBe("latest");
28+
expect(windows.name).toBe("Windows");
2229
});
2330

2431
it("throws an error if the os is not supported", async () => {

__tests__/swift-versions.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as versions from "../src/swift-versions";
33

44
const macOS: System = { os: OS.MacOS, version: "latest", name: "macOS" };
55
const ubuntu: System = { os: OS.Ubuntu, version: "latest", name: "Ubuntu" };
6+
const windows: System = { os: OS.Windows, version: "latest", name: "Windows" };
67

78
describe("swift version resolver", () => {
89
it("identifies X.X.X versions", async () => {
@@ -27,7 +28,7 @@ describe("swift version resolver", () => {
2728

2829
it("identifies X versions", async () => {
2930
const version = await versions.verify("5", macOS);
30-
expect(version).toBe("5.6.1");
31+
expect(version).toBe("5.6.3");
3132
});
3233

3334
it("identifies versions based on system", async () => {
@@ -39,12 +40,19 @@ describe("swift version resolver", () => {
3940
});
4041

4142
it("throws an error if the version isn't available for the system", async () => {
42-
expect.assertions(1);
43+
expect.assertions(2);
44+
4345
try {
4446
await versions.verify("5.0.3", macOS);
4547
} catch (e) {
4648
expect(e).toEqual(new Error('Version "5.0.3" is not available'));
4749
}
50+
51+
try {
52+
await versions.verify("5.2", windows);
53+
} catch (e) {
54+
expect(e).toEqual(new Error('Version "5.2" is not available'));
55+
}
4856
});
4957

5058
it("throws an error if version is invalid", async () => {

__tests__/visual-studio.test.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import os from "os";
2+
import * as path from "path";
3+
import * as vs from "../src/visual-studio";
4+
import { swiftPackage } from "../src/swift-versions";
5+
import { OS, System } from "../src/os";
6+
7+
jest.mock("fs", () => {
8+
const original = jest.requireActual("fs");
9+
return {
10+
...original,
11+
existsSync: jest.fn((path) => true),
12+
};
13+
});
14+
15+
const windows: System = { os: OS.Windows, version: "latest", name: "Windows" };
16+
17+
describe("visual studio resolver", () => {
18+
const env = process.env;
19+
20+
beforeEach(() => {
21+
jest.resetModules();
22+
process.env = { ...env };
23+
});
24+
25+
afterEach(() => {
26+
process.env = env;
27+
});
28+
29+
it("fetches visual studio requirement for swift version", async () => {
30+
jest.spyOn(os, "release").mockReturnValue("10.0.17763");
31+
32+
const req5_3 = vs.vsRequirement(swiftPackage("5.3", windows));
33+
expect(req5_3.version).toBe("16");
34+
expect(req5_3.components).toContain(
35+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
36+
);
37+
expect(req5_3.components).toContain(
38+
"Microsoft.VisualStudio.Component.Windows10SDK.17763"
39+
);
40+
41+
const req5_6 = vs.vsRequirement(swiftPackage("5.6", windows));
42+
expect(req5_6.version).toBe("16");
43+
expect(req5_6.components).toContain(
44+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
45+
);
46+
expect(req5_6.components).toContain(
47+
"Microsoft.VisualStudio.Component.Windows10SDK.17763"
48+
);
49+
});
50+
51+
it("adds latest sdk for release newer than or equal to build 17763", async () => {
52+
jest.spyOn(os, "release").mockReturnValue("10.0.17763");
53+
const req17763 = vs.vsRequirement(swiftPackage("5.3", windows));
54+
expect(req17763.components).toContain(
55+
"Microsoft.VisualStudio.Component.Windows10SDK.17763"
56+
);
57+
58+
jest.spyOn(os, "release").mockReturnValue("10.0.18363");
59+
const req18363 = vs.vsRequirement(swiftPackage("5.3", windows));
60+
expect(req18363.components).toContain(
61+
"Microsoft.VisualStudio.Component.Windows10SDK.18363"
62+
);
63+
});
64+
65+
it("adds recommended sdk for release older than build 17763", async () => {
66+
jest.spyOn(os, "release").mockReturnValue("10.0.16299");
67+
const req16299 = vs.vsRequirement(swiftPackage("5.3", windows));
68+
expect(req16299.components).toContain(
69+
"Microsoft.VisualStudio.Component.Windows10SDK.17763"
70+
);
71+
});
72+
73+
it("finds vswhere path from environment value", async () => {
74+
const vswherePath = path.join("C:", "bin");
75+
const vswhereExe = path.join(vswherePath, "vswhere.exe");
76+
process.env.VSWHERE_PATH = vswherePath;
77+
expect(await vs.getVsWherePath()).toBe(vswhereExe);
78+
});
79+
80+
it("finds vswhere path from ProgramFiles environment value", async () => {
81+
const vswhereExe = path.join(
82+
"C:",
83+
"Program Files (x86)",
84+
"Microsoft Visual Studio",
85+
"Installer",
86+
"vswhere.exe"
87+
);
88+
process.env["ProgramFiles(x86)"] = path.join("C:", "Program Files (x86)");
89+
expect(await vs.getVsWherePath()).toBe(vswhereExe);
90+
});
91+
});

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
swift-version:
66
description: Swift version to configure
77
required: true
8-
default: '5.6.1'
8+
default: '5.6.3'
99
outputs:
1010
version:
1111
description: The full Swift version that was configured

0 commit comments

Comments
 (0)