Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use GitHub Action nick-invision/retry #57

Closed
wants to merge 19 commits into from
24 changes: 0 additions & 24 deletions .github/workflows/rerun.yml

This file was deleted.

47 changes: 10 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ on:
branches:
- main
paths-ignore:
- '**.md'
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'
- '**.md'

env:
TIME-OUT-TEST-NUM: 2
RETRY-TEST-NUM: 10

jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 5
runs-on: ubuntu-22.04
container: osrf/ros:humble-desktop-full
steps:
- uses: actions/checkout@v2
Expand All @@ -45,44 +45,17 @@ jobs:
- name: Exec
run: |
source /root/ros2_ws/install/setup.bash
ros2 run emcl2 test.bash
timeout 240 ros2 run emcl2 test.bash
shell: bash

retry:
runs-on: ubuntu-22.04
needs: test
if: ${{ always() && needs.test.result == 'failure' }}
steps:
- uses: actions/github-script@v6
- name: Retry failed jobs
uses: hourki-actions/retry-workflow-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
async function run() {
const { owner, repo } = context.repo;
const workflow_id = 'rerun.yml';
const ref = ('${{ github.head_ref }}' === '' || '${{ github.head_ref }}' === 'main') ? 'main' : '${{ github.head_ref }}';
const run_id = context.runId;

try {
const workflow_run = await github.rest.actions.getWorkflowRun({
owner,
repo,
run_id
});

if (workflow_run.data.run_attempt < ${{ env.RETRY-TEST-NUM }}) {
console.log('Triggering workflow dispatch...');
await github.rest.actions.createWorkflowDispatch({
owner,
repo,
workflow_id,
ref
});
} else {
console.log('Conditions not met for re-dispatch.');
}
} catch (error) {
console.error('Failed to fetch workflow run or dispatch:', error);
}
}
run();
token: ${{ secrets.GITHUB_TOKEN }}
workflow_run_id: ${{ github.run_id }}
max_retries: ${{ env.RETRY-TEST-NUM }}
Loading