Skip to content

Commit

Permalink
tip.cuelang.org: apply the stored patch
Browse files Browse the repository at this point in the history
This adds a step near the end of CI that unconditionally checks that the
patch stored at internal/patch/tip.diff still applies to the repo
successfully. CI performs this check by actually applying the patch via
_scripts/tipPatchApply.bash - any use of this script leaves the repo in
a modified/dirty state.

The patch contains changes that make the site compatible with the tip of
cue-lang/cue's default branch.

A follow-up CL will:

1. add a CI step that runs whenever the default branch of this repo is
   updated and:
   - forces the site to use the tip of cue-lang/cue
   - invokes ./_scripts/regenPostInfraChange.bash
   - checks that the site builds successfully

Later changes might also:

2. publish the site (e.g. to the as-yet-unestablished tip.cuelang.org)
   after (1) succeeds
3. replicate (1) and (2) any time the default branch of cue-lang/cue is
   updated;
4. push the working trees generated by (1) and/or (3) to a long-running
   CL, so that the delta is visible/downloadable/etc.

Signed-off-by: Paul Jolly <[email protected]>
Change-Id: I8fe2461cd4caa24d12fda7361b5205ae5c871640
Dispatch-Trailer: {"type":"trybot","CL":1200804,"patchset":8,"ref":"refs/changes/04/1200804/8","targetBranch":"master"}
  • Loading branch information
myitcv authored and cueckoo committed Sep 10, 2024
1 parent 16c1eb3 commit 58ff1af
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/trybot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,5 @@ jobs:
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_INDEX_KEY }}
ALGOLIA_INDEX_NAME: cuelang.org
ALGOLIA_INDEX_FILE: ../_public/algolia.json
- name: 'tip.cuelang.org: Apply tip''s patch, checking that it applies cleanly'
run: _scripts/tipPatchApply.bash
24 changes: 24 additions & 0 deletions _scripts/tipPatchApply.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail

# Usage:
# tipPatchApply.bash
#
# tipPatchApply applies the patch stored at $patchPath to the current git
# working tree and index. This patch is intended to make the cuelang.org site
# compatible with the tip version of cue-lang/cue.

# cd to the parent directory to that containing the script
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.."

patchPath=$(./_scripts/tipPatchPath.bash)

# We must be in a clean state first
if test ! -z "$(git status --porcelain)"
then
echo "working tree is not porcelain"
exit 1
fi

# --index: working tree and index must be identical.
git apply --index $patchPath
18 changes: 18 additions & 0 deletions _scripts/tipPatchGenerate.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

# Usage:
# tipPatchGenerate.bash
#
# tipPatchGenerate takes the current state of the working tree and stores its
# diff against HEAD at $patchPath. This is intended to ease the ongoing,
# repeated generation of the patch that makes the repo compatible with the tip
# of cue-lang/cue.

# cd to the parent directory to that containing the script
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.."

patchPath="$(./_scripts/tipPatchPath.bash)"

# ":^x" excludes changes to "x" from the diff.
git diff HEAD -- . ":^$patchPath" >"$patchPath"
10 changes: 10 additions & 0 deletions _scripts/tipPatchPath.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

# Usage:
# tipPatchPath.bash
#
# tipPatchPath prints the path of the patch file that makes the repo compatible
# with the tip of cue-lang/cue, relative to the repo root.

echo "internal/patch/tip.diff"
5 changes: 5 additions & 0 deletions internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ workflows: trybot: _repo.bashWorkflow & {
ALGOLIA_INDEX_FILE: "../_public/algolia.json"
}
},

json.#step & {
name: "tip.cuelang.org: Apply tip's patch, checking that it applies cleanly"
run: "_scripts/tipPatchApply.bash"
},
]
}

Expand Down
13 changes: 13 additions & 0 deletions internal/patch/tip.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/playground/_scripts/revendorToolsInternal.bash b/playground/_scripts/revendorToolsInternal.bash
index 771d24ec..ea3def82 100755
--- a/playground/_scripts/revendorToolsInternal.bash
+++ b/playground/_scripts/revendorToolsInternal.bash
@@ -29,7 +29,7 @@ popd > /dev/null

# TODO this is very fragile - we need to move away from this to a proper
# dependency-based approach to minimal copy
-for i in "" filetypes encoding third_party/yaml encoding/yaml astinternal cueexperiment envflag source
+for i in "" filetypes encoding encoding/yaml astinternal cueexperiment envflag source
do
rsync -a --relative --delete $td/$path@$version/internal/./$i/ ./internal/cuelang_org_go_internal/
find ./internal/cuelang_org_go_internal/$i -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +

0 comments on commit 58ff1af

Please sign in to comment.