| 1 |
name: GHA Build |
| 2 |
# The `name:` here is also used in badge.svg rendering as the left-hand-side |
| 3 |
|
| 4 |
permissions: |
| 5 |
# Control the GITHUB_TOKEN permissions. |
| 6 |
# By having this block, all permissions not listed here are set to none. |
| 7 |
# Available permissions listed at: |
| 8 |
# <https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token> |
| 9 |
# Which API calls need which permissions at what level, listed at: |
| 10 |
# <https://docs.github.com/en/rest/reference/permissions-required-for-github-apps> |
| 11 |
# |
| 12 |
contents: read |
| 13 |
checks: write |
| 14 |
statuses: write |
| 15 |
|
| 16 |
on: |
| 17 |
push: |
| 18 |
branches-ignore: |
| 19 |
- 'exp' |
| 20 |
- 'exp/*' |
| 21 |
- 'exp-*' |
| 22 |
- 'exp_*' |
| 23 |
- 'wip' |
| 24 |
- 'wip/*' |
| 25 |
- 'wip-*' |
| 26 |
- 'wip_*' |
| 27 |
pull_request: |
| 28 |
|
| 29 |
jobs: |
| 30 |
test: |
| 31 |
runs-on: ${{ matrix.os }} |
| 32 |
continue-on-error: ${{ matrix.experimental || false }} |
| 33 |
strategy: |
| 34 |
matrix: |
| 35 |
include: |
| 36 |
- go: stable |
| 37 |
os: ubuntu-latest |
| 38 |
canonical: true |
| 39 |
|
| 40 |
steps: |
| 41 |
- name: Checkout |
| 42 |
uses: actions/checkout@v4 |
| 43 |
|
| 44 |
- name: Set up Go |
| 45 |
uses: actions/setup-go@v6 |
| 46 |
with: |
| 47 |
go-version-file: "go.mod" |
| 48 |
# We're not doing releases, just checks, so we can live without check-latest here |
| 49 |
|
| 50 |
- name: Export Go environment to Actions outputs |
| 51 |
id: go-settings |
| 52 |
run: | |
| 53 |
echo >> "$GITHUB_OUTPUT" "arch=$(go env GOARCH)" |
| 54 |
echo >> "$GITHUB_OUTPUT" "hostarch=$(go env GOHOSTARCH)" |
| 55 |
echo >> "$GITHUB_OUTPUT" "os=$(go env GOOS)" |
| 56 |
echo >> "$GITHUB_OUTPUT" "hostos=$(go env GOHOSTOS)" |
| 57 |
echo >> "$GITHUB_OUTPUT" "go-version=$(go env GOVERSION)" |
| 58 |
# Use with: |
| 59 |
# ${{ steps.go-settings.outputs.go-version }} |
| 60 |
# which will look like `go1.17.1` if matrix `1.17.x` matches `1.17.1`. |
| 61 |
# These are independent of how the matrix is setup, or if a matrix is even used. |
| 62 |
# |
| 63 |
# You can see the individual values in the "Set up Go" output, collapsed inside a "go env" group at the end. |
| 64 |
|
| 65 |
- name: Install staticcheck |
| 66 |
uses: dominikh/[email protected] |
| 67 |
with: |
| 68 |
version: "latest" |
| 69 |
install-go: false |
| 70 |
|
| 71 |
- name: Install additional check/lint tools |
| 72 |
id: tools-install |
| 73 |
run: | |
| 74 |
go install github.com/mattn/goveralls@latest |
| 75 |
go install github.com/client9/misspell/cmd/misspell@latest |
| 76 |
|
| 77 |
- name: Basic Go integrity checks |
| 78 |
id: integrity |
| 79 |
run: | |
| 80 |
$(exit $(go fmt ./... | wc -l)) |
| 81 |
go get -t ./... |
| 82 |
go vet ./... |
| 83 |
misspell -error -locale US . |
| 84 |
misspell -error -locale US ./nk |
| 85 |
staticcheck ./... |
| 86 |
out="$(go list -m -retracted -f '{{if .Retracted}}{{.Path}} is retracted{{end}}' all)" |
| 87 |
if [ -n "$out" ]; then |
| 88 |
printf '%s\n' "$out" |
| 89 |
exit 1 |
| 90 |
fi |
| 91 |
env: |
| 92 |
GOFLAGS: "-mod=mod" |
| 93 |
|
| 94 |
- name: Run Basic Tests |
| 95 |
id: tests |
| 96 |
run: | |
| 97 |
go test -v -vet=off --race --failfast |
| 98 |
|
| 99 |
- name: Run Coverage Tests |
| 100 |
id: coverage |
| 101 |
run: | |
| 102 |
go test -v -covermode=count -coverprofile=coverage.out |
| 103 |
|
| 104 |
- name: Upload coverage results |
| 105 |
id: coverage-upload |
| 106 |
run: | |
| 107 |
goveralls -coverprofile=coverage.out -service=github |
| 108 |
env: |
| 109 |
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 110 |
if: matrix.canonical |
| 111 |
|
| 112 |
#EOF |