Compare commits

...

9 Commits

Author SHA1 Message Date
Nick Fields
9417ab4993 Merge pull request #148 from xavier2k6/nf_retry_p1
Bump `ci_cd` workflow actions
2025-02-25 08:56:37 -05:00
Nick Fields
07cd61dba6 Merge branch 'master' into nf_retry_p1 2025-02-25 08:44:45 -05:00
Nick Fields
ce71cc2ab8 Merge pull request #150 from nick-fields/nrf/bump-sem-rels
Bump semantic-release packages
2025-02-25 08:22:06 -05:00
Nick Fields
b3eed5aa93 patch: bump semantic-release packages 2025-02-25 08:17:18 -05:00
Nick Fields
d6b241c90e Merge branch 'master' into nf_retry_p1 2025-02-25 08:05:30 -05:00
Nick Fields
41b1e1aaef Bump action versions, fix tag step in release, regen js (#149)
* patch: bump assert-action to latest version

* patch: only attempt to move the major version tag if a new release published
2025-02-25 08:01:36 -05:00
xavier2k6
8d92921684 Bump ci_cd workflow actions
* `nick-fields/assert-action` to `v2`
https://github.com/nick-fields/assert-action/releases

* `codecov/codecov-action` to `v5`
https://github.com/codecov/codecov-action/releases
2025-02-25 12:20:54 +00:00
Raja Anbazhagan
361088214a refactor: update actions from nick-invision to nick-fields (#147) 2025-02-25 06:54:55 -05:00
Raja Anbazhagan
c97818ca39 fix: group log lines for each attempt (#146) 2025-02-17 12:26:57 -05:00
5 changed files with 3393 additions and 1987 deletions

View File

@@ -23,7 +23,7 @@ jobs:
run: npm ci run: npm ci
- name: Run Unit Tests - name: Run Unit Tests
run: npm test run: npm test
- uses: codecov/codecov-action@v3 - uses: codecov/codecov-action@v5
with: with:
directory: ./coverage/ directory: ./coverage/
verbose: true verbose: true
@@ -48,7 +48,7 @@ jobs:
timeout_minutes: 1 timeout_minutes: 1
max_attempts: 2 max_attempts: 2
command: npm -v command: npm -v
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: true expected: true
actual: ${{ steps.happy_path.outputs.total_attempts == '1' && steps.happy_path.outputs.exit_code == '0' }} actual: ${{ steps.happy_path.outputs.total_attempts == '1' && steps.happy_path.outputs.exit_code == '0' }}
@@ -67,11 +67,11 @@ jobs:
timeout_minutes: 1 timeout_minutes: 1
max_attempts: 2 max_attempts: 2
command: node -e "process.exit(1)" command: node -e "process.exit(1)"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.sad_path_error.outputs.total_attempts }} actual: ${{ steps.sad_path_error.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.sad_path_error.outcome }} actual: ${{ steps.sad_path_error.outcome }}
@@ -85,15 +85,15 @@ jobs:
max_attempts: 3 max_attempts: 3
retry_on: timeout retry_on: timeout
command: node -e "process.exit(2)" command: node -e "process.exit(2)"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 1 expected: 1
actual: ${{ steps.retry_on_timeout_fail.outputs.total_attempts }} actual: ${{ steps.retry_on_timeout_fail.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.retry_on_timeout_fail.outcome }} actual: ${{ steps.retry_on_timeout_fail.outcome }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.retry_on_timeout_fail.outputs.exit_code }} actual: ${{ steps.retry_on_timeout_fail.outputs.exit_code }}
@@ -107,15 +107,15 @@ jobs:
max_attempts: 2 max_attempts: 2
retry_on: error retry_on: error
command: node -e "process.exit(2)" command: node -e "process.exit(2)"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.retry_on_error.outputs.total_attempts }} actual: ${{ steps.retry_on_error.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.retry_on_error.outcome }} actual: ${{ steps.retry_on_error.outcome }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.retry_on_error.outputs.exit_code }} actual: ${{ steps.retry_on_error.outputs.exit_code }}
@@ -129,11 +129,11 @@ jobs:
max_attempts: 2 max_attempts: 2
shell: cmd shell: cmd
command: 'dir' command: 'dir'
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.wrong_shell.outputs.total_attempts }} actual: ${{ steps.wrong_shell.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.wrong_shell.outcome }} actual: ${{ steps.wrong_shell.outcome }}
@@ -180,12 +180,12 @@ jobs:
timeout_minutes: 5 timeout_minutes: 5
command: 'make -C ./test-data/large-output bytes-102400' command: 'make -C ./test-data/large-output bytes-102400'
- name: Assert test had expected result - name: Assert test had expected result
uses: nick-invision/assert-action@v1 uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.large-output.outcome }} actual: ${{ steps.large-output.outcome }}
- name: Assert exit code is expected - name: Assert exit code is expected
uses: nick-invision/assert-action@v1 uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.large-output.outputs.exit_code }} actual: ${{ steps.large-output.outputs.exit_code }}
@@ -211,11 +211,11 @@ jobs:
retry_on_exit_code: 2 retry_on_exit_code: 2
max_attempts: 3 max_attempts: 3
command: node -e "process.exit(2)" command: node -e "process.exit(2)"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.retry_on_exit_code_expected.outcome }} actual: ${{ steps.retry_on_exit_code_expected.outcome }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 3 expected: 3
actual: ${{ steps.retry_on_exit_code_expected.outputs.total_attempts }} actual: ${{ steps.retry_on_exit_code_expected.outputs.total_attempts }}
@@ -229,11 +229,11 @@ jobs:
retry_on_exit_code: 2 retry_on_exit_code: 2
max_attempts: 3 max_attempts: 3
command: node -e "process.exit(1)" command: node -e "process.exit(1)"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.retry_on_exit_code_unexpected.outcome }} actual: ${{ steps.retry_on_exit_code_unexpected.outcome }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 1 expected: 1
actual: ${{ steps.retry_on_exit_code_unexpected.outputs.total_attempts }} actual: ${{ steps.retry_on_exit_code_unexpected.outputs.total_attempts }}
@@ -265,22 +265,22 @@ jobs:
timeout_minutes: 1 timeout_minutes: 1
continue_on_error: true continue_on_error: true
- name: Verify continue_on_error returns correct exit code on success - name: Verify continue_on_error returns correct exit code on success
uses: nick-invision/assert-action@v1 uses: nick-fields/assert-action@v2
with: with:
expected: 0 expected: 0
actual: ${{ steps.happy_path_continue_on_error.outputs.exit_code }} actual: ${{ steps.happy_path_continue_on_error.outputs.exit_code }}
- name: Verify continue_on_error exits with correct outcome on success - name: Verify continue_on_error exits with correct outcome on success
uses: nick-invision/assert-action@v1 uses: nick-fields/assert-action@v2
with: with:
expected: success expected: success
actual: ${{ steps.happy_path_continue_on_error.outcome }} actual: ${{ steps.happy_path_continue_on_error.outcome }}
- name: Verify continue_on_error returns correct exit code on error - name: Verify continue_on_error returns correct exit code on error
uses: nick-invision/assert-action@v1 uses: nick-fields/assert-action@v2
with: with:
expected: 33 expected: 33
actual: ${{ steps.sad_path_continue_on_error.outputs.exit_code }} actual: ${{ steps.sad_path_continue_on_error.outputs.exit_code }}
- name: Verify continue_on_error exits with successful outcome when an error occurs - name: Verify continue_on_error exits with successful outcome when an error occurs
uses: nick-invision/assert-action@v1 uses: nick-fields/assert-action@v2
with: with:
expected: success expected: success
actual: ${{ steps.sad_path_continue_on_error.outcome }} actual: ${{ steps.sad_path_continue_on_error.outcome }}
@@ -307,15 +307,15 @@ jobs:
max_attempts: 3 max_attempts: 3
retry_wait_seconds: 15 retry_wait_seconds: 15
command: npm install this-isnt-a-real-package-name-zzz command: npm install this-isnt-a-real-package-name-zzz
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 3 expected: 3
actual: ${{ steps.sad_path_wait_sec.outputs.total_attempts }} actual: ${{ steps.sad_path_wait_sec.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.sad_path_wait_sec.outcome }} actual: ${{ steps.sad_path_wait_sec.outcome }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 'Final attempt failed' expected: 'Final attempt failed'
actual: ${{ steps.sad_path_wait_sec.outputs.exit_error }} actual: ${{ steps.sad_path_wait_sec.outputs.exit_error }}
@@ -385,11 +385,11 @@ jobs:
timeout_seconds: 15 timeout_seconds: 15
max_attempts: 2 max_attempts: 2
command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.sad_path_timeout.outputs.total_attempts }} actual: ${{ steps.sad_path_timeout.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.sad_path_timeout.outcome }} actual: ${{ steps.sad_path_timeout.outcome }}
@@ -416,11 +416,11 @@ jobs:
max_attempts: 2 max_attempts: 2
retry_on: timeout retry_on: timeout
command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.retry_on_timeout.outputs.total_attempts }} actual: ${{ steps.retry_on_timeout.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.retry_on_timeout.outcome }} actual: ${{ steps.retry_on_timeout.outcome }}
@@ -447,15 +447,15 @@ jobs:
max_attempts: 2 max_attempts: 2
retry_on: error retry_on: error
command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 1 expected: 1
actual: ${{ steps.retry_on_error_fail.outputs.total_attempts }} actual: ${{ steps.retry_on_error_fail.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.retry_on_error_fail.outcome }} actual: ${{ steps.retry_on_error_fail.outcome }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 1 expected: 1
actual: ${{ steps.retry_on_error_fail.outputs.exit_code }} actual: ${{ steps.retry_on_error_fail.outputs.exit_code }}
@@ -481,11 +481,11 @@ jobs:
timeout_minutes: 1 timeout_minutes: 1
max_attempts: 2 max_attempts: 2
command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()"
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: 2 expected: 2
actual: ${{ steps.sad_path_timeout_minutes.outputs.total_attempts }} actual: ${{ steps.sad_path_timeout_minutes.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1 - uses: nick-fields/assert-action@v2
with: with:
expected: failure expected: failure
actual: ${{ steps.sad_path_timeout_minutes.outcome }} actual: ${{ steps.sad_path_timeout_minutes.outcome }}
@@ -584,6 +584,8 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag - name: Tag
# only bump v# (e.g., v3) tag if semantic release action publishes any new version
if: ${{ steps.semantic.outputs.new_release_major_version != '' }}
run: git tag -f v${MAJOR_VERSION} && git push -f origin v${MAJOR_VERSION} run: git tag -f v${MAJOR_VERSION} && git push -f origin v${MAJOR_VERSION}
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

14
dist/index.js vendored
View File

@@ -25040,17 +25040,18 @@ function runAction(inputs) {
attempt = 1; attempt = 1;
_a.label = 2; _a.label = 2;
case 2: case 2:
if (!(attempt <= inputs.max_attempts)) return [3 /*break*/, 13]; if (!(attempt <= inputs.max_attempts)) return [3 /*break*/, 14];
(0, core_1.info)("::group::Attempt ".concat(attempt));
_a.label = 3; _a.label = 3;
case 3: case 3:
_a.trys.push([3, 5, , 12]); _a.trys.push([3, 5, 12, 13]);
// just keep overwriting attempts output // just keep overwriting attempts output
(0, core_1.setOutput)(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt); (0, core_1.setOutput)(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt);
return [4 /*yield*/, runCmd(attempt, inputs)]; return [4 /*yield*/, runCmd(attempt, inputs)];
case 4: case 4:
_a.sent(); _a.sent();
(0, core_1.info)("Command completed after ".concat(attempt, " attempt(s).")); (0, core_1.info)("Command completed after ".concat(attempt, " attempt(s)."));
return [3 /*break*/, 13]; return [3 /*break*/, 14];
case 5: case 5:
error_2 = _a.sent(); error_2 = _a.sent();
if (!(attempt === inputs.max_attempts)) return [3 /*break*/, 6]; if (!(attempt === inputs.max_attempts)) return [3 /*break*/, 6];
@@ -25076,11 +25077,14 @@ function runAction(inputs) {
(0, core_1.info)("Attempt ".concat(attempt, " failed. Reason: ").concat(error_2.message)); (0, core_1.info)("Attempt ".concat(attempt, " failed. Reason: ").concat(error_2.message));
} }
_a.label = 11; _a.label = 11;
case 11: return [3 /*break*/, 12]; case 11: return [3 /*break*/, 13];
case 12: case 12:
(0, core_1.info)("::endgroup::");
return [7 /*endfinally*/];
case 13:
attempt++; attempt++;
return [3 /*break*/, 2]; return [3 /*break*/, 2];
case 13: return [2 /*return*/]; case 14: return [2 /*return*/];
} }
}); });
}); });

5283
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -13,15 +13,15 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/nick-invision/retry.git" "url": "git+https://github.com/nick-fields/retry.git"
}, },
"keywords": [], "keywords": [],
"author": "Nick Fields", "author": "Nick Fields",
"license": "ISC", "license": "ISC",
"bugs": { "bugs": {
"url": "https://github.com/nick-invision/retry/issues" "url": "https://github.com/nick-fields/retry/issues"
}, },
"homepage": "https://github.com/nick-invision/retry#readme", "homepage": "https://github.com/nick-fields/retry#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",
"milliseconds": "^1.0.3", "milliseconds": "^1.0.3",
@@ -30,7 +30,7 @@
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^16.2.3", "@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1", "@commitlint/config-conventional": "^16.2.1",
"@semantic-release/changelog": "^6.0.1", "@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1", "@semantic-release/git": "^10.0.1",
"@types/jest": "^28.1.6", "@types/jest": "^28.1.6",
"@types/milliseconds": "0.0.30", "@types/milliseconds": "0.0.30",
@@ -45,7 +45,7 @@
"jest": "^28.1.3", "jest": "^28.1.3",
"lint-staged": "^13.0.3", "lint-staged": "^13.0.3",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"semantic-release": "19.0.3", "semantic-release": "^24.2.3",
"ts-jest": "^28.0.7", "ts-jest": "^28.0.7",
"ts-node": "9.0.0", "ts-node": "9.0.0",
"typescript": "^4.7.4", "typescript": "^4.7.4",

View File

@@ -130,6 +130,7 @@ async function runAction(inputs: Inputs) {
await validateInputs(inputs); await validateInputs(inputs);
for (let attempt = 1; attempt <= inputs.max_attempts; attempt++) { for (let attempt = 1; attempt <= inputs.max_attempts; attempt++) {
info(`::group::Attempt ${attempt}`);
try { try {
// just keep overwriting attempts output // just keep overwriting attempts output
setOutput(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt); setOutput(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt);
@@ -156,6 +157,8 @@ async function runAction(inputs: Inputs) {
info(`Attempt ${attempt} failed. Reason: ${error.message}`); info(`Attempt ${attempt} failed. Reason: ${error.message}`);
} }
} }
} finally {
info(`::endgroup::`);
} }
} }
} }