Fixing CodeQL errors #81
Workflow file for this run
This file contains 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: GO Tests | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.19 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download Dependencies | |
run: go mod download | |
- name: Install ginkgo | |
run: go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@latest | |
- name: Run Unit Tests | |
run: | | |
ginkgo -r --randomize-all --randomize-suites --fail-on-pending --cover --trace --v --coverprofile=coverage.out ./... | |
- name: Upload Coverage Report to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage.out | |
flag: unittests | |
- name: Generate Coverage Comment | |
id: generate-comment | |
run: | | |
COVERAGE_PERCENT=$(go tool cover -func=coverage.out | grep total | awk '{print $NF}') | |
COMMENT_MESSAGE="Code coverage: $COVERAGE_PERCENT" | |
echo "::set-output name=comment::$COMMENT_MESSAGE" | |
- name: Comment on Pull Request | |
run: | | |
COMMENT_BODY="${{ steps.generate-comment.outputs.comment }}" | |
curl \ | |
-X POST \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"body\":\"$COMMENT_BODY\"}" \ | |
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" |