Skip to content

Commit

Permalink
tip.cuelang.org: test if site builds successfully
Browse files Browse the repository at this point in the history
This adds a pair of steps to the end of CI which only run on the repo's
default branch (or its pre-submission testing counterpart) in the
primary (non-trybot) repo; i.e. after a CL has been submitted.

The first step overrides the site's CUE version to be the tip of
cue-lang/cue. The second step builds the site to check that the patch
we're maintaining to make the site compatible with the CUE tip still
does its job and allows the site build to succeed.

Later changes will publish the site/source to Netlify/Gerrit, to
increase our visibility of any changes. For now, this change just
asserts that the site builds successfully.

Change-Id: I51f6f7fbada47d6a250ff3ecfb11c212d78b9a70
Signed-off-by: Jonathan Matthews <[email protected]>
Dispatch-Trailer: {"type":"trybot","CL":1200891,"patchset":5,"ref":"refs/changes/91/1200891/5","targetBranch":"master"}
  • Loading branch information
jpluscplusm authored and cueckoo committed Sep 10, 2024
1 parent a6a6d58 commit a336089
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/trybot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 44 additions & 0 deletions _scripts/tipUseAlternativeCUE.bash
Original file line number Diff line number Diff line change
@@ -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: - <<EOD >tip.cue
_version: _ @tag(version)
versions: cue: [string]: v: _version
EOD
18 changes: 18 additions & 0 deletions internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
]
}

Expand Down

0 comments on commit a336089

Please sign in to comment.