Skip to content

Commit 6afeb1e

Browse files
improvements
1 parent ff0c196 commit 6afeb1e

8 files changed

Lines changed: 368 additions & 102 deletions

File tree

.github/workflows/main.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: "PR Checks"
2-
on: push
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
36

47
permissions:
58
contents: read
@@ -14,13 +17,23 @@ jobs:
1417
with:
1518
node-version: 20
1619
cache: 'npm'
17-
- run: npm install
20+
- run: npm ci
21+
- run: npm run format-check
22+
- run: npm run lint
1823
- run: npm test
24+
- name: Verify dist/ is up to date
25+
run: |
26+
npm run build
27+
git diff --exit-code dist/ || (
28+
echo "::error::dist/ is out of date — run 'npm run build' and commit the result." >&2
29+
exit 1
30+
)
1931
2032
e2e:
2133
runs-on: ubuntu-latest
2234
name: E2E Test
2335
needs: unit
36+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
2437
steps:
2538
- uses: actions/checkout@v4
2639
- uses: actions/setup-node@v4
@@ -32,8 +45,8 @@ jobs:
3245
key: ${{ secrets.TB_KEY }}
3346
secret: ${{ secrets.TB_SECRET }}
3447
tunnelIdentifier: github-action-tunnel
35-
- run: npm install
48+
- run: npm ci
3649
- run: npm run test:e2e
3750
env:
3851
TB_KEY: ${{ secrets.TB_KEY }}
39-
TB_SECRET: ${{ secrets.TB_SECRET }}
52+
TB_SECRET: ${{ secrets.TB_SECRET }}

dist/main/index.js

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -94250,6 +94250,47 @@ async function startTunnel() {
9425094250
}
9425194251

9425294252

94253+
/***/ }),
94254+
94255+
/***/ 79407:
94256+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
94257+
94258+
"use strict";
94259+
94260+
Object.defineProperty(exports, "__esModule", ({ value: true }));
94261+
exports.retryDelays = void 0;
94262+
exports.run = run;
94263+
const core_1 = __nccwpck_require__(37484);
94264+
const container_1 = __nccwpck_require__(36296);
94265+
exports.retryDelays = [1, 1, 1, 2, 3, 4, 5, 10, 20, 40, 60].map(a => a * 1000);
94266+
async function run() {
94267+
const retryTimeout = (parseInt((0, core_1.getInput)('retryTimeout'), 10) || 10) * 1000 * 60;
94268+
const startTime = Date.now();
94269+
for (let i = 0;; i++) {
94270+
try {
94271+
const containerId = await (0, container_1.startTunnel)();
94272+
(0, core_1.saveState)('containerId', containerId);
94273+
return;
94274+
}
94275+
catch (e) {
94276+
if (Date.now() - startTime >= retryTimeout) {
94277+
break;
94278+
}
94279+
const delay = exports.retryDelays[Math.min(exports.retryDelays.length - 1, i)];
94280+
const message = e instanceof Error ? e.message : String(e);
94281+
(0, core_1.warning)(`Error occurred on attempt ${i + 1} (${message}). Retrying in ${delay} ms...`);
94282+
await new Promise(resolve => setTimeout(resolve, delay));
94283+
}
94284+
}
94285+
throw new Error('Timed out waiting for Tunnel to start');
94286+
}
94287+
/* istanbul ignore next */
94288+
if (require.main === require.cache[eval('__filename')]) {
94289+
// eslint-disable-next-line github/no-then
94290+
run().catch(error => (0, core_1.setFailed)(error instanceof Error ? error.message : String(error)));
94291+
}
94292+
94293+
9425394294
/***/ }),
9425494295

