54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: golang
|
|
container:
|
|
image: golang:1.26
|
|
env:
|
|
GOPRIVATE: forgejo.riotpiao.com
|
|
GOFLAGS: -mod=readonly
|
|
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
|
|
steps:
|
|
- name: install node (required by JS-based actions)
|
|
run: apt-get update && apt-get install -y --no-install-recommends nodejs ca-certificates git
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: configure git auth for private module fetch
|
|
run: |
|
|
git config --global url."https://oauth2:${REGISTRY_PAT}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
|
|
|
|
- name: cache go modules + build cache
|
|
# uses: actions/cache@v4
|
|
# with:
|
|
# path: |
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
# key: # go-${{ runner.os }}-${{ hashFiles('go.sum') }}
|
|
# restore-keys: |
|
|
# go-${{ runner.os }}-
|
|
|
|
- name: gofmt
|
|
run: |
|
|
fmt_out="$(gofmt -l ./cmd ./internal)"
|
|
if [ -n "$fmt_out" ]; then
|
|
echo "$fmt_out"
|
|
echo "::error::gofmt found unformatted files, run 'gofmt -w ./cmd ./internal'"
|
|
exit 1
|
|
fi
|
|
|
|
- name: go vet
|
|
run: go vet ./cmd/... ./internal/...
|
|
|
|
- name: go build
|
|
run: go build ./cmd/kmsvc
|
|
|
|
- name: go test
|
|
run: go test ./cmd/... ./internal/... -race
|