Skip to content

Commit 00a3e5b

Browse files
authored
Merge pull request #89 from CryptoLabInc/yg/ci-go-test-job
ci: add Go test job (skips when go.mod absent)
2 parents a0164df + 4765a9e commit 00a3e5b

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/pr-tests.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,46 @@ jobs:
9595
- name: Fail if tests failed
9696
if: always() && steps.pytest.outputs.exit_code != '0'
9797
run: exit 1
98+
99+
run-go-tests:
100+
name: Run Go tests
101+
runs-on: [self-hosted, rune-ci]
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
# Skip silently when go.mod is absent (Python-only branches before the
106+
# Go migration lands on main). Subsequent steps gate on this output.
107+
- name: Detect Go project
108+
id: detect_go
109+
run: |
110+
if [ -f go.mod ]; then
111+
echo "has_go=true" >> "$GITHUB_OUTPUT"
112+
else
113+
echo "has_go=false" >> "$GITHUB_OUTPUT"
114+
echo "::notice::No go.mod found — skipping Go tests"
115+
fi
116+
117+
- uses: actions/setup-go@v5
118+
if: steps.detect_go.outputs.has_go == 'true'
119+
with:
120+
go-version-file: 'go.mod'
121+
cache: true
122+
123+
- name: gofmt
124+
if: steps.detect_go.outputs.has_go == 'true'
125+
run: |
126+
unformatted=$(gofmt -l -e .)
127+
if [ -n "$unformatted" ]; then
128+
echo "::error::gofmt found unformatted files:"
129+
echo "$unformatted"
130+
gofmt -d -e .
131+
exit 1
132+
fi
133+
134+
- name: go vet
135+
if: steps.detect_go.outputs.has_go == 'true'
136+
run: go vet ./...
137+
138+
- name: go test -race
139+
if: steps.detect_go.outputs.has_go == 'true'
140+
run: go test -race -count=1 ./...

0 commit comments

Comments
 (0)