Skip to content

Commit fdefc33

Browse files
committed
gh action
1 parent 11169b5 commit fdefc33

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

.github/workflows/pr-checks.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
workflow_call:
7+
inputs:
8+
go-version:
9+
description: "Version of golang to install"
10+
default: "1.23.0"
11+
type: string
12+
task-version:
13+
description: "Version of task to install (https://taskfile.dev)"
14+
default: "3.29.1"
15+
type: string
16+
17+
jobs:
18+
lint:
19+
name: Lint
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Setup go-task
24+
uses: pnorton5432/setup-task@v1
25+
with:
26+
task-version: ${{ inputs.task-version }}
27+
- uses: actions/setup-go@v5
28+
with:
29+
go-version: ${{ inputs.go-version }}
30+
cache: false
31+
- name: Install nilaway
32+
run: go install go.uber.org/nilaway/cmd/nilaway@latest
33+
- name: Run golangci-lint
34+
uses: golangci/golangci-lint-action@v3
35+
with:
36+
version: v1.64.5
37+
args: --timeout=5m
38+
- name: Run other linters
39+
run: |
40+
task lint-nilaway
41+
task lint-md
42+
task lint-vuln
43+
44+
test:
45+
name: Test
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Setup go-task
50+
uses: pnorton5432/setup-task@v1
51+
with:
52+
task-version: ${{ inputs.task-version }}
53+
- uses: actions/setup-go@v5
54+
with:
55+
go-version: ${{ inputs.go-version }}
56+
cache: false
57+
- name: Run tests with coverage
58+
run: task test-coverage
59+
- name: Upload coverage as artifact
60+
uses: actions/upload-artifact@v3
61+
with:
62+
name: coverage-report
63+
path: coverage.out
64+
- name: Check coverage threshold
65+
run: |
66+
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')
67+
if (( $(echo "$COVERAGE < 70" | bc -l) )); then
68+
echo "Test coverage is below 70%: $COVERAGE%"
69+
echo "Consider adding more tests to improve coverage"
70+
fi
71+
72+
build:
73+
name: Build
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
- name: Setup go-task
78+
uses: pnorton5432/setup-task@v1
79+
with:
80+
task-version: ${{ inputs.task-version }}
81+
- uses: actions/setup-go@v5
82+
with:
83+
go-version: ${{ inputs.go-version }}
84+
cache: false
85+
- name: Build binary
86+
run: task build
87+
- name: Check goreleaser config
88+
run: |
89+
go install github.com/goreleaser/goreleaser@latest
90+
goreleaser check

0 commit comments

Comments
 (0)