9425594296
/***/ 42078:
@@ -143654,42 +143695,12 @@ module.exports = /*#__PURE__*/JSON.parse('[{"actionOption":"auth","dockerOption"
143654143695
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
143655143696
/******/
143656143697
/************************************************************************/
143657-
var __webpack_exports__ = {};
143658-
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
143659-
(() => {
143660-
"use strict";
143661-
var exports = __webpack_exports__;
143662-
143663-
Object.defineProperty(exports, "__esModule", ({ value: true }));
143664-
const core_1 = __nccwpck_require__(37484);
143665-
const container_1 = __nccwpck_require__(36296);
143666-
const retryDelays = [1, 1, 1, 2, 3, 4, 5, 10, 20, 40, 60].map(a => a * 1000);
143667-
async function run() {
143668-
const retryTimeout = (parseInt((0, core_1.getInput)('retryTimeout'), 10) || 10) * 1000 * 60;
143669-
const startTime = Date.now();
143670-
for (let i = 0;; i++) {
143671-
try {
143672-
const containerId = await (0, container_1.startTunnel)();
143673-
(0, core_1.saveState)('containerId', containerId);
143674-
return;
143675-
}
143676-
catch (e) {
143677-
if (Date.now() - startTime >= retryTimeout) {
143678-
break;
143679-
}
143680-
const delay = retryDelays[Math.min(retryDelays.length - 1, i)];
143681-
const message = e instanceof Error ? e.message : String(e);
143682-
(0, core_1.warning)(`Error occurred on attempt ${i + 1} (${message}). Retrying in ${delay} ms...`);
143683-
await new Promise(resolve => setTimeout(resolve, delay));
143684-
}
143685-
}
143686-
throw new Error('Timed out waiting for Tunnel to start');
143687-
}
143688-
// eslint-disable-next-line github/no-then
143689-
run().catch(error => (0, core_1.setFailed)(error instanceof Error ? error.message : String(error)));
143690-
143691-
})();
143692-
143693-
module.exports = __webpack_exports__;
143698+
/******/
143699+
/******/ // startup
143700+
/******/ // Load entry module and return exports
143701+
/******/ // This entry module is referenced by other modules so it can't be inlined
143702+
/******/ var __webpack_exports__ = __nccwpck_require__(79407);
143703+
/******/ module.exports = __webpack_exports__;
143704+
/******/
143694143705
/******/ })()
143695143706
;

dist/post/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143661,6 +143661,7 @@ var __webpack_exports__ = {};
143661143661
var exports = __webpack_exports__;
143662143662

143663143663
Object.defineProperty(exports, "__esModule", ({ value: true }));
143664+
exports.run = run;
143664143665
const core_1 = __nccwpck_require__(37484);
143665143666
const container_1 = __nccwpck_require__(36296);
143666143667
async function run() {
@@ -143674,8 +143675,11 @@ async function run() {
143674143675
await (0, container_1.uploadLog)();
143675143676
}
143676143677
}
143677-
// eslint-disable-next-line github/no-then
143678-
run().catch(error => (0, core_1.setFailed)(error instanceof Error ? error.message : String(error)));
143678+
/* istanbul ignore next */
143679+
if (require.main === require.cache[eval('__filename')]) {
143680+
// eslint-disable-next-line github/no-then
143681+
run().catch(error => (0, core_1.setFailed)(error instanceof Error ? error.message : String(error)));
143682+
}
143679143683

143680143684
})();
143681143685

src/index.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {getInput, saveState, setFailed, warning} from '@actions/core'
22
import {startTunnel} from './container'
33

4-
const retryDelays = [1, 1, 1, 2, 3, 4, 5, 10, 20, 40, 60].map(a => a * 1000)
4+
export const retryDelays = [1, 1, 1, 2, 3, 4, 5, 10, 20, 40, 60].map(
5+
a => a * 1000
6+
)
57

6-
async function run(): Promise<void> {
8+
export async function run(): Promise<void> {
79
const retryTimeout =
810
(parseInt(getInput('retryTimeout'), 10) || 10) * 1000 * 60
911
const startTime = Date.now()
@@ -20,13 +22,20 @@ async function run(): Promise<void> {
2022
const delay = retryDelays[Math.min(retryDelays.length - 1, i)]
2123
const message = e instanceof Error ? e.message : String(e)
2224
warning(
23-
`Error occurred on attempt ${i + 1} (${message}). Retrying in ${delay} ms...`
25+
`Error occurred on attempt ${
26+
i + 1
27+
} (${message}). Retrying in ${delay} ms...`
2428
)
2529
await new Promise<void>(resolve => setTimeout(resolve, delay))
2630
}
2731
}
2832
throw new Error('Timed out waiting for Tunnel to start')
2933
}
3034

31-
// eslint-disable-next-line github/no-then
32-
run().catch(error => setFailed(error instanceof Error ? error.message : String(error)))
35+
/* istanbul ignore next */
36+
if (require.main === module) {
37+
// eslint-disable-next-line github/no-then
38+
run().catch(error =>
39+
setFailed(error instanceof Error ? error.message : String(error))
40+
)
41+
}

src/post.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {getState, warning, setFailed, getInput} from '@actions/core'
22
import {stopTunnel, uploadLog} from './container'
33

4-
async function run(): Promise<void> {
4+
export async function run(): Promise<void> {
55
const containerId = getState('containerId')
66
if (!containerId) {
77
warning('No active TestingBot Tunnel available.')
@@ -14,5 +14,10 @@ async function run(): Promise<void> {
1414
}
1515
}
1616

17-
// eslint-disable-next-line github/no-then
18-
run().catch(error => setFailed(error instanceof Error ? error.message : String(error)))
17+
/* istanbul ignore next */
18+
if (require.main === module) {
19+
// eslint-disable-next-line github/no-then
20+
run().catch(error =>
21+
setFailed(error instanceof Error ? error.message : String(error))
22+
)
23+
}

0 commit comments

Comments
 (0)