-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: complete migration to cue-lang/vscode-cue
* Updates the Go module path to the new GitHub home. This includes updating docs to drop mention of cue-sh * Update the README to include the history of the "homes" for this plugin * Create a CUE module as the basis for the CI configuration * Template the CI configuration from a minimally adapted version of cue-lang/cuelang.org This is based on a baseline of CI from cue-lang/cue@bb24c7ce. We also: * Make the go:generate directive for gen-syntax use a relative path (it doesn't need to be anything else). * Switch to go1.23.0 as the base Go version used by tooling for this repo. * Fix use of deprecated io/ioutil in gen-syntax (caught by a later version of staticcheck) Signed-off-by: Paul Jolly <[email protected]> Change-Id: I32cf7b76369fb821710a90a7c2736860eac883b5 Reviewed-on: https://review.gerrithub.io/c/cue-lang/vscode-cue/+/1200595 Reviewed-by: Chief Cueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
- Loading branch information
Showing
25 changed files
with
2,563 additions
and
40 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Code generated internal/ci/ci_tool.cue; DO NOT EDIT. | ||
|
||
name: Evict caches | ||
"on": | ||
schedule: | ||
- cron: 0 2 * * * | ||
jobs: | ||
test: | ||
if: ${{github.repository == 'cue-lang/vscode-cue'}} | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
shell: bash | ||
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/master') && (! (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: Delete caches | ||
run: |- | ||
set -x | ||
echo ${{ secrets.CUECKOO_GITHUB_PAT }} | gh auth login --with-token | ||
gh extension install actions/gh-actions-cache | ||
for i in https://github.com/cue-lang/vscode-cue https://github.com/cue-lang/vscode-cue-trybot | ||
do | ||
echo "Evicting caches for $i" | ||
cd $(mktemp -d) | ||
git init -b initialbranch | ||
git remote add origin $i | ||
for j in $(gh actions-cache list -L 100 | grep refs/ | awk '{print $1}') | ||
do | ||
gh actions-cache delete --confirm $j | ||
done | ||
done | ||
- name: Trigger workflow runs to repopulate caches | ||
run: |- | ||
# Prepare git for pushes to trybot repo. Note | ||
# because we have already checked out code we don't | ||
# need origin. Fetch origin default branch for later use | ||
git config user.name cueckoo | ||
git config user.email [email protected] | ||
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:${{ secrets.CUECKOO_GITHUB_PAT }} | base64)" | ||
git remote add trybot https://github.com/cue-lang/vscode-cue-trybot | ||
# Now trigger the most recent workflow run on each of the default branches. | ||
# We do this by listing all the branches on the main repo and finding those | ||
# which match the protected branch patterns (globs). | ||
for j in $(curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" -f https://api.github.com/repos/cue-lang/vscode-cue/branches | jq -r '.[] | .name') | ||
do | ||
for i in master | ||
do | ||
if [[ "$j" != $i ]]; then | ||
continue | ||
fi | ||
echo Branch: $j | ||
sha=$(curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/cue-lang/vscode-cue/commits/$j" | jq -r '.sha') | ||
echo Latest commit: $sha | ||
echo "Trigger workflow on cue-lang/vscode-cue" | ||
curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail-with-body -X POST https://api.github.com/repos/cue-lang/vscode-cue/actions/workflows/trybot.yml/dispatches -d "{\"ref\":\"$j\"}" | ||
# Ensure that the trybot repo has the latest commit for | ||
# this branch. If the force-push results in a commit | ||
# being pushed, that will trigger the trybot workflows | ||
# so we don't need to do anything, otherwise we need to | ||
# trigger the most recent commit on that branch | ||
git remote -v | ||
git fetch origin refs/heads/$j | ||
git log -1 FETCH_HEAD | ||
success=false | ||
for try in {1..20}; do | ||
echo "Push to trybot try $try" | ||
exitCode=0; push="$(git push -f trybot FETCH_HEAD:$j 2>&1)" || exitCode=$? | ||
echo "$push" | ||
if [[ $exitCode -eq 0 ]]; then | ||
success=true | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
if ! $success; then | ||
echo "Giving up" | ||
exit 1 | ||
fi | ||
if echo "$push" | grep up-to-date | ||
then | ||
# We are up-to-date, i.e. the push did nothing, hence we need to trigger a workflow_dispatch | ||
# in the trybot repo. | ||
echo "Trigger workflow on cue-lang/vscode-cue-trybot" | ||
curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail-with-body -X POST https://api.github.com/repos/cue-lang/vscode-cue-trybot/actions/workflows/trybot.yml/dispatches -d "{\"ref\":\"$j\"}" | ||
else | ||
echo "Force-push to cue-lang/vscode-cue-trybot did work; nothing to do" | ||
fi | ||
done | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Code generated internal/ci/ci_tool.cue; DO NOT EDIT. | ||
|
||
name: Push tip to trybot | ||
"on": | ||
push: | ||
branches: | ||
- master | ||
concurrency: push_tip_to_trybot | ||
jobs: | ||
push: | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
shell: bash | ||
if: ${{github.repository == 'cue-lang/vscode-cue'}} | ||
steps: | ||
- name: Write netrc file for cueckoo Gerrithub | ||
run: |- | ||
cat <<EOD > ~/.netrc | ||
machine review.gerrithub.io | ||
login cueckoo | ||
password ${{ secrets.CUECKOO_GERRITHUB_PASSWORD }} | ||
EOD | ||
chmod 600 ~/.netrc | ||
- name: Push tip to trybot | ||
run: |- | ||
mkdir tmpgit | ||
cd tmpgit | ||
git init -b initialbranch | ||
git config user.name cueckoo | ||
git config user.email [email protected] | ||
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:${{ secrets.CUECKOO_GITHUB_PAT }} | base64)" | ||
git remote add origin https://review.gerrithub.io/a/cue-lang/vscode-cue | ||
git remote add trybot https://github.com/cue-lang/vscode-cue-trybot | ||
git fetch origin "${{ github.ref }}" | ||
success=false | ||
for try in {1..20}; do | ||
echo "Push to trybot try $try" | ||
if git push -f trybot "FETCH_HEAD:${{ github.ref }}"; then | ||
success=true | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
if ! $success; then | ||
echo "Giving up" | ||
exit 1 | ||
fi |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Code generated internal/ci/ci_tool.cue; DO NOT EDIT. | ||
|
||
name: TryBot | ||
"on": | ||
push: | ||
branches: | ||
- ci/test | ||
- master | ||
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/master') && (! (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.23.x | ||
- name: Set common go env vars | ||
run: |- | ||
go env -w GOTOOLCHAIN=local | ||
# Dump env for good measure | ||
go env | ||
- 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/master') && (! (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.23.x-${{ github.run_id }} | ||
restore-keys: ${{ runner.os }}-1.23.x | ||
- if: |- | ||
! (((github.ref == 'refs/heads/master') && (! (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.23.x-${{ github.run_id }} | ||
restore-keys: ${{ runner.os }}-1.23.x | ||
- if: |- | ||
github.repository == 'cue-lang/vscode-cue' && (((github.ref == 'refs/heads/master') && (! (contains(github.event.head_commit.message, ' | ||
Dispatch-Trailer: {"type":"')))) || github.ref == 'refs/heads/ci/test') | ||
run: go clean -testcache | ||
- name: Verify | ||
run: go mod verify | ||
- name: Generate | ||
run: go generate ./... | ||
- name: Test | ||
run: go test ./... | ||
- name: Race test | ||
run: go test -race ./... | ||
- name: staticcheck | ||
run: go run honnef.co/go/tools/cmd/[email protected] ./... | ||
- name: Tidy | ||
run: go mod tidy | ||
- 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) |
Oops, something went wrong.