Skip to content

Commit cc67e60

Browse files
authored
Merge pull request #2 from exec-astraea/ci/test-workflow
ci: run build, vet, and tests on main pushes and PRs
2 parents fc20e61 + b366f20 commit cc67e60

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
# Allow manual runs from the Actions tab.
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
# Track the version in go.mod so this never drifts from the module.
24+
go-version-file: go.mod
25+
26+
- name: Check formatting
27+
# gofmt -l lists misformatted files and exits 0 either way, so fail
28+
# explicitly when the list is non-empty.
29+
run: |
30+
unformatted=$(gofmt -l .)
31+
if [ -n "$unformatted" ]; then
32+
echo "These files need gofmt:"
33+
echo "$unformatted"
34+
exit 1
35+
fi
36+
37+
- name: Build
38+
run: go build ./...
39+
40+
- name: Vet
41+
run: go vet ./...
42+
43+
- name: Test
44+
run: go test -race ./...

AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ This is a flat `package main`, one concern per file:
4545
| `util.go` | Tiny shared helpers. |
4646
| `discord_test.go` | Unit test for `buildContent` (placeholder/plural expansion). |
4747

48+
CI lives in `.github/workflows/` — see [CI](#ci).
49+
4850
## Build / run / verify
4951

5052
All commands run from this directory.
@@ -68,6 +70,20 @@ only the immediate `runOnStart` check fires) and `markExistingOnFirstRun: false`
6870
After a `go build .` here, delete the stray `hoyo-codes` binary it drops
6971
(already gitignored).
7072

73+
### CI
74+
75+
Two GitHub Actions workflows, both in `.github/workflows/`:
76+
77+
| Workflow | Runs on | Does |
78+
| -------------------- | ------------------------------------ | --------------------------------------- |
79+
| `test.yml` | pushes to `main`, **every** PR | gofmt gate, build, vet, `go test -race`. |
80+
| `docker-publish.yml` | pushes to `main`, `v*` tags | builds and pushes the image to ghcr.io. |
81+
82+
`test.yml` takes its Go version from `go.mod` (`go-version-file`), so bumping the
83+
module bumps CI too. The gofmt step fails the build on any misformatted file —
84+
`gofmt -l` alone always exits 0, so it checks for non-empty output explicitly.
85+
Run the same gate locally before pushing (the one-liner above).
86+
7187
## Configuration reference
7288

7389
All config lives in `config.yaml` (gitignored — it holds webhook URLs). See

0 commit comments

Comments
 (0)