From b164ffd30d30756fe18ae0cd62a03062e0beb008 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sun, 15 Nov 2026 02:34:09 +0000 Subject: [PATCH] Test the Go JavaScript builder against the template under review --- .github/workflows/consumer-tests.yml | 55 ++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/.github/workflows/consumer-tests.yml b/.github/workflows/consumer-tests.yml index 407312c..e94005a 100644 --- a/.github/workflows/consumer-tests.yml +++ b/.github/workflows/consumer-tests.yml @@ -4,9 +4,9 @@ name: Consumer tests # exercised by the SDKs that embed it. This builds every one of them against # the revision under review and runs its JavaScript builder tests. # -# Six SDKs render the templates. .NET, Java, Node and Python embed them as a -# submodule. PHP and Rust carry a copy of the file, which does not follow -# this repository on its own, so for those two the job also says when the +# Seven SDKs render the templates. .NET, Java, Node and Python embed them as a +# submodule. PHP, Rust and Go carry a copy of the file, which does not follow +# this repository on its own, so for those three the job also says when the # copy differs from main here. Every one of them is expected to render the # same script from the same evidence, so a # change here that suits one and not another is a fault in the change or in @@ -48,6 +48,10 @@ on: description: Branch, tag or SHA of 51degrees-rust to test against required: false default: main + go-ref: + description: Branch, tag or SHA of 51degrees-go to test against + required: false + default: main permissions: contents: read @@ -366,3 +370,48 @@ jobs: - name: Run the JavaScript builder tests working-directory: consumer run: cargo test -p fiftyone-javascript-builder + + go: + name: 51degrees-go JavaScript builder + runs-on: ubuntu-latest + steps: + - name: Check out the template under review + uses: actions/checkout@v4 + with: + path: template + + - name: Check out 51degrees-go + uses: actions/checkout@v4 + with: + repository: 51Degrees/51degrees-go + ref: ${{ inputs.go-ref || 'main' }} + path: consumer + + # A copy embedded with go:embed, so the same comparison as PHP and Rust. + # The tests also read the javascript-templates submodule and check the + # copy equals it, so the revision under review goes in both places. + - name: Swap in the template under review + run: | + set -euo pipefail + file=pipeline/elements/javascriptbuilder/javascript-templates/JavaScriptResource.mustache + if [ ! -f "consumer/$file" ]; then + echo "::error::consumer/$file is missing - the copy has moved and this workflow needs updating" + exit 1 + fi + cp template/JavaScriptResource.mustache "consumer/$file" + if git -C consumer diff --quiet -- "$file"; then + echo "::notice::the copy in 51degrees-go is identical to the revision under review" + else + echo "::warning::the copy in 51degrees-go differs from the revision under review" + git -C consumer --no-pager diff --stat -- "$file" + fi + mkdir -p consumer/javascript-templates + cp template/JavaScriptResource.mustache consumer/javascript-templates/ + + - uses: actions/setup-go@v5 + with: + go-version-file: consumer/pipeline/go.mod + + - name: Run the JavaScript builder tests + working-directory: consumer/pipeline + run: go test -count=1 -v ./elements/javascriptbuilder/