From b15fcb039af15018e423f4700a4de576f7e4607b Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Sat, 4 Nov 2023 10:29:21 +0000 Subject: [PATCH] internal/ci: only run e2e tests in source repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We already had the condition that the e2e tests should only run on protected branch for the latest-linux matrix entry, but this condition needs to be enhanced to limit this further to the source repo and not the trybot "shadow" repo. There are no credentials available in the latter, so e2e tests would always fail. Signed-off-by: Paul Jolly Change-Id: I5ab31580ec48c1fac4428de18cf2963913b4bbeb Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1171699 TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine Reviewed-by: Daniel Martí --- .github/workflows/trybot.yml | 2 +- internal/ci/github/trybot.cue | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/trybot.yml b/.github/workflows/trybot.yml index f6b06aa9be6..337430d2169 100644 --- a/.github/workflows/trybot.yml +++ b/.github/workflows/trybot.yml @@ -183,7 +183,7 @@ jobs: env: GORACE: atexit_sleep_ms=10 - if: |- - ((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' + github.repository == 'cue-lang/cue' && ((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' Dispatch-Trailer: {"type":"')))) && (matrix.go-version == '1.21.x' && matrix.runner == 'ubuntu-22.04') name: End-to-end test run: |- diff --git a/internal/ci/github/trybot.cue b/internal/ci/github/trybot.cue index 031966819c9..438d798002a 100644 --- a/internal/ci/github/trybot.cue +++ b/internal/ci/github/trybot.cue @@ -118,14 +118,17 @@ workflows: trybot: _repo.bashWorkflow & { _e2eTest: json.#step & { name: "End-to-end test" // The end-to-end tests require a github token secret and are a bit slow, - // so we only run them on pushes to protected branches and on one environment. - if: "\(_repo.isProtectedBranch) && \(_isLatestLinux)" + // so we only run them on pushes to protected branches and on one + // environment in the source repo. + if: "github.repository == '\(_repo.githubRepositoryPath)' && \(_repo.isProtectedBranch) && \(_isLatestLinux)" + // The secret is the fine-grained access token "cue-lang/cue ci e2e for modules-testing" // owned by the porcuepine bot account with read+write access to repo administration and code // on the entire cue-labs-modules-testing org. Note that porcuepine is also an org admin, // since otherwise the repo admin access to create and delete repos does not work. env: GITHUB_TOKEN: "${{ secrets.E2E_GITHUB_TOKEN }}" - run: """ + + run: """ cd internal/e2e go test """ @@ -146,6 +149,6 @@ workflows: trybot: _repo.bashWorkflow & { _goTestRace: json.#step & { name: "Test with -race" env: GORACE: "atexit_sleep_ms=10" // Otherwise every Go package being tested sleeps for 1s; see https://go.dev/issues/20364. - run: "go test -race ./..." + run: "go test -race ./..." } }