diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a9de41..41db9f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,11 +8,54 @@ on: - master name: Run tests jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + + - name: Get StaticCheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Gomod + run: | + go mod tidy + if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then + echo "go.sum was added by go mod tidy" + exit 1 + fi + git diff --exit-code -- go.sum go.mod + + - name: Gofmt + if: ${{ success() || failure() }} # run this step even if the previous one failed + run: | + out=$(gofmt -s -l .) + if [[ -n "$out" ]]; then + echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}' + exit 1 + fi + + - name: Vet + if: ${{ success() || failure() }} # run this step even if the previous one failed + run: go vet ./... + + - name: StaticCheck + if: ${{ success() || failure() }} # run this step even if the previous one failed + run: staticcheck ./... + test: strategy: matrix: os: ["ubuntu", "windows", "macos"] runs-on: ${{ matrix.os }}-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 2cf0e5a..49fcf47 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -7,7 +7,7 @@ on: - completed jobs: - build: + version: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: