Skip to content

Commit 63fd9f4

Browse files
committed
Use versions of Task with Apple Silicon builds in tests
The unit and integration tests install various versions of Task. The GitHub Actions macos-latest runner was recently changed from using x86 machines to Apple Silicon/ARM machines. Task is now built for both architectures. However, this was not done for the older versions of Task previously used for the tests. The runner architecture switch caused the tests to start failing spuriously on the macos-latest GitHub Actions workflow run jobs: ``` FAIL __tests__/main.test.ts installer tests ✕ Downloads version of Task if no matching version is installed (188 ms) Gets the latest release of Task ✕ Gets the latest version of Task 2.5 using 2.5 and no matching version is installed (174 ms) ✕ Gets latest version of Task using 2.x and no matching version is installed (68 ms) ✕ Gets preview version of Task using 3.x and no matching version is installed (167 ms) ✕ Skips version computing when a valid semver is provided (164 ms) ● installer tests › Downloads version of Task if no matching version is installed Failed to download version v2.6.0: Error: Unexpected HTTP response: 404 165 | core.debug(error.toString()); 166 | } > 167 | throw new Error(`Failed to download version ${version}: ${error}`); | ^ 168 | } 169 | 170 | // Extract at src/installer.ts:167:11 at Generator.throw (<anonymous>) at rejected (src/installer.ts:40:65) ● installer tests › Gets the latest release of Task › Gets the latest version of Task 2.5 using 2.5 and no matching version is installed Failed to download version v2.5.2: Error: Unexpected HTTP response: 404 165 | core.debug(error.toString()); 166 | } > 167 | throw new Error(`Failed to download version ${version}: ${error}`); | ^ 168 | } 169 | 170 | // Extract at src/installer.ts:167:11 at Generator.throw (<anonymous>) at rejected (src/installer.ts:40:65) ● installer tests › Gets the latest release of Task › Gets latest version of Task using 2.x and no matching version is installed Failed to download version v2.6.0: Error: Unexpected HTTP response: 404 165 | core.debug(error.toString()); 166 | } > 167 | throw new Error(`Failed to download version ${version}: ${error}`); | ^ 168 | } 169 | 170 | // Extract at src/installer.ts:167:11 at Generator.throw (<anonymous>) at rejected (src/installer.ts:40:65) ● installer tests › Gets the latest release of Task › Gets preview version of Task using 3.x and no matching version is installed Failed to download version v3.0.0-preview1: Error: Unexpected HTTP response: 404 165 | core.debug(error.toString()); 166 | } > 167 | throw new Error(`Failed to download version ${version}: ${error}`); | ^ 168 | } 169 | 170 | // Extract at src/installer.ts:167:11 at Generator.throw (<anonymous>) at rejected (src/installer.ts:40:65) ● installer tests › Gets the latest release of Task › Skips version computing when a valid semver is provided Failed to download version v3.0.0: Error: Unexpected HTTP response: 404 165 | core.debug(error.toString()); 166 | } > 167 | throw new Error(`Failed to download version ${version}: ${error}`); | ^ 168 | } 169 | 170 | // Extract at src/installer.ts:167:11 at Generator.throw (<anonymous>) at rejected (src/installer.ts:40:65) ``` ``` Error: Failed to download version v3.4.1: Error: Unexpected HTTP response: 404 ``` The obvious solution would be to pin the runner to the last x86 runner: macos-13 in the test runner workflows. However, GitHub phases out runners over time so this would not be a future proof solution. The chosen solution is to continue to use the Apple Silicon macos-latest runner and adjust the tests to use versions of Task for which an Apple Silicon build is available. This was not possible for the integration test of the action's major version pinning capability. The reason is that a previous major version (2.x) must be used in this test in order to allow a consistent assertion, since the installed version would change over time if the latest major version was used. Apple Silicon builds are not available in the 2.x Task version series. For this reason, the integration test runner workflow is configured to skip that test on the macos-latest runner job. The Linux and Windows integration test runner jobs, as well as unit test (which is not constrained in this way due to using artificial tags data) will provide sufficient coverage for this capability.
1 parent 4158d2b commit 63fd9f4

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

.github/workflows/test-integration.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,18 @@ jobs:
5454
version:
5555
- input: 2.x
5656
expected: "Task version: 2.8.1"
57-
- input: 2.8.x
58-
expected: "Task version: 2.8.1"
59-
- input: 3.4.1
60-
expected: "Task version: 3.4.1"
57+
- input: 3.36.x
58+
expected: "Task version: v3.36.0 (h1:XVJ5hQ5hdzTAulHpAGzbUMUuYr9MUOEQFOFazI3hUsY=)"
59+
- input: 3.37.2
60+
expected: "Task version: v3.37.2 (h1:Jwgvo+2vX79Fu+44xPxVKC5DIkUE89QeDjN2tmYaQzA=)"
61+
62+
exclude:
63+
# The macos-latest runner is an Apple Silicon machine, but Task 2.x is only available for x86 on macOS, which
64+
# would cause a spurious test failure: "Unexpected HTTP response: 404"
65+
- runs-on: macos-latest
66+
version:
67+
input: 2.x
68+
expected: "Task version: 2.8.1"
6169

6270
steps:
6371
- name: Checkout repository

__tests__/main.test.ts

+9-21
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ describe("installer tests", () => {
4343
});
4444

4545
it("Downloads version of Task if no matching version is installed", async () => {
46-
await installer.getTask("2.6.0", "");
47-
const taskDir = path.join(toolDir, "task", "2.6.0", os.arch());
46+
await installer.getTask("3.37.1", "");
47+
const taskDir = path.join(toolDir, "task", "3.37.1", os.arch());
4848

4949
expect(fs.existsSync(`${taskDir}.complete`)).toBe(true);
5050

@@ -67,9 +67,9 @@ describe("installer tests", () => {
6767
nock.enableNetConnect();
6868
});
6969

70-
it("Gets the latest version of Task 2.5 using 2.5 and no matching version is installed", async () => {
71-
await installer.getTask("2.5", "");
72-
const taskDir = path.join(toolDir, "task", "2.5.2", os.arch());
70+
it("Gets the latest version of Task 3.36 using 3.36 and no matching version is installed", async () => {
71+
await installer.getTask("3.36", "");
72+
const taskDir = path.join(toolDir, "task", "3.36.0", os.arch());
7373

7474
expect(fs.existsSync(`${taskDir}.complete`)).toBe(true);
7575
if (IS_WINDOWS) {
@@ -79,21 +79,9 @@ describe("installer tests", () => {
7979
}
8080
});
8181

82-
it("Gets latest version of Task using 2.x and no matching version is installed", async () => {
83-
await installer.getTask("2.x", "");
84-
const taskdir = path.join(toolDir, "task", "2.6.0", os.arch());
85-
86-
expect(fs.existsSync(`${taskdir}.complete`)).toBe(true);
87-
if (IS_WINDOWS) {
88-
expect(fs.existsSync(path.join(taskdir, "bin", "task.exe"))).toBe(true);
89-
} else {
90-
expect(fs.existsSync(path.join(taskdir, "bin", "task"))).toBe(true);
91-
}
92-
});
93-
94-
it("Gets preview version of Task using 3.x and no matching version is installed", async () => {
82+
it("Gets latest version of Task using 3.x and no matching version is installed", async () => {
9583
await installer.getTask("3.x", "");
96-
const taskdir = path.join(toolDir, "task", "3.0.0-preview1", os.arch());
84+
const taskdir = path.join(toolDir, "task", "3.37.2", os.arch());
9785

9886
expect(fs.existsSync(`${taskdir}.complete`)).toBe(true);
9987
if (IS_WINDOWS) {
@@ -104,8 +92,8 @@ describe("installer tests", () => {
10492
});
10593

10694
it("Skips version computing when a valid semver is provided", async () => {
107-
await installer.getTask("3.0.0", "");
108-
const taskdir = path.join(toolDir, "task", "3.0.0", os.arch());
95+
await installer.getTask("3.37.0", "");
96+
const taskdir = path.join(toolDir, "task", "3.37.0", os.arch());
10997

11098
expect(fs.existsSync(`${taskdir}.complete`)).toBe(true);
11199
if (IS_WINDOWS) {

__tests__/testdata/tags.json

+30
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,35 @@
248248
"type": "tag",
249249
"url": "https://api.github.com/repos/go-task/task/git/tags/b637b3f832f28ce254377e507170c62cce3c20da"
250250
}
251+
},
252+
{
253+
"ref": "refs/tags/v3.36.0",
254+
"node_id": "MDM6UmVmODMyNTI5ODM6cmVmcy90YWdzL3YzLjM2LjA=",
255+
"url": "https://api.github.com/repos/go-task/task/git/refs/tags/v3.36.0",
256+
"object": {
257+
"sha": "cc6d0979c6584edc68623aa67ffe29742baeaefe",
258+
"type": "tag",
259+
"url": "https://api.github.com/repos/go-task/task/git/tags/cc6d0979c6584edc68623aa67ffe29742baeaefe"
260+
}
261+
},
262+
{
263+
"ref": "refs/tags/v3.37.1",
264+
"node_id": "MDM6UmVmODMyNTI5ODM6cmVmcy90YWdzL3YzLjM3LjE=",
265+
"url": "https://api.github.com/repos/go-task/task/git/refs/tags/v3.37.1",
266+
"object": {
267+
"sha": "e48824e99dbccf39dc7d376c2684560945123b30",
268+
"type": "tag",
269+
"url": "https://api.github.com/repos/go-task/task/git/tags/e48824e99dbccf39dc7d376c2684560945123b30"
270+
}
271+
},
272+
{
273+
"ref": "refs/tags/v3.37.2",
274+
"node_id": "MDM6UmVmODMyNTI5ODM6cmVmcy90YWdzL3YzLjM3LjI=",
275+
"url": "https://api.github.com/repos/go-task/task/git/refs/tags/v3.37.2",
276+
"object": {
277+
"sha": "7aa90b1511c05da43f415d3e6b27aa9866cb40cb",
278+
"type": "tag",
279+
"url": "https://api.github.com/repos/go-task/task/git/tags/7aa90b1511c05da43f415d3e6b27aa9866cb40cb"
280+
}
251281
}
252282
]

0 commit comments

Comments
 (0)