This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
forked from cue-lang/cue
-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (143 loc) · 5.8 KB
/
test.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
# Generated by internal/ci/ci_tool.cue; do not edit
name: Test
"on":
push:
branches:
- '**'
tags-ignore:
- v*
pull_request: {}
jobs:
start:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- if: ${{ startsWith(github.ref, 'refs/heads/ci/') }}
name: Write netrc file for cueckoo Gerrithub
run: |-
cat <<EOD > ~/.netrc
machine review.gerrithub.io
login cueckoo
password ${{ secrets.CUECKOO_GERRITHUB_PASSWORD }}
EOD
chmod 600 ~/.netrc
- if: ${{ startsWith(github.ref, 'refs/heads/ci/') }}
name: Update Gerrit CL message with starting message
run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data "{\"tag\":\"trybot\",\"message\":\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\"}" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review'
test:
needs: start
strategy:
fail-fast: false
matrix:
go-version:
- 1.17.x
- 1.18.x
os:
- ubuntu-20.04
- macos-11
- windows-2022
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Write netrc file for cueckoo Gerrithub
run: |-
cat <<EOD > ~/.netrc
machine review.gerrithub.io
login cueckoo
password ${{ secrets.CUECKOO_GERRITHUB_PASSWORD }}
EOD
chmod 600 ~/.netrc
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- if: matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04'
name: Early git and code sanity checks
run: |-
# Ensure the recent commit messages have Signed-off-by headers.
# TODO: Remove once this is enforced for admins too;
# see https://bugs.chromium.org/p/gerrit/issues/detail?id=15229
# TODO: Our --max-count here is just 1, because we've made mistakes very
# recently. Increase it to 5 or 10 soon, to also cover CL chains.
for commit in $(git rev-list --max-count=1 HEAD); do
if ! git rev-list --format=%B --max-count=1 $commit | grep -q '^Signed-off-by:'; then
echo -e "
Recent commit is lacking Signed-off-by:
"
git show --quiet $commit
exit 1
fi
done
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-${{ matrix.go-version }}-go-
- if: ${{ github.ref == 'refs/heads/master' }}
run: echo CUE_LONG=true >> $GITHUB_ENV
- if: matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04'
name: Generate
run: go generate ./...
- name: Test
run: go test ./...
- if: matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04'
name: Check
run: go vet ./...
- if: ${{ matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04' }}
name: Test with -race
run: go test -race ./...
- name: Check that git is clean post generate and tests
run: test -z "$(git status --porcelain)" || (git status; git diff; false)
- if: ${{ github.ref == 'refs/heads/master' }}
name: Pull this commit through the proxy on master
run: |-
v=$(git rev-parse HEAD)
cd $(mktemp -d)
go mod init mod.com
GOPROXY=https://proxy.golang.org go get -d cuelang.org/go/cmd/cue@$v
- if: ${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }}
name: Post any failures for this matrix entry
run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data "{\"tag\":\"trybot\",\"message\":\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\",\"labels\":{\"TryBot-Result\":-1}}" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review'
mark_ci_success:
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref, 'refs/heads/ci/') }}
needs: test
defaults:
run:
shell: bash
steps:
- name: Write netrc file for cueckoo Gerrithub
run: |-
cat <<EOD > ~/.netrc
machine review.gerrithub.io
login cueckoo
password ${{ secrets.CUECKOO_GERRITHUB_PASSWORD }}
EOD
chmod 600 ~/.netrc
- name: Update Gerrit CL message with success message
run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data "{\"tag\":\"trybot\",\"message\":\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\",\"labels\":{\"TryBot-Result\":1}}" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review'
delete_build_branch:
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref, 'refs/heads/ci/') && always() }}
needs: test
defaults:
run:
shell: bash
steps:
- run: |-
mkdir tmpgit
cd tmpgit
git init
git config user.name cueckoo
git config user.email [email protected]
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:${{ secrets.CUECKOO_GITHUB_PAT }} | base64)"
git push https://github.com/cue-lang/cue :${GITHUB_REF#refs/heads/}