From 59079b1a834999274efea25caf7e31776e2c6227 Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Thu, 15 Jul 2021 17:31:30 +0100 Subject: [PATCH] ci: tidy up quoting of JSON args in workflow commands Spotted during the migration; using strconv.Quote is a more robust way of ensuring the string argument to curl is quoted properly. Signed-off-by: Paul Jolly Change-Id: Idc2eaf2771a2244d8668584e95563ecd991900df Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/520759 Unity-Result: CUEcueckoo TryBot-Result: CUEcueckoo --- .github/workflows/test.yml | 18 +++++---- cmd/cue/cmd/testdata/script/cmd_github.txt | 21 ++++++----- cue/testdata/eval/github.txtar | 43 +++++++++++----------- internal/ci/workflows.cue | 3 +- 4 files changed, 46 insertions(+), 39 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a72e3ed9b9..78e151f9e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,9 +27,10 @@ jobs: - if: ${{ startsWith(github.ref, 'refs/heads/ci/') }} name: Update Gerrit CL message with starting message run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data - ''{"tag":"trybot","message":"Started the build... see progress at ${{ github.event.repository.html_url - }}/actions/runs/${{ github.run_id }}"}'' https://review.gerrithub.io/a/changes/$(basename - $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review' + "{\"tag\":\"trybot\",\"message\":\"Started the build... see progress at ${{ + github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\"}" + https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename + $GITHUB_REF)/review' test: needs: start strategy: @@ -81,9 +82,9 @@ jobs: - if: ${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }} name: Post any failures for this matrix entry run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data - ''{"tag":"trybot","message":"Build failed for ${{ runner.os }}-${{ matrix.go-version + "{\"tag\":\"trybot\",\"message\":\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id - }} for more details","labels":{"TryBot-Result":-1}}'' https://review.gerrithub.io/a/changes/$(basename + }} for more details\",\"labels\":{\"TryBot-Result\":-1}}" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review' mark_ci_success: runs-on: ubuntu-18.04 @@ -103,9 +104,10 @@ jobs: chmod 600 ~/.netrc - name: Update Gerrit CL message with success message run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data - ''{"tag":"trybot","message":"Build succeeded for ${{ github.event.repository.html_url - }}/actions/runs/${{ github.run_id }}","labels":{"TryBot-Result":1}}'' https://review.gerrithub.io/a/changes/$(basename - $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review' + "{\"tag\":\"trybot\",\"message\":\"Build succeeded for ${{ github.event.repository.html_url + }}/actions/runs/${{ github.run_id }}\",\"labels\":{\"TryBot-Result\":1}}" + https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename + $GITHUB_REF)/review' delete_build_branch: runs-on: ubuntu-18.04 if: ${{ startsWith(github.ref, 'refs/heads/ci/') && always() }} diff --git a/cmd/cue/cmd/testdata/script/cmd_github.txt b/cmd/cue/cmd/testdata/script/cmd_github.txt index ed1e50617d..a0c8ade30e 100644 --- a/cmd/cue/cmd/testdata/script/cmd_github.txt +++ b/cmd/cue/cmd/testdata/script/cmd_github.txt @@ -198,9 +198,10 @@ jobs: - if: ${{ startsWith(github.ref, 'refs/heads/ci/') }} name: Update Gerrit CL message with starting message run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data - ''{"tag":"trybot","message":"Started the build... see progress at ${{ github.event.repository.html_url - }}/actions/runs/${{ github.run_id }}"}'' https://review.gerrithub.io/a/changes/$(basename - $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review' + "{\"tag\":\"trybot\",\"message\":\"Started the build... see progress at ${{ + github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\"}" + https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename + $GITHUB_REF)/review' test: needs: start strategy: @@ -252,9 +253,9 @@ jobs: - if: ${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }} name: Post any failures for this matrix entry run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data - ''{"tag":"trybot","message":"Build failed for ${{ runner.os }}-${{ matrix.go-version + "{\"tag\":\"trybot\",\"message\":\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id - }} for more details","labels":{"TryBot-Result":-1}}'' https://review.gerrithub.io/a/changes/$(basename + }} for more details\",\"labels\":{\"TryBot-Result\":-1}}" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review' mark_ci_success: runs-on: ubuntu-18.04 @@ -274,9 +275,10 @@ jobs: chmod 600 ~/.netrc - name: Update Gerrit CL message with success message run: 'curl -f -s -n -H "Content-Type: application/json" --request POST --data - ''{"tag":"trybot","message":"Build succeeded for ${{ github.event.repository.html_url - }}/actions/runs/${{ github.run_id }}","labels":{"TryBot-Result":1}}'' https://review.gerrithub.io/a/changes/$(basename - $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review' + "{\"tag\":\"trybot\",\"message\":\"Build succeeded for ${{ github.event.repository.html_url + }}/actions/runs/${{ github.run_id }}\",\"labels\":{\"TryBot-Result\":1}}" + https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename + $GITHUB_REF)/review' delete_build_branch: runs-on: ubuntu-18.04 if: ${{ startsWith(github.ref, 'refs/heads/ci/') && always() }} @@ -1127,6 +1129,7 @@ package ci import ( "github.com/SchemaStore/schemastore/src/schemas/json" + "strconv" encjson "encoding/json" ) @@ -1249,7 +1252,7 @@ test: _#bashWorkflow & { message: string labels?: "TryBot-Result": int } - res: "\(_#curl) -n -H \"Content-Type: application/json\" --request POST --data '\(encjson.Marshal(#args))' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" + res: "\(_#curl) -n -H \"Content-Type: application/json\" --request POST --data \(strconv.Quote(encjson.Marshal(#args))) https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } } diff --git a/cue/testdata/eval/github.txtar b/cue/testdata/eval/github.txtar index 124c0412be..8752039395 100644 --- a/cue/testdata/eval/github.txtar +++ b/cue/testdata/eval/github.txtar @@ -10,6 +10,7 @@ package ci import ( "github.com/SchemaStore/schemastore/src/schemas/json" + "strconv" encjson "encoding/json" ) @@ -132,7 +133,7 @@ test: _#bashWorkflow & { message: string labels?: "TryBot-Result": int } - res: "\(_#curl) -n -H \"Content-Type: application/json\" --request POST --data '\(encjson.Marshal(#args))' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" + res: "\(_#curl) -n -H \"Content-Type: application/json\" --request POST --data \(strconv.Quote(encjson.Marshal(#args))) https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } } @@ -1100,7 +1101,7 @@ import "strings" } 1: (#struct){ name: (string){ "Update Gerrit CL message with starting message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\"}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\"}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') }}" } } } @@ -1176,7 +1177,7 @@ import "strings" 9: (#struct){ if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }}" } name: (string){ "Post any failures for this matrix entry" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\",\"labels\":{\"TryBot-Result\":-1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":-1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } } defaults: (#struct){ @@ -1196,7 +1197,7 @@ import "strings" } 1: (#struct){ name: (string){ "Update Gerrit CL message with success message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\",\"labels\":{\"TryBot-Result\":1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } } defaults: (#struct){ @@ -1243,16 +1244,16 @@ import "strings" } _#startCLBuild(:ci): (#struct){ name: (string){ "Update Gerrit CL message with starting message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\"}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\"}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } _#failCLBuild(:ci): (#struct){ if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }}" } name: (string){ "Post any failures for this matrix entry" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\",\"labels\":{\"TryBot-Result\":-1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":-1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } _#passCLBuild(:ci): (#struct){ name: (string){ "Update Gerrit CL message with success message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\",\"labels\":{\"TryBot-Result\":1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } _#gerrit(:ci): (#struct){ _#setCodeReview(:ci): (#struct){ @@ -1262,7 +1263,7 @@ import "strings" } res: (_|_){ // [incomplete] invalid interpolation: cannot convert incomplete value "string" to JSON: - // ./workflows.cue:127:9 + // ./workflows.cue:128:9 } } } @@ -1338,7 +1339,7 @@ import "strings" _#type(:ci): (string){ string } if: (_|_){ // [incomplete] workflows.1.schema._#dispatchJob.if: invalid interpolation: non-concrete value string (type string): - // ./workflows.cue:138:14 + // ./workflows.cue:139:14 } } name: (string){ "Repository Dispatch" } @@ -1670,7 +1671,7 @@ import "strings" } 1: (#struct){ name: (string){ "Update Gerrit CL message with starting message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\"}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\"}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') }}" } } } @@ -1746,7 +1747,7 @@ import "strings" 9: (#struct){ if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }}" } name: (string){ "Post any failures for this matrix entry" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\",\"labels\":{\"TryBot-Result\":-1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":-1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } } defaults: (#struct){ @@ -1766,7 +1767,7 @@ import "strings" } 1: (#struct){ name: (string){ "Update Gerrit CL message with success message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\",\"labels\":{\"TryBot-Result\":1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } } defaults: (#struct){ @@ -1813,16 +1814,16 @@ import "strings" } _#startCLBuild(:ci): (#struct){ name: (string){ "Update Gerrit CL message with starting message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\"}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\"}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } _#failCLBuild(:ci): (#struct){ if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }}" } name: (string){ "Post any failures for this matrix entry" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\",\"labels\":{\"TryBot-Result\":-1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":-1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } _#passCLBuild(:ci): (#struct){ name: (string){ "Update Gerrit CL message with success message" } - run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data '{\"tag\":\"trybot\",\"message\":\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\",\"labels\":{\"TryBot-Result\":1}}' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } + run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } _#gerrit(:ci): (#struct){ _#setCodeReview(:ci): (#struct){ @@ -1832,7 +1833,7 @@ import "strings" } res: (_|_){ // [incomplete] invalid interpolation: cannot convert incomplete value "string" to JSON: - // ./workflows.cue:127:9 + // ./workflows.cue:128:9 } } } @@ -1905,7 +1906,7 @@ import "strings" _#type(:ci): (string){ string } if: (_|_){ // [incomplete] repository_dispatch._#dispatchJob.if: invalid interpolation: non-concrete value string (type string): - // ./workflows.cue:138:14 + // ./workflows.cue:139:14 } } name: (string){ "Repository Dispatch" } @@ -2264,7 +2265,7 @@ import "strings" name: (string){ "Set go build tags" } run: (_|_){ // [incomplete] _#setGoBuildTags.run: invalid interpolation: non-concrete value string (type string): - // ./workflows.cue:269:10 + // ./workflows.cue:270:10 } } _#installGo(:ci): (#struct){ @@ -2318,7 +2319,7 @@ import "strings" _#cueckooCopybaraImage(:ci): (string){ "cueckoo/copybara:afc4ae03eed00b0c9d7415141cd1b5dfa583da7c" } _#copybaraCmd(:ci): (_|_){ // [incomplete] _#copybaraCmd: invalid interpolation: non-concrete value string (type string): - // ./workflows.cue:343:2 + // ./workflows.cue:344:2 _#cmd(:ci): (string){ string } } _#copybaraSteps(:ci): (#list){ @@ -2332,7 +2333,7 @@ import "strings" name: (string){ string } run: (_|_){ // [incomplete] _#copybaraSteps.1.run: invalid interpolation: non-concrete value string (type string): - // ./workflows.cue:343:2 + // ./workflows.cue:344:2 _#cmd(:ci): (string){ string } } } @@ -2485,7 +2486,7 @@ import "strings" "TryBot-Result": int } } - res: "\(〈3;_#curl〉) -n -H "Content-Type: application/json" --request POST --data '\(〈import;"encoding/json"〉.Marshal(〈0;#args〉))' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" + res: "\(〈3;_#curl〉) -n -H "Content-Type: application/json" --request POST --data \(〈import;strconv〉.Quote(〈import;"encoding/json"〉.Marshal(〈0;#args〉))) https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } } }) diff --git a/internal/ci/workflows.cue b/internal/ci/workflows.cue index 19b7dbbb97..c2b80980c9 100644 --- a/internal/ci/workflows.cue +++ b/internal/ci/workflows.cue @@ -17,6 +17,7 @@ package ci import ( "github.com/SchemaStore/schemastore/src/schemas/json" encjson "encoding/json" + "strconv" ) workflowsDir: *"./" | string @tag(workflowsDir) @@ -181,7 +182,7 @@ test: _#bashWorkflow & { } } res: #""" - \#(_#curl) -n -H "Content-Type: application/json" --request POST --data '\#(encjson.Marshal(#args))' https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review + \#(_#curl) -n -H "Content-Type: application/json" --request POST --data \#(strconv.Quote(encjson.Marshal(#args))) https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review """# } }