diff --git a/.github/workflows/_e2e.yaml b/.github/workflows/_e2e.yaml index fc6fe96311bb..9f83f07e176e 100644 --- a/.github/workflows/_e2e.yaml +++ b/.github/workflows/_e2e.yaml @@ -7,7 +7,11 @@ on: runnersByArch: type: string required: false +<<<<<<< HEAD default: '{"amd64": "ubuntu-latest", "arm64": "circleci"}' +======= + default: '' +>>>>>>> 9fbead7e2 (ci(.github): enable self hosted runners for AMD64 E2E tasks (#10745)) permissions: contents: read env: @@ -22,8 +26,7 @@ env: jobs: e2e: timeout-minutes: 60 - # use the runner from the map, if the runner is circleci or '' then use ubuntu-latest - runs-on: ${{ contains(fromJSON('["circleci", ""]'), fromJSON(inputs.runnersByArch)[fromJSON(inputs.matrix).arch]) && 'ubuntu-latest' || fromJSON(inputs.runnersByArch)[fromJSON(inputs.matrix).arch]}} + runs-on: ${{ fromJSON(inputs.runnersByArch)[fromJSON(inputs.matrix).arch] }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/_test.yaml b/.github/workflows/_test.yaml index b4c95cde8d0a..5474a7fe8575 100644 --- a/.github/workflows/_test.yaml +++ b/.github/workflows/_test.yaml @@ -39,6 +39,7 @@ jobs: runs-on: ubuntu-latest outputs: matrix: ${{ steps.generate-matrix.outputs.matrix }} + runners: ${{ steps.assign-e2e-runners.outputs.runners }} steps: - id: generate-matrix name: Generate matrix @@ -95,6 +96,48 @@ jobs: echo "matrix<> $GITHUB_OUTPUT echo "$BASE_MATRIX_ALL" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT + - id: assign-e2e-runners + name: Assign runners for E2E tests + env: + IS_TRUSTED_BUILD: ${{ github.event_name == 'push' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} + ALL_RUNNERS: |- + { + "trusted_builds": { + "amd64": [ + "ubuntu-latest-kong" + ], + "arm64": [ + "ubuntu-latest-arm64-kong" + ] + }, + "untrusted_builds": { + "amd64": [ + "ubuntu-latest" + ], + "arm64": [] + } + } + run: |- + ALL_RUNNERS='${{ env.ALL_RUNNERS }}' + if [[ "${{ env.IS_TRUSTED_BUILD }}" == "true" ]]; then + ALL_RUNNERS=$(echo $ALL_RUNNERS | jq -r '.trusted_builds') + else + ALL_RUNNERS=$(echo $ALL_RUNNERS | jq -r '.untrusted_builds') + fi + + for ARCH in amd64 arm64; do + COUNT=$(echo $ALL_RUNNERS | jq -r ".$ARCH | length") + if [[ $COUNT -eq 0 ]]; then + ALL_RUNNERS=$(echo $ALL_RUNNERS | jq -r ".$ARCH=\"\"") + else + ALL_RUNNERS=$(echo $ALL_RUNNERS | jq -r ".$ARCH=.$ARCH[0]") + fi + done + + echo "final runners: $ALL_RUNNERS" + echo "runners<> $GITHUB_OUTPUT + echo "$ALL_RUNNERS" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT test_e2e: needs: ["gen_e2e_matrix"] if: fromJSON(needs.gen_e2e_matrix.outputs.matrix).test_e2e @@ -105,6 +148,7 @@ jobs: uses: ./.github/workflows/_e2e.yaml with: matrix: ${{ toJSON(matrix) }} + runnersByArch: ${{ needs.gen_e2e_matrix.outputs.runners }} secrets: inherit test_e2e_env: needs: ["gen_e2e_matrix"] @@ -116,4 +160,5 @@ jobs: uses: ./.github/workflows/_e2e.yaml with: matrix: ${{ toJSON(matrix) }} + runnersByArch: ${{ needs.gen_e2e_matrix.outputs.runners }} secrets: inherit