chore(deps): bump actions/checkout from 5 to 6 #532
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test | |
| on: [push] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| test: | |
| name: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v6 | |
| - name: setup go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: test | |
| run: go test -timeout=10s -race -count=10 -shuffle=on -failfast -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... | |
| - name: check test coverage | |
| id: coverage | |
| uses: vladopajic/go-test-coverage@v2 | |
| continue-on-error: true # Should fail after coverage comment is posted | |
| with: | |
| config: ./.testcoverage.yml | |
| git-branch: badges | |
| git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }} | |
| - name: find pull request ID | |
| run: | | |
| PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}&state=open") | |
| PR_ID=$(echo "$PR_DATA" | jq -r '.[0].number') | |
| if [ "$PR_ID" != "null" ]; then | |
| echo "pull_request_id=$PR_ID" >> $GITHUB_ENV | |
| else | |
| echo "No open pull request found for this branch." | |
| fi | |
| - name: post coverage report | |
| if: env.pull_request_id | |
| uses: thollander/actions-comment-pull-request@v3 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| comment-tag: coverage-report | |
| pr-number: ${{ env.pull_request_id }} | |
| message: | | |
| go-test-coverage report: | |
| ``` | |
| ${{ fromJSON(steps.coverage.outputs.report) }}``` | |
| - name: "finally check coverage" | |
| if: steps.coverage.outcome == 'failure' | |
| shell: bash | |
| run: echo "coverage check failed" && exit 1 |