| 1 |
|
| 2 |
|
| 3 |
name: TryBot |
| 4 |
"on": |
| 5 |
push: |
| 6 |
branches: |
| 7 |
- ci/test |
| 8 |
- main |
| 9 |
pull_request: {} |
| 10 |
workflow_dispatch: {} |
| 11 |
jobs: |
| 12 |
test: |
| 13 |
runs-on: ubuntu-22.04 |
| 14 |
defaults: |
| 15 |
run: |
| 16 |
shell: bash |
| 17 |
if: |- |
| 18 |
(contains(github.event.head_commit.message, ' |
| 19 |
Dispatch-Trailer: {"type":"trybot"')) || ! (contains(github.event.head_commit.message, ' |
| 20 |
Dispatch-Trailer: {"type":"')) |
| 21 |
steps: |
| 22 |
- name: Checkout code |
| 23 |
uses: actions/checkout@v4 |
| 24 |
with: |
| 25 |
ref: ${{ github.event.pull_request.head.sha }} |
| 26 |
fetch-depth: 0 |
| 27 |
- name: Reset git directory modification times |
| 28 |
run: touch -t 202211302355 $(find * -type d) |
| 29 |
- name: Restore git file modification times |
| 30 |
uses: chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe |
| 31 |
- id: DispatchTrailer |
| 32 |
name: Try to extract Dispatch-Trailer |
| 33 |
run: |- |
| 34 |
x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')" |
| 35 |
if [[ "$x" == "" ]] |
| 36 |
then |
| 37 |
# Some steps rely on the presence or otherwise of the Dispatch-Trailer. |
| 38 |
# We know that we don't have a Dispatch-Trailer in this situation, |
| 39 |
# hence we use the JSON value null in order to represent that state. |
| 40 |
# This means that GitHub expressions can determine whether a Dispatch-Trailer |
| 41 |
# is present or not by checking whether the fromJSON() result of the |
| 42 |
# output from this step is the JSON value null or not. |
| 43 |
x=null |
| 44 |
fi |
| 45 |
echo "value<<EOD" >> $GITHUB_OUTPUT |
| 46 |
echo "$x" >> $GITHUB_OUTPUT |
| 47 |
echo "EOD" >> $GITHUB_OUTPUT |
| 48 |
- if: |- |
| 49 |
((github.ref == 'refs/heads/main') && (! (contains(github.event.head_commit.message, ' |
| 50 |
Dispatch-Trailer: {"type":"')))) && (contains(github.event.head_commit.message, ' |
| 51 |
Dispatch-Trailer: {"type":"')) |
| 52 |
name: Check we don't have Dispatch-Trailer on a protected branch |
| 53 |
run: |- |
| 54 |
echo "github.event.head_commit.message contains Dispatch-Trailer but we are on a protected branch" |
| 55 |
false |
| 56 |
- name: Install Go |
| 57 |
uses: actions/setup-go@v5 |
| 58 |
with: |
| 59 |
cache: false |
| 60 |
go-version: 1.22.x |
| 61 |
- name: Set common go env vars |
| 62 |
run: |- |
| 63 |
go env -w GOTOOLCHAIN=local |
| 64 |
|
| 65 |
# Dump env for good measure |
| 66 |
go env |
| 67 |
- id: go-mod-cache-dir |
| 68 |
name: Get go mod cache directory |
| 69 |
run: echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT} |
| 70 |
- id: go-cache-dir |
| 71 |
name: Get go build/test cache directory |
| 72 |
run: echo "dir=$(go env GOCACHE)" >> ${GITHUB_OUTPUT} |
| 73 |
- if: |- |
| 74 |
(((github.ref == 'refs/heads/main') && (! (contains(github.event.head_commit.message, ' |
| 75 |
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) |
| 76 |
uses: actions/cache@v4 |
| 77 |
with: |
| 78 |
path: |- |
| 79 |
${{ steps.go-mod-cache-dir.outputs.dir }}/cache/download |
| 80 |
${{ steps.go-cache-dir.outputs.dir }} |
| 81 |
key: ${{ runner.os }}-1.22.x-${{ github.run_id }} |
| 82 |
restore-keys: ${{ runner.os }}-1.22.x |
| 83 |
- if: |- |
| 84 |
! (((github.ref == 'refs/heads/main') && (! (contains(github.event.head_commit.message, ' |
| 85 |
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) |
| 86 |
uses: actions/cache/restore@v4 |
| 87 |
with: |
| 88 |
path: |- |
| 89 |
${{ steps.go-mod-cache-dir.outputs.dir }}/cache/download |
| 90 |
${{ steps.go-cache-dir.outputs.dir }} |
| 91 |
key: ${{ runner.os }}-1.22.x-${{ github.run_id }} |
| 92 |
restore-keys: ${{ runner.os }}-1.22.x |
| 93 |
- if: |- |
| 94 |
github.repository == 'cue-labs/oci' && (((github.ref == 'refs/heads/main') && (! (contains(github.event.head_commit.message, ' |
| 95 |
Dispatch-Trailer: {"type":"')))) || github.ref == 'refs/heads/ci/test') |
| 96 |
run: go clean -testcache |
| 97 |
- name: Early git and code sanity checks |
| 98 |
run: go run cuelang.org/go/internal/ci/[email protected] |
| 99 |
- name: Generate cmd/ocisrv |
| 100 |
run: go generate ./... |
| 101 |
working-directory: cmd/ocisrv |
| 102 |
env: |
| 103 |
GOWORK: "" |
| 104 |
- name: Test cmd/ocisrv |
| 105 |
run: go test ./... |
| 106 |
working-directory: cmd/ocisrv |
| 107 |
env: |
| 108 |
GOWORK: "" |
| 109 |
- name: Check cmd/ocisrv |
| 110 |
run: go vet ./... |
| 111 |
working-directory: cmd/ocisrv |
| 112 |
env: |
| 113 |
GOWORK: "" |
| 114 |
- name: Generate cmd/ocisrv with GOWORK=off |
| 115 |
run: go generate ./... |
| 116 |
working-directory: cmd/ocisrv |
| 117 |
env: |
| 118 |
GOWORK: "off" |
| 119 |
- name: Test cmd/ocisrv with GOWORK=off |
| 120 |
run: go test ./... |
| 121 |
working-directory: cmd/ocisrv |
| 122 |
env: |
| 123 |
GOWORK: "off" |
| 124 |
- name: Check cmd/ocisrv with GOWORK=off |
| 125 |
run: go vet ./... |
| 126 |
working-directory: cmd/ocisrv |
| 127 |
env: |
| 128 |
GOWORK: "off" |
| 129 |
- name: Generate ociregistry/internal/conformance |
| 130 |
run: go generate ./... |
| 131 |
working-directory: ociregistry/internal/conformance |
| 132 |
env: |
| 133 |
GOWORK: "" |
| 134 |
- name: Test ociregistry/internal/conformance |
| 135 |
run: go test ./... |
| 136 |
working-directory: ociregistry/internal/conformance |
| 137 |
env: |
| 138 |
GOWORK: "" |
| 139 |
- name: Check ociregistry/internal/conformance |
| 140 |
run: go vet ./... |
| 141 |
working-directory: ociregistry/internal/conformance |
| 142 |
env: |
| 143 |
GOWORK: "" |
| 144 |
- name: Generate ociregistry/internal/conformance with GOWORK=off |
| 145 |
run: go generate ./... |
| 146 |
working-directory: ociregistry/internal/conformance |
| 147 |
env: |
| 148 |
GOWORK: "off" |
| 149 |
- name: Test ociregistry/internal/conformance with GOWORK=off |
| 150 |
run: go test ./... |
| 151 |
working-directory: ociregistry/internal/conformance |
| 152 |
env: |
| 153 |
GOWORK: "off" |
| 154 |
- name: Check ociregistry/internal/conformance with GOWORK=off |
| 155 |
run: go vet ./... |
| 156 |
working-directory: ociregistry/internal/conformance |
| 157 |
env: |
| 158 |
GOWORK: "off" |
| 159 |
- name: Generate ociregistry |
| 160 |
run: go generate ./... |
| 161 |
working-directory: ociregistry |
| 162 |
env: |
| 163 |
GOWORK: "" |
| 164 |
- name: Test ociregistry |
| 165 |
run: go test ./... |
| 166 |
working-directory: ociregistry |
| 167 |
env: |
| 168 |
GOWORK: "" |
| 169 |
- name: Check ociregistry |
| 170 |
run: go vet ./... |
| 171 |
working-directory: ociregistry |
| 172 |
env: |
| 173 |
GOWORK: "" |
| 174 |
- name: Generate ociregistry with GOWORK=off |
| 175 |
run: go generate ./... |
| 176 |
working-directory: ociregistry |
| 177 |
env: |
| 178 |
GOWORK: "off" |
| 179 |
- name: Test ociregistry with GOWORK=off |
| 180 |
run: go test ./... |
| 181 |
working-directory: ociregistry |
| 182 |
env: |
| 183 |
GOWORK: "off" |
| 184 |
- name: Check ociregistry with GOWORK=off |
| 185 |
run: go vet ./... |
| 186 |
working-directory: ociregistry |
| 187 |
env: |
| 188 |
GOWORK: "off" |
| 189 |
- name: Generate internal/ci |
| 190 |
run: go generate ./... |
| 191 |
working-directory: internal/ci |
| 192 |
env: |
| 193 |
GOWORK: "" |
| 194 |
- name: Test internal/ci |
| 195 |
run: go test ./... |
| 196 |
working-directory: internal/ci |
| 197 |
env: |
| 198 |
GOWORK: "" |
| 199 |
- name: Check internal/ci |
| 200 |
run: go vet ./... |
| 201 |
working-directory: internal/ci |
| 202 |
env: |
| 203 |
GOWORK: "" |
| 204 |
- name: Generate internal/ci with GOWORK=off |
| 205 |
run: go generate ./... |
| 206 |
working-directory: internal/ci |
| 207 |
env: |
| 208 |
GOWORK: "off" |
| 209 |
- name: Test internal/ci with GOWORK=off |
| 210 |
run: go test ./... |
| 211 |
working-directory: internal/ci |
| 212 |
env: |
| 213 |
GOWORK: "off" |
| 214 |
- name: Check internal/ci with GOWORK=off |
| 215 |
run: go vet ./... |
| 216 |
working-directory: internal/ci |
| 217 |
env: |
| 218 |
GOWORK: "off" |
| 219 |
- run: go work sync |
| 220 |
- if: always() |
| 221 |
name: Check that git is clean at the end of the job |
| 222 |
run: test -z "$(git status --porcelain)" || (git status; git diff; false) |