Skip to content

Commit

Permalink
ci(status): add status check for tests (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg authored Nov 20, 2023
1 parent a05b517 commit 75582a1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/test-ci-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
PR_head_ref: ${{ fromJSON(steps.comment-branch.outputs.result).ref }}
PR_num: ${{ fromJSON(steps.comment-branch.outputs.result).num }}
PR_repo: ${{ fromJSON(steps.comment-branch.outputs.result).repo }}
PR_head_sha: ${{ fromJSON(steps.comment-branch.outputs.result).head_sha }}
steps:
- uses: actions/github-script@v6
id: comment-branch
Expand All @@ -64,7 +65,7 @@ jobs:
repo: context.repo.repo,
pull_number: context.issue.number
})
return { repo: result.data.head.repo.full_name, num: result.data.number, ref: result.data.head.ref }
return { repo: result.data.head.repo.full_name, num: result.data.number, ref: result.data.head.ref, head_sha: result.data.head.sha }
get-test-image-tag:
runs-on: ubuntu-latest
Expand All @@ -87,8 +88,10 @@ jobs:
uses: ./.github/workflows/test-ci-reusable.yml
needs: [get-test-image-tag, checkout-branch]
permissions:
statuses: write
packages: write
with:
repository: ${{ needs.checkout-branch.outputs.PR_repo }}
ref: ${{ needs.checkout-branch.outputs.PR_head_ref }}
tag: ${{ needs.get-test-image-tag.outputs.tag }}
sha: ${{ needs.checkout-branch.outputs.PR_head_sha }}
11 changes: 11 additions & 0 deletions .github/workflows/test-ci-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ on:
- cryostat-v[0-9]+.[0-9]+

jobs:
check-before-test:
runs-on: ubuntu-latest
steps:
- name: Fail if needs-triage label applied
if: ${{ contains(github.event.pull_request.labels.*.name, 'needs-triage') }}
run: exit 1

get-test-image-tag:
runs-on: ubuntu-latest
outputs:
Expand All @@ -30,5 +37,9 @@ jobs:
run-test-jobs:
uses: ./.github/workflows/test-ci-reusable.yml
needs: [get-test-image-tag]
permissions:
packages: write
statuses: write
with:
tag: ${{ needs.get-test-image-tag.outputs.tag }}
sha: ${{ needs.checkout-branch.outputs.PR_head_sha }}
23 changes: 23 additions & 0 deletions .github/workflows/test-ci-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ on:
ref:
required: false
type: string
sha:
required: true
type: string

env:
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key"
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04"

permissions:
statuses: write
packages: write

jobs:
clean-up-test-images:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,6 +51,14 @@ jobs:
go-version: '1.20.*'
- name: Run controller tests
run: make test-envtest
- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
sha: ${{ inputs.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: ${{ github.job }}

scorecard-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -127,3 +142,11 @@ jobs:
make test-scorecard
- name: Clean up Kind cluster
run: kind delete cluster -n ci-${{ github.run_id }}
- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
sha: ${{ inputs.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: ${{ github.job }}

0 comments on commit 75582a1

Please sign in to comment.