Skip to content

Commit fb19563

Browse files
authored
Fix release process (#283)
* Use node 22 for release action * Use upload-artifact@v4 Fixes: This request has been automatically failed because it uses a deprecated version of `actions/upload-artifact: v3` * Increase sauce connect ready timeout from 30s to 60s * Increase sauce connect close timeout from 5s to 10s * Increase timeout for sc e2e tests * Do not fail silently if error is not caused by a http request itself
1 parent c802d74 commit fb19563

File tree

6 files changed

+42
-19
lines changed

6 files changed

+42
-19
lines changed

.github/workflows/npm-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
- name: Setup Node version
2323
uses: actions/setup-node@v3
2424
with:
25-
node-version: 16
25+
node-version: 22
2626
- name: Install dependencies
2727
run: npm ci
2828
- run: npm run build
2929
- name: Run tests
3030
run: npm test
3131
- name: Upload built package
32-
uses: actions/upload-artifact@v3
32+
uses: actions/upload-artifact@v4
3333
with:
3434
name: compiled-package
3535
path: build/
@@ -43,7 +43,7 @@ jobs:
4343
- name: Setup Node version
4444
uses: actions/setup-node@v3
4545
with:
46-
node-version: 16
46+
node-version: 22
4747
registry-url: https://registry.npmjs.org/
4848
- name: Setup Git
4949
run: |

e2e/sc.test.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ID = process.env.GITHUB_RUN_ID ?? '(local)';
55
// in GitHub Actions, otherwise it fails for untrusted PRs
66
const SKIP_TEST = process.env.GITHUB_RUN_ID && !process.env.SAUCE_USERNAME;
77

8-
jest.setTimeout(60 * 1000); // 60s should be sufficient to boot SC
8+
jest.setTimeout(120 * 1000); // 120s should be sufficient to run all SC tests
99

1010
/**
1111
* unmock
@@ -77,9 +77,3 @@ test('should be able to run Sauce Connect', async () => {
7777
console.log('Sauce Connect started successfully, shutting down...');
7878
await sc.close();
7979
});
80-
81-
afterAll(async () => {
82-
// this is here because for whatever reason, we're logging output from
83-
// sc _after_ sc.close() has fulfilled. this is disallowed by jest, for whatever reason
84-
await new Promise((resolve) => setTimeout(resolve, 5000));
85-
});

src/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,6 @@ export const SC_PARAMS_TO_STRIP = [
329329
...SAUCE_CONNECT_CLI_PARAM_ALIASES,
330330
];
331331

332-
export const SC_CLOSE_TIMEOUT = 5000;
333-
export const SC_READY_TIMEOUT = 30000;
332+
export const SC_CLOSE_TIMEOUT = 10000;
333+
export const SC_READY_TIMEOUT = 60000;
334334
export const SC_HEALTHCHECK_TIMEOUT = 1000;

src/sauceConnectHealthcheck.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class SauceConnectHealthCheck {
66
signal: AbortSignal.timeout(SC_HEALTHCHECK_TIMEOUT),
77
});
88
if (response.status !== 200) {
9-
throw new Error(`response status code ${response.status} != 200`);
9+
throw new TypeError(`response status code ${response.status} != 200`);
1010
}
1111
}
1212
}

src/sauceConnectManager.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {
66
import SauceConnectHealthCheck from './sauceConnectHealthcheck';
77

88
export class SauceConnectManager {
9-
constructor(cp, logger) {
9+
constructor(cp, logger, healthcheck) {
1010
this.cp = cp;
1111
this.logger = logger || (() => {});
12-
this.healthcheck = new SauceConnectHealthCheck();
12+
this.healthcheck = healthcheck || new SauceConnectHealthCheck();
1313
this._healthcheckInterval = null;
1414
this._readyTimeout = null;
1515
}
@@ -41,10 +41,18 @@ export class SauceConnectManager {
4141

4242
this.healthcheck
4343
.perform(apiAddress)
44-
.then(() => clearInterval(this._healthcheckInterval))
45-
.then(() => clearTimeout(this._readyTimeout))
46-
.then(resolve)
47-
.catch(() => {});
44+
.then(() => {
45+
clearInterval(this._healthcheckInterval);
46+
clearTimeout(this._readyTimeout);
47+
resolve();
48+
})
49+
.catch((err) => {
50+
if (err.name !== 'TypeError') {
51+
clearInterval(this._healthcheckInterval);
52+
clearTimeout(this._readyTimeout);
53+
reject(err);
54+
}
55+
});
4856
}, SC_HEALTHCHECK_TIMEOUT);
4957

5058
this._readyTimeout = setTimeout(() => {

tests/sauceConnectManager.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ describe('SauceConnectManager', () => {
1919
);
2020
});
2121

22+
test('error when requesting healthcheck', async () => {
23+
const manager = new SauceConnectManager(
24+
{
25+
stderr: {
26+
on: jest.fn(),
27+
},
28+
stdout: {
29+
on: jest.fn(),
30+
},
31+
},
32+
undefined,
33+
{
34+
async perform() {
35+
throw new Error('custom error');
36+
},
37+
}
38+
);
39+
const error = await manager.waitForReady(':8042').catch((err) => err);
40+
expect(error.message).toBe('custom error');
41+
});
42+
2243
describe('waiting too long for healthcheck', () => {
2344
let origTimeout = constants.SC_READY_TIMEOUT;
2445
beforeEach(() => {

0 commit comments

Comments
 (0)