-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (155 loc) · 4.95 KB
/
ci.yaml
File metadata and controls
183 lines (155 loc) · 4.95 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: ci
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
permissions:
contents: read
pull-requests: read
# Cancel in-progress runs for pull requests when developers push
# additional changes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
lint-go:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Install go tools
run: |
go install golang.org/x/tools/cmd/goimports@v0.31.0
# Run only basic format checks
- name: Go linting
run: |
# Format check
goimports -l .
go fmt ./...
lint-ts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Node
uses: ./.github/actions/setup-node
- name: Run JS linting
working-directory: site
run: pnpm lint
# Skip TS type checking as it might require additional setup
# - name: Check TS types
# working-directory: site
# run: pnpm check-types
test-go-core:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Run core Go tests
id: test
shell: bash
run: |
export TS_DEBUG_DISCO=true
# Test core packages that don't have complex environment dependencies
packages=(
"./cryptorand/..."
"./buildinfo/..."
"./apiversion/..."
"./archive/..."
"./testutil/..."
"./provisionersdk/..."
)
go test ${packages[@]} -short -failfast
test-go-utils:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Run utility Go tests
id: test
shell: bash
run: |
export TS_DEBUG_DISCO=true
# Test utility packages that don't have complex environment dependencies
go test ./tailnet -run "TestService|TestConn|TestDERPMap" -short -failfast
test-js-basic:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Node
uses: ./.github/actions/setup-node
- name: Run JS unit tests
working-directory: site
run: |
# Run only utility tests that are less likely to be flaky
pnpm jest --selectProjects test --testPathPattern "src/utils|src/hooks|src/api" --testTimeout=30000
build-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Setup Node
uses: ./.github/actions/setup-node
- name: Verify all packages compile
run: |
# Verify Go packages compile
go build -o /dev/null ./cmd/coder
# Skip TypeScript verification as it might require additional setup
# cd site
# pnpm build-api
# pnpm check-types
required:
runs-on: ubuntu-latest
needs:
- lint-go
- lint-ts
- test-go-core
- test-go-utils
- test-js-basic
- build-checks
# Allow this job to run even if the needed jobs fail, are skipped or
# cancelled.
if: always()
steps:
- name: Ensure required checks
run: |
echo "Checking required checks"
echo "- lint-go: ${{ needs.lint-go.result }}"
echo "- lint-ts: ${{ needs.lint-ts.result }}"
echo "- test-go-core: ${{ needs.test-go-core.result }}"
echo "- test-go-utils: ${{ needs.test-go-utils.result }}"
echo "- test-js-basic: ${{ needs.test-js-basic.result }}"
echo "- build-checks: ${{ needs.build-checks.result }}"
echo
# We allow skipped jobs to pass, but not failed or cancelled jobs.
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One of the required checks has failed or has been cancelled"
exit 1
fi
echo "Required checks have passed"