Logs #30
Workflow file for this run
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: CI | |
| on: | |
| pull_request: | |
| branches: [master] | |
| push: | |
| branches: [master] | |
| tags: | |
| - 'v*.*.*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libzmq3-dev libczmq-dev libsodium-dev pkg-config | |
| - name: Build | |
| run: make build | |
| - name: Run tests with coverage | |
| run: | | |
| go test -v -coverprofile=coverage.out -covermode=atomic ./... | |
| go tool cover -func=coverage.out | |
| - name: Update coverage badge in README | |
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
| run: | | |
| COVERAGE=$(go tool cover -func=coverage.out | grep '^total:' | awk '{print $NF}' | tr -d '%') | |
| if (( $(echo "$COVERAGE >= 80" | bc -l) )); then | |
| COLOR="brightgreen" | |
| elif (( $(echo "$COVERAGE >= 60" | bc -l) )); then | |
| COLOR="yellow" | |
| elif (( $(echo "$COVERAGE >= 40" | bc -l) )); then | |
| COLOR="orange" | |
| else | |
| COLOR="red" | |
| fi | |
| BADGE="" | |
| if grep -q '!\[Coverage\]' README.md; then | |
| sed -i "s|!\[Coverage\](.*)|${BADGE}|" README.md | |
| else | |
| sed -i "1 a\\\\n${BADGE}" README.md | |
| fi | |
| - name: Commit updated README | |
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git diff --quiet README.md || (git add README.md && git commit -m "ci: update test coverage badge" && git push) |