Skip to content

Commit b8bada8

Browse files
authored
Merge pull request #1763 from sustainable-computing-io/debug-wkf
fix(ci): Split Mock ACPI workflow into multiple jobs
2 parents 6a76bc3 + e9e323e commit b8bada8

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

.github/workflows/mock_acpi.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ on: # yamllint disable-line rule:truthy
66
types: [created]
77

88
jobs:
9-
test-mock-acpi:
9+
initalize-workflow:
1010
if: github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
11-
name: Test Mock ACPI
11+
name: Initialize workflow
1212
runs-on: ubuntu-latest
13+
outputs:
14+
head_sha: ${{ steps.pr_branch.outputs.head_sha }}
1315
steps:
1416
# Since `issue_comment` event runs on the default branch,
1517
# we need to get the branch of the pull request
@@ -27,15 +29,22 @@ jobs:
2729
token: ${{ secrets.GITHUB_TOKEN }}
2830
status: pending
2931

32+
test-mock-acpi:
33+
if: github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
34+
name: Test Mock ACPI
35+
needs: initalize-workflow
36+
runs-on: self-hosted
37+
outputs:
38+
runner-name: ${{ runner.name }}
39+
steps:
3040
- name: Checkout code
31-
if: ${{ success() }}
3241
uses: actions/checkout@v4
3342
with:
34-
ref: ${{ steps.pr_branch.outputs.head_sha }}
43+
ref: ${{ needs.initalize-workflow.outputs.head_sha }}
3544

3645
- name: metal-runner-action
46+
# TODO: use the forked version of metal-runner-action inside sustainable-computing-io organization
3747
uses: vprashar2929/metal-runner-action@custom-action
38-
# uses: equinix-labs/[email protected]
3948
with:
4049
github_token: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
4150
metal_auth_token: ${{ secrets.EQUINIX_API_TOKEN }}
@@ -65,32 +74,38 @@ jobs:
6574
- name: Run playbook
6675
id: run-playbook
6776
if: ${{ success() }}
68-
continue-on-error: true # This is done to release equinix runners irrespective of failure
6977
run: |
7078
echo "Setting up the infra"
7179
cd ${GITHUB_WORKSPACE}/ansible
7280
ansible-playbook -vv -i inventory.yaml setup.yaml
7381
echo "Launching Mock ACPI compose and running validator"
7482
ansible-playbook -vv -i inventory.yaml mock_acpi_playbook.yaml -e "pr_number=${{ github.event.issue.number }}"
7583
84+
cleanup:
85+
if: ${{ always() }}
86+
name: Cleanup
87+
needs: [initalize-workflow, test-mock-acpi]
88+
runs-on: ubuntu-latest
89+
steps:
7690
- name: delete runner
91+
if: ${{ always() }}
7792
uses: rootfs/metal-delete-action@main
7893
with:
7994
authToken: ${{ secrets.EQUINIX_API_TOKEN }}
8095
projectID: ${{ secrets.EQUINIX_PROJECT_ID }}
81-
runnerName: ${{ runner.name }}
96+
runnerName: ${{ needs.test-mock-acpi.outputs.runner-name }}
8297

8398
# Marking the workflow as failed if the playbook fails
8499
- name: Mark workflow as failed if playbook failed
85-
if: ${{ steps.run-playbook.outcome == 'failure' }}
100+
if: ${{ needs.test-mock-acpi.result == 'failure' }}
86101
run: |
87102
echo "Playbook failed, marking workflow as failed"
88103
exit 1
89104
90105
- name: Set job status as ${{ job.status }}
91106
uses: myrotvorets/set-commit-status-action@master
92-
if: always()
107+
if: ${{ always() }}
93108
with:
94-
sha: ${{ steps.pr_branch.outputs.head_sha }}
109+
sha: ${{ needs.initalize-workflow.outputs.head_sha }}
95110
token: ${{ secrets.GITHUB_TOKEN }}
96111
status: ${{ job.status }}

0 commit comments

Comments
 (0)