Skip to content

Commit

Permalink
ci(.github): enable self hosted runners for AMD64 E2E tasks (#10745)
Browse files Browse the repository at this point in the history
  • Loading branch information
jijiechen authored and kumahq[bot] committed Jul 3, 2024
1 parent bab1af2 commit c882bc0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,6 +96,48 @@ jobs:
echo "matrix<<EOF" >> $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<<EOF" >> $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
Expand All @@ -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"]
Expand All @@ -116,4 +160,5 @@ jobs:
uses: ./.github/workflows/_e2e.yaml
with:
matrix: ${{ toJSON(matrix) }}
runnersByArch: ${{ needs.gen_e2e_matrix.outputs.runners }}
secrets: inherit

0 comments on commit c882bc0

Please sign in to comment.