Skip to content

Merge pull request #11 from voltgizerz/felix_refactor_gql #27

Merge pull request #11 from voltgizerz/felix_refactor_gql

Merge pull request #11 from voltgizerz/felix_refactor_gql #27

Workflow file for this run

name: Code Checker
on:
pull_request:
branches:
- master
- develop
push:
branches:
- master
- develop
paths:
- 'revive.toml'
- '.github/workflows/revive-lint.yml'
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/server.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 shall be above threshold
env:
TESTCOVERAGE_THRESHOLD: 1
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]+'`
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "OK"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Failed"
exit 1
fi
- name: πŸ‘¨β€πŸŽ€ Run Revive Action
uses: docker://morphy/revive-action:v2
with:
config: revive.toml
continue-on-error: true
- name: πŸ‘¨β€πŸŽ€ Check formatting
run: gofmt -l .