-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (120 loc) · 3.6 KB
/
ci.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: GoLang AIO CI
on:
pull_request:
push:
branches:
- main
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Dependencies
uses: ./.github/actions/setup-deps
- name: Format Node
working-directory: ./web
run: yarn format
- name: Format Go
run: |
gofmt_output=$(gofmt -s -d .)
if [ -n "$gofmt_output" ]; then
echo "Code formatting issues found:"
echo "$gofmt_output"
exit 1
fi
lint:
runs-on: ubuntu-latest
needs: format
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Dependencies
uses: ./.github/actions/setup-deps
- name: Lint Node
working-directory: ./web
run: yarn lint
- name: Analyze Go
run: go vet ./...
- name: Lint Go
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6
with:
version: latest
skip-pkg-cache: true
test:
runs-on: ubuntu-latest
needs: format
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Dependencies
uses: ./.github/actions/setup-deps
with:
setup-node: false
- name: Test Go
run: go test -v ./...
build-binary:
runs-on: ubuntu-latest
needs: [test, lint]
strategy:
fail-fast: false
matrix:
os: [darwin, linux, windows]
arch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Dependencies
uses: ./.github/actions/setup-deps
- name: Build Node
working-directory: ./web
run: yarn export
- name: Build Go
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: |
go build -o ./bin/golang-aio .
sha256sum ./bin/golang-aio > ./bin/golang-aio-checksum
- name: Upload Artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
with:
name: golang-aio-${{ matrix.os }}-${{ matrix.arch }}
path: |
./bin/golang-aio
./bin/golang-aio-checksum
if-no-files-found: error
build-docker:
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Docker
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3
- name: Build Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
with:
context: .
tags: golang-aio:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
fan-in:
runs-on: ubuntu-latest
needs: [format, lint, test, build-binary, build-docker]
if: always()
steps:
- name: Check Jobs
shell: bash
env:
JOBS: ${{ toJSON(needs) }}
run: |
echo "Job status:"
echo $JOBS | jq -r 'to_entries[] | " - \(.key): \(.value.result)"'
for i in $(echo $JOBS | jq -r 'to_entries[] | .value.result'); do
if [ "$i" != "success" ] && [ "$i" != "skipped" ]; then
echo ""
echo "Status check not okay!"
exit 1
fi
done