From c1133d1f16f1cb55e42b6c2b3c591fa3c8cfe425 Mon Sep 17 00:00:00 2001 From: Anton Belodedenko <2033996+ab77@users.noreply.github.com> Date: Mon, 24 Feb 2025 10:28:44 -0800 Subject: [PATCH 1/3] Support testing external commits tests require cloning of GitHub repo outside of Flowzone on AWS runners` * on pull_request_target (external contibutions) github.event.pull_request.head.repo.full_name will resolve to {{forked-repo}}/open-balena (e.g. MrMEEE/open-balena) * on pull_request, it will resolve to {{ github.repository }} change-type: patch --- .github/workflows/tests.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ce43a18..c035101 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -76,6 +76,7 @@ jobs: - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 with: persist-credentials: false + ref: ${{ github.event.pull_request.head.sha || github.event.head_commit.id || github.event.pull_request.head.ref }} # https://github.com/unfor19/install-aws-cli-action - name: Setup awscli @@ -242,9 +243,8 @@ jobs: with_backoff balena login --token '${{ secrets.BALENA_API_KEY }}' pr_id='${{ github.event.pull_request.id }}' - head_sha='${{ github.event.pull_request.head.sha || github.event.head_commit.id }}' release_id="$(with_backoff balena releases '${{ matrix.fleet }}' --json \ - | jq -r --arg pr_id "${pr_id}" --arg head_sha "${head_sha}" '.[] + | jq -r --arg pr_id "${pr_id}" --arg head_sha "${COMMIT}" '.[] | select(.release_tag[].tag_key=="balena-ci-commit-sha") | select(.release_tag[].value==$head_sha) | select(.release_tag[].tag_key=="balena-ci-id") @@ -256,6 +256,9 @@ jobs: with_backoff balena device ${{ steps.register-test-device.outputs.balena_device_uuid }} + env: + COMMIT: ${{ github.event.pull_request.head.sha || github.event.head_commit.id || github.event.pull_request.head.ref }} + - name: configure balenaOS test device environment if: matrix.target == 'balena-public-pki' run: | @@ -856,7 +859,6 @@ jobs: env: ATTEMPTS: 2 AWS_DEFAULT_REGION: ${{ vars.AWS_REGION || 'us-east-1' }} - COMMIT: ${{ github.event.pull_request.head.sha || github.event.head_commit.id || github.event.pull_request.head.ref }} - name: SUT&DUT (Ubuntu/compose) if: matrix.target == 'compose-private-pki' @@ -910,7 +912,7 @@ jobs: # docs/getting-started.md cmds="set -ax \ && cloud-init status --wait --long && cat Date: Mon, 24 Feb 2025 10:42:32 -0800 Subject: [PATCH 2/3] just use the PR head SHA Co-authored-by: Kyle Harding --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c035101..a060b13 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -76,7 +76,7 @@ jobs: - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 with: persist-credentials: false - ref: ${{ github.event.pull_request.head.sha || github.event.head_commit.id || github.event.pull_request.head.ref }} + ref: ${{ github.event.pull_request.head.sha }} # https://github.com/unfor19/install-aws-cli-action - name: Setup awscli From 1a38782e696661eaf63af7f8ad51f2ac683ea105 Mon Sep 17 00:00:00 2001 From: Anton Belodedenko <2033996+ab77@users.noreply.github.com> Date: Mon, 24 Feb 2025 10:42:58 -0800 Subject: [PATCH 3/3] Just use PR head SHA Co-authored-by: Kyle Harding --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a060b13..b8e679c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -257,7 +257,7 @@ jobs: with_backoff balena device ${{ steps.register-test-device.outputs.balena_device_uuid }} env: - COMMIT: ${{ github.event.pull_request.head.sha || github.event.head_commit.id || github.event.pull_request.head.ref }} + COMMIT: ${{ github.event.pull_request.head.sha }} - name: configure balenaOS test device environment if: matrix.target == 'balena-public-pki'