-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (195 loc) · 6.89 KB
/
trybot.yaml
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Code generated internal/ci/ci_tool.cue; DO NOT EDIT.
name: TryBot
"on":
push:
tags:
- v*
branches:
- ci/test
- master
workflow_dispatch: {}
pull_request: {}
jobs:
test:
runs-on: ubuntu-22.04
if: |-
(contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"trybot"')) || ! (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"'))
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Reset git directory modification times
run: |-
set -o nounset
touch -t 202211302355 $(find * -type d)
- name: Restore git file modification times
uses: chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe
- id: DispatchTrailer
name: Try to extract Dispatch-Trailer
run: |-
set -o nounset
x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')"
if [[ "$x" == "" ]]
then
# Some steps rely on the presence or otherwise of the Dispatch-Trailer.
# We know that we don't have a Dispatch-Trailer in this situation,
# hence we use the JSON value null in order to represent that state.
# This means that GitHub expressions can determine whether a Dispatch-Trailer
# is present or not by checking whether the fromJSON() result of the
# output from this step is the JSON value null or not.
x=null
fi
echo "value<<EOD" >> $GITHUB_OUTPUT
echo "$x" >> $GITHUB_OUTPUT
echo "EOD" >> $GITHUB_OUTPUT
- if: |-
((github.ref == 'refs/heads/master') && (! (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"')))) && (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"'))
name: Check we don't have Dispatch-Trailer on a protected branch
run: |-
set -o nounset
echo "github.event.head_commit.message contains Dispatch-Trailer but we are on a protected branch"
false
- name: Install Go
uses: actions/setup-go@v5
with:
cache: false
go-version: 1.23.3
- name: Set common go env vars
run: |-
set -o nounset
go env -w GOTOOLCHAIN=local
# Dump env for good measure
go env
- id: go-mod-cache-dir
name: Get go mod cache directory
run: |-
set -o nounset
echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT}
- id: go-cache-dir
name: Get go build/test cache directory
run: |-
set -o nounset
echo "dir=$(go env GOCACHE)" >> ${GITHUB_OUTPUT}
- if: |-
(((github.ref == 'refs/heads/master') && (! (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test'))
uses: actions/cache@v4
with:
path: |-
${{ steps.go-mod-cache-dir.outputs.dir }}/cache/download
${{ steps.go-cache-dir.outputs.dir }}
~/.npm
key: ${{ runner.os }}-1.23.3-${{ github.run_id }}
restore-keys: ${{ runner.os }}-1.23.3
- if: |-
! (((github.ref == 'refs/heads/master') && (! (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test'))
uses: actions/cache/restore@v4
with:
path: |-
${{ steps.go-mod-cache-dir.outputs.dir }}/cache/download
${{ steps.go-cache-dir.outputs.dir }}
~/.npm
key: ${{ runner.os }}-1.23.3-${{ github.run_id }}
restore-keys: ${{ runner.os }}-1.23.3
- if: |-
github.repository == 'cue-lang/vscode-cue' && (((github.ref == 'refs/heads/master') && (! (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"')))) || github.ref == 'refs/heads/ci/test')
run: |-
set -o nounset
go clean -testcache
- name: Install CUE
uses: cue-lang/[email protected]
with:
version: v0.11.0
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 22.11.0
- name: Early git and code sanity checks
run: |-
set -o nounset
go run cuelang.org/go/internal/ci/[email protected]
- run: |-
set -o nounset
cue login --token=${CUE_TOKEN}
env:
CUE_TOKEN: ${{ secrets.NOTCUECKOO_CUE_TOKEN }}
- name: Add node_modules/.bin to PATH and npm install
run: |-
set -o nounset
echo "PATH=$PWD/node_modules/.bin:$PATH" >> $GITHUB_ENV
npm install
- working-directory: extension
name: Add node_modules/.bin to PATH and npm install
run: |-
set -o nounset
echo "PATH=$PWD/node_modules/.bin:$PATH" >> $GITHUB_ENV
npm install
- name: Verify
run: |-
set -o nounset
go mod verify
- name: Generate
run: |-
set -o nounset
go generate ./...
- name: Test
run: |-
set -o nounset
go test ./...
- name: Race test
run: |-
set -o nounset
go test -race ./...
- name: staticcheck
run: |-
set -o nounset
go run honnef.co/go/tools/cmd/[email protected] ./...
- name: Tidy
run: |-
set -o nounset
go mod tidy
- working-directory: extension
name: Format
run: |-
set -o nounset
npm run format
- working-directory: extension
name: Compile
run: |-
set -o nounset
npm run compile
- working-directory: extension
name: Extension publish dry-run
run: |-
set -o nounset
npm run package
- if: always()
name: Check that git is clean at the end of the job
run: |-
set -o nounset
test -z "$(git status --porcelain)" || (git status; git diff; false)
- working-directory: extension
if: github.repository == 'cue-lang/vscode-cue' && (startsWith(github.ref, 'refs/tags/v'))
name: Check version match
run: |-
set -o nounset
cue cmd -t tag=${GITHUB_REF##refs/tags/} checkReleaseVersion
- working-directory: extension
if: github.repository == 'cue-lang/vscode-cue' && (startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/ci/test'))
name: Release package
env:
VSCODE_PAT: ${{ secrets.CUECKOO_VSCODE_PAT }}
run: |-
set -o nounset
npm run publish -- -p $VSCODE_PAT