Modernize the project setup (#82) #446
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: Static Analysis | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
jobs: | |
static_analysis: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: WillAbides/[email protected] | |
with: | |
go-version: '1.21.x' | |
- name: Get dependencies | |
run: >- | |
sudo apt-get update && | |
sudo apt-get install | |
gcc | |
libegl1-mesa-dev | |
libgl1-mesa-dev | |
libgles2-mesa-dev | |
libx11-dev | |
xorg-dev | |
xvfb | |
- name: Install analysis tools | |
run: | | |
go install golang.org/x/tools/cmd/goimports@latest | |
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest | |
go install honnef.co/go/tools/cmd/[email protected] | |
go install github.com/mattn/goveralls@latest | |
- name: Vet | |
run: go vet ./... | |
- name: Goimports | |
run: test -z "$(goimports -e -d . | tee /dev/stderr)" | |
- name: Gocyclo | |
run: gocyclo -over 30 . | |
- name: Staticcheck | |
run: staticcheck ./... | |
- name: Update coverage | |
run: | | |
set -e | |
xvfb-run go test -covermode=atomic -coverprofile=coverage.out ./... | |
coverage=`go tool cover -func coverage.out | grep total | tr -s '\t' | cut -f 3 | grep -o '[^%]*'` | |
if (( $(echo "$coverage < 48" | bc) )); then echo "Test coverage lowered"; exit 1; fi | |
- name: Update PR Coverage | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: coverage.out |