Skip to content

Felix 11 Force revive action linter fix #73

Felix 11 Force revive action linter fix

Felix 11 Force revive action linter fix #73

Workflow file for this run

name: πŸ‘©πŸΌβ€πŸŒΎ Code Checker
on:
pull_request:
branches:
- master
- develop
push:
branches:
- master
- develop
paths:
- './config/linter/revive.toml'
env:
TESTCOVERAGE_THRESHOLD: 20
jobs:
lint:
name: Lint and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: πŸ”§ Print current working dir
run: |
ls -la $PWD
ls -la $GITHUB_WORKSPACE
- uses: actions/setup-go@v2
with:
go-version: '1.21.1'
- name: βš™οΈ Setup GO environment
run: |
go mod download
- name: πŸ‘· Build
run: go build ./cmd/main.go
- name: πŸ§ͺ Run Unit tests
run: |
sudo go test ./... -coverprofile coverage.out -covermode count
sudo go tool cover -func coverage.out
- name: πŸ”Ž Quality Gate - Test coverage
run: |
echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
# Set totalCoverage as an environment variable
echo "totalCoverage=$totalCoverage" >> $GITHUB_ENV
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "βœ… Test coverage is above the threshold. Great job!"
else
echo "❌ Current test coverage is below the threshold. Please add more unit tests or adjust the threshold to a lower value."
fi
- name: πŸ’¬ PR comment with reactions - Above Threshold
uses: thollander/actions-comment-pull-request@v2
if: ${{ github.event_name == 'pull_request' && env.totalCoverage >= env.TESTCOVERAGE_THRESHOLD }}
with:
message: |
βœ… Test coverage is above the threshold. Good job!
- **Coverage: ${{env.totalCoverage}}%, Threshold: ${{env.TESTCOVERAGE_THRESHOLD}}%**
reactions: rocket
- name: πŸ’¬ PR comment with reactions - Below Threshold
uses: thollander/actions-comment-pull-request@v2
if: ${{ github.event_name == 'pull_request' && env.totalCoverage < env.TESTCOVERAGE_THRESHOLD }}
with:
message: |
❌ Test coverage is below the threshold. Please add more unit tests.
- **Coverage: ${{env.totalCoverage}}%, Threshold: ${{env.TESTCOVERAGE_THRESHOLD}}%**
reactions: eyes
- name: 🚧 Gate Keeper - Test coverage
if: ${{ github.event_name == 'pull_request' && env.totalCoverage < env.TESTCOVERAGE_THRESHOLD }}
run: exit 1
- name: πŸ‘¨β€πŸŽ€ Run Revive Action
uses: docker://morphy/revive-action:v2
with:
config: ./config/linter/revive.toml
continue-on-error: false
- name: πŸ‘¨β€πŸŽ€ Check formatting
run: gofmt -l .