45 lines
1.0 KiB
YAML
45 lines
1.0 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- main
|
|
|
|
jobs:
|
|
lint-test:
|
|
name: Lint and test
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: golang:1.24-bookworm
|
|
steps:
|
|
- name: Checkout
|
|
env:
|
|
TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -eu
|
|
git init .
|
|
if [ -n "${TOKEN:-}" ]; then
|
|
server="${GITHUB_SERVER_URL#https://}"
|
|
server="${server#http://}"
|
|
git remote add origin "https://x-access-token:${TOKEN}@${server}/${GITHUB_REPOSITORY}.git"
|
|
else
|
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
fi
|
|
git fetch --depth=1 origin "${GITHUB_SHA}"
|
|
git checkout --detach FETCH_HEAD
|
|
|
|
- name: Check formatting
|
|
run: |
|
|
files="$(gofmt -l .)"
|
|
if [ -n "$files" ]; then
|
|
echo "The following files need gofmt:"
|
|
echo "$files"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Test
|
|
run: go test ./...
|