diff --git a/.github/workflows/trybot.yaml b/.github/workflows/trybot.yaml index a8fe3b5b6..5fab75d43 100644 --- a/.github/workflows/trybot.yaml +++ b/.github/workflows/trybot.yaml @@ -234,3 +234,11 @@ jobs: ALGOLIA_INDEX_FILE: ../_public/algolia.json - name: 'tip.cuelang.org: Apply tip''s patch, checking that it applies cleanly' run: _scripts/tipPatchApply.bash + - if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test')) + name: 'tip.cuelang.org: Resolve the tip version of cue-lang/cue and configure the site to use it' + run: _scripts/tipUseAlternativeCUE.bash + env: + GOPROXY: direct + - if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test')) + name: 'tip.cuelang.org: Check if the site builds against the tip of cue-lang/cue' + run: _scripts/regenPostInfraChange.bash diff --git a/_scripts/tipUseAlternativeCUE.bash b/_scripts/tipUseAlternativeCUE.bash new file mode 100755 index 000000000..2f9167669 --- /dev/null +++ b/_scripts/tipUseAlternativeCUE.bash @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Usage: +# tipUseAlternativeCUE.bash [CUE_COMMIT_REF] +# +# tipUseAlternativeCUE resolves the version of CUE available via +# cuelang.org/go@$CUE_COMMIT_REF and overrides the site configuration so that +# this version takes the place of all named CUEs (currently only "latest" and +# "prerelease" are directly overridden, with their versions transitively +# dictating those used by "tip", "default", and "playground"). CUE_COMMIT_REF +# defaults to "master", so that invoking the script with no arguments will use +# the tip of cue-lang/cue. + +versionRef=${1:-master} + +# cd to the parent directory to that containing the script +cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.." + +# Resolve $versionRef to a pseudo-version. Notice this intentionally honours +# GOPROXY rather that setting a specific value in the script, allowing the +# setting to be controlled by this script's invocation. +td=$(mktemp -d) +trap "rm -rf $td" EXIT +pushd $td > /dev/null +go mod init mod.example &> /dev/null +go get cuelang.org/go@$versionRef &> /dev/null +version=$(go list -m -f={{.Version}} cuelang.org/go) +popd > /dev/null + +echo "Will use cuelang.org/go@$version" + +# Override all versions of CUE referenced by the site to be $version. +# This might change if any entries are added to the version matrix that +# deliberately make a previous version of CUE available but, for now, we don't +# need that - and could easily make it configurable later. +go run cuelang.org/go/cmd/cue def \ + -t version="$version" \ + -p site \ + --out cue \ + cue: - <tip.cue +_version: _ @tag(version) +versions: cue: [string]: v: _version +EOD diff --git a/internal/ci/github/trybot.cue b/internal/ci/github/trybot.cue index bd937c773..a106b54c4 100644 --- a/internal/ci/github/trybot.cue +++ b/internal/ci/github/trybot.cue @@ -253,6 +253,24 @@ workflows: trybot: _repo.bashWorkflow & { name: "tip.cuelang.org: Apply tip's patch, checking that it applies cleanly" run: "_scripts/tipPatchApply.bash" }, + + json.#step & { + name: "tip.cuelang.org: Resolve the tip version of cue-lang/cue and configure the site to use it" + // Only run in the main repo on the default branch or its designated test branch (i.e not CLs) + // so that CLs aren't blocked by failures caused by unrelated changes. + if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))" + // Force Go to bypass the module proxy, ensuring that the absolute + // latest CUE pseudo-version is available to test against. + env: GOPROXY: "direct" + run: "_scripts/tipUseAlternativeCUE.bash" + }, + json.#step & { + name: "tip.cuelang.org: Check if the site builds against the tip of cue-lang/cue" + // Only run in the main repo on the default branch or its designated test branch (i.e not CLs) + // so that CLs aren't blocked by failures caused by unrelated changes. + if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))" + run: "_scripts/regenPostInfraChange.bash" + }, ] }