ociregistry: start using and benefitting from Go 1.22 #532
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code generated internal/ci/ci_tool.cue; DO NOT EDIT. | |
name: TryBot | |
"on": | |
push: | |
branches: | |
- ci/test | |
- main | |
pull_request: {} | |
workflow_dispatch: {} | |
jobs: | |
test: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
shell: bash | |
if: |- | |
(contains(github.event.head_commit.message, ' | |
Dispatch-Trailer: {"type":"trybot"')) || ! (contains(github.event.head_commit.message, ' | |
Dispatch-Trailer: {"type":"')) | |
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: 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: |- | |
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/main') && (! (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: |- | |
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.21.x | |
- id: go-mod-cache-dir | |
name: Get go mod cache directory | |
run: echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT} | |
- id: go-cache-dir | |
name: Get go build/test cache directory | |
run: echo "dir=$(go env GOCACHE)" >> ${GITHUB_OUTPUT} | |
- if: |- | |
(((github.ref == 'refs/heads/main') && (! (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 }} | |
key: ${{ runner.os }}-1.21.x-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-1.21.x | |
- if: |- | |
! (((github.ref == 'refs/heads/main') && (! (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 }} | |
key: ${{ runner.os }}-1.21.x-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-1.21.x | |
- if: |- | |
github.repository == 'cue-labs/oci' && (((github.ref == 'refs/heads/main') && (! (contains(github.event.head_commit.message, ' | |
Dispatch-Trailer: {"type":"')))) || github.ref == 'refs/heads/ci/test') | |
run: go clean -testcache | |
- name: Early git and code sanity checks | |
run: |- | |
# Ensure that commit messages have a blank second line. | |
# We know that a commit message must be longer than a single | |
# line because each commit must be signed-off. | |
if git log --format=%B -n 1 HEAD | sed -n '2{/^$/{q1}}'; then | |
echo "second line of commit message must be blank" | |
exit 1 | |
fi | |
# All authors, including co-authors, must have a signed-off trailer by email. | |
# Note that trailers are in the form "Name <email>", so grab the email with sed. | |
# For now, we require the sorted lists of author and signer emails to match. | |
# Note that this also fails if a commit isn't signed-off at all. | |
# | |
# In Gerrit we already enable a form of this via https://gerrit-review.googlesource.com/Documentation/project-configuration.html#require-signed-off-by, | |
# but it does not support co-authors nor can it be used when testing GitHub PRs. | |
commit_authors="$( | |
{ | |
git log -1 --pretty='%ae' | |
git log -1 --pretty='%(trailers:key=Co-authored-by,valueonly)' | sed -ne 's/.* <\(.*\)>/\1/p' | |
} | sort -u | |
)" | |
commit_signers="$( | |
{ | |
git log -1 --pretty='%(trailers:key=Signed-off-by,valueonly)' | sed -ne 's/.* <\(.*\)>/\1/p' | |
} | sort -u | |
)" | |
if [[ "${commit_authors}" != "${commit_signers}" ]]; then | |
echo "Error: commit author email addresses do not match signed-off-by trailers" | |
echo | |
echo "Authors:" | |
echo "${commit_authors}" | |
echo | |
echo "Signers:" | |
echo "${commit_signers}" | |
exit 1 | |
fi | |
- name: Generate cmd/ocisrv | |
run: go generate ./... | |
working-directory: cmd/ocisrv | |
env: | |
GOWORK: "" | |
- name: Test cmd/ocisrv | |
run: go test ./... | |
working-directory: cmd/ocisrv | |
env: | |
GOWORK: "" | |
- name: Check cmd/ocisrv | |
run: go vet ./... | |
working-directory: cmd/ocisrv | |
env: | |
GOWORK: "" | |
- name: Generate cmd/ocisrv with GOWORK=off | |
run: go generate ./... | |
working-directory: cmd/ocisrv | |
env: | |
GOWORK: "off" | |
- name: Test cmd/ocisrv with GOWORK=off | |
run: go test ./... | |
working-directory: cmd/ocisrv | |
env: | |
GOWORK: "off" | |
- name: Check cmd/ocisrv with GOWORK=off | |
run: go vet ./... | |
working-directory: cmd/ocisrv | |
env: | |
GOWORK: "off" | |
- name: Generate ociregistry/internal/conformance | |
run: go generate ./... | |
working-directory: ociregistry/internal/conformance | |
env: | |
GOWORK: "" | |
- name: Test ociregistry/internal/conformance | |
run: go test ./... | |
working-directory: ociregistry/internal/conformance | |
env: | |
GOWORK: "" | |
- name: Check ociregistry/internal/conformance | |
run: go vet ./... | |
working-directory: ociregistry/internal/conformance | |
env: | |
GOWORK: "" | |
- name: Generate ociregistry/internal/conformance with GOWORK=off | |
run: go generate ./... | |
working-directory: ociregistry/internal/conformance | |
env: | |
GOWORK: "off" | |
- name: Test ociregistry/internal/conformance with GOWORK=off | |
run: go test ./... | |
working-directory: ociregistry/internal/conformance | |
env: | |
GOWORK: "off" | |
- name: Check ociregistry/internal/conformance with GOWORK=off | |
run: go vet ./... | |
working-directory: ociregistry/internal/conformance | |
env: | |
GOWORK: "off" | |
- name: Generate ociregistry | |
run: go generate ./... | |
working-directory: ociregistry | |
env: | |
GOWORK: "" | |
- name: Test ociregistry | |
run: go test ./... | |
working-directory: ociregistry | |
env: | |
GOWORK: "" | |
- name: Check ociregistry | |
run: go vet ./... | |
working-directory: ociregistry | |
env: | |
GOWORK: "" | |
- name: Generate ociregistry with GOWORK=off | |
run: go generate ./... | |
working-directory: ociregistry | |
env: | |
GOWORK: "off" | |
- name: Test ociregistry with GOWORK=off | |
run: go test ./... | |
working-directory: ociregistry | |
env: | |
GOWORK: "off" | |
- name: Check ociregistry with GOWORK=off | |
run: go vet ./... | |
working-directory: ociregistry | |
env: | |
GOWORK: "off" | |
- name: Generate internal/ci | |
run: go generate ./... | |
working-directory: internal/ci | |
env: | |
GOWORK: "" | |
- name: Test internal/ci | |
run: go test ./... | |
working-directory: internal/ci | |
env: | |
GOWORK: "" | |
- name: Check internal/ci | |
run: go vet ./... | |
working-directory: internal/ci | |
env: | |
GOWORK: "" | |
- name: Generate internal/ci with GOWORK=off | |
run: go generate ./... | |
working-directory: internal/ci | |
env: | |
GOWORK: "off" | |
- name: Test internal/ci with GOWORK=off | |
run: go test ./... | |
working-directory: internal/ci | |
env: | |
GOWORK: "off" | |
- name: Check internal/ci with GOWORK=off | |
run: go vet ./... | |
working-directory: internal/ci | |
env: | |
GOWORK: "off" | |
- run: go work sync | |
- if: always() | |
name: Check that git is clean at the end of the job | |
run: test -z "$(git status --porcelain)" || (git status; git diff; false) |