-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (61 loc) · 1.86 KB
/
cli.yml
File metadata and controls
70 lines (61 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: CLI
on:
pull_request:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.github/workflows/cli.yml'
push:
branches:
- master
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.github/workflows/cli.yml'
jobs:
check:
name: Check
runs-on: warp-ubuntu-latest-x64-4x
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version-file: go.mod
cache: true
- name: Check formatting
run: |
# Check if gofmt would make changes
if [ -n "$(gofmt -l .)" ]; then
echo "::error::Code is not formatted. Run 'gofmt -w .' to fix."
gofmt -d .
exit 1
fi
- name: Check import formatting
run: |
go install golang.org/x/tools/cmd/goimports@latest
# Check if goimports would make changes
if [ -n "$(goimports -l -local github.com/jmgilman/headjack .)" ]; then
echo "::error::Imports are not formatted. Run 'goimports -w -local github.com/jmgilman/headjack .' to fix."
goimports -d -local github.com/jmgilman/headjack .
exit 1
fi
- name: Run linter
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
with:
version: latest
- name: Run tests
run: go test -race -coverprofile=coverage.out ./...
- name: Upload coverage report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-report
path: coverage.out
retention-days: 7