diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..471dc6c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: CI + +# Ported from .gitlab-ci.yml (lint + test) as part of the GitLab -> GitHub +# migration (STAC-25142). Public Go library, no secrets/registry needed, so it +# runs on GitHub-hosted runners with actions/setup-go (Go version from go.mod). + +on: + pull_request: + push: + branches: [master] + +permissions: + contents: read + +jobs: + lint: + name: Lint (gofmt + revive) + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Set up Go + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 + with: + go-version-file: go.mod + + - name: Check gofmt + run: | + unformatted="$(gofmt -l .)" + if [ -n "$unformatted" ]; then + echo "The following files are not gofmt-formatted:" + echo "$unformatted" + exit 1 + fi + + - name: revive + run: go run github.com/mgechev/revive@v1.15.0 -formatter stylish -config revive-recommended.toml ./... + + test: + name: Test (go test) + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Set up Go + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 + with: + go-version-file: go.mod + + - name: go test + run: go test -v ./...