forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (62 loc) · 1.81 KB
/
go.yml
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
71
72
73
74
75
76
77
name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'
- name: Check vendored dependencies
run: |
go mod tidy
go mod verify
go mod vendor -v
git status
if [[ -n "$(git status --porcelain vendor)" ]]; then
echo 'vendor/ is out-of-date: run `go mod tidy && go mod vendor` and then check in the changes'
echo 'If `go mod tidy && go mod vendor` results in no changes, make sure you are using the latest relase of Go'
git status --porcelain vendor
exit 1
fi
- name: gofmt
run: test -z "$(gofmt -s -l $(find -name '*.go' | grep -v /vendor/))"
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'
- name: Build
run: go build -mod=mod -v ./...
- name: Vet Test
run: go vet -composites=false -mod=mod ./...
- name: Test
run: "CGO_ENABLED=0 go env && CGO_ENABLED=0 go test -mod=mod ./pkg/uroot/..."
badbuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'
- name: Build fail
id: buildfail
continue-on-error: true
run: |
echo bad >> cmds/core/date/date.go
go build .
./u-root
- name: Fail if Build Failure did not fail
run: |
echo buildfail got ${{ steps.buildfail.outcome }} and should get failure
bash -c "if [[ ${{ steps.buildfail.outcome }} == failure ]]; then exit 0; else exit 1; fi"