ci(github): move test, build and publish to workflow_call #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | ||
workflow_call: | ||
inputs: | ||
FULL_MATRIX: | ||
required: true | ||
type: string | ||
CI_TOOLS_DIR: | ||
required: true | ||
type: string | ||
secrets: | ||
circleCIToken: | ||
required: true | ||
permissions: | ||
contents: read | ||
jobs: | ||
test: | ||
timeout-minutes: 20 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version-file: go.mod | ||
- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 | ||
with: | ||
path: | | ||
${{ inputs.CI_TOOLS_DIR }} | ||
key: ${{ runner.os }}-${{ runner.arch }}-devtools-${{ hashFiles('mk/dependencies/deps.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ runner.arch }}-devtools | ||
- run: | | ||
make dev/tools | ||
- run: | | ||
make test | ||
gen_e2e_matrix: | ||
timeout-minutes: 2 | ||
runs-on: ubuntu-latest | ||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci/skip-e2e-test') }} | ||
outputs: | ||
matrix: ${{ steps.generate-matrix.outputs.matrix }} | ||
steps: | ||
- id: generate-matrix | ||
name: Generate matrix | ||
env: | ||
BASE_MATRIX: |- | ||
{ | ||
"test_e2e": { | ||
"target": [""], | ||
"k8sVersion": ["kindIpv6", "${{ env.K8S_MIN_VERSION }}", "${{ env.K8S_MAX_VERSION }}"], | ||
"arch": ["amd64"], | ||
"parallelism": [4], | ||
"cniNetworkPlugin": ["flannel"], | ||
"sidecarContainers": [""] | ||
}, | ||
"test_e2e_env": { | ||
"target": ["kubernetes", "universal", "multizone"], | ||
"k8sVersion": ["kind", "kindIpv6", "${{ env.K8S_MIN_VERSION }}", "${{ env.K8S_MAX_VERSION }}"], | ||
"arch": ["amd64"], | ||
"parallelism": [1], | ||
"cniNetworkPlugin": ["flannel"], | ||
"sidecarContainers": [""], | ||
"exclude":[ | ||
{"target": "kubernetes", "k8sVersion":"kind"}, | ||
{"target": "multizone", "k8sVersion":"kind"}, | ||
{"target":"universal", "k8sVersion":"${{ env.K8S_MIN_VERSION }}"}, | ||
{"target":"universal", "k8sVersion":"${{ env.K8S_MAX_VERSION }}"} | ||
], | ||
"include":[ | ||
{"sidecarContainers": "sidecarContainers", "k8sVersion": "${{ env.K8S_MAX_VERSION }}", "target": "kubernetes", "arch": "amd64"}, | ||
{"k8sVersion": "${{ env.K8S_MAX_VERSION }}", "target": "multizone", "arch": "arm64"}, | ||
{"k8sVersion": "${{ env.K8S_MAX_VERSION }}", "target": "kubernetes", "arch": "arm64"}, | ||
{"k8sVersion": "${{ env.K8S_MAX_VERSION }}", "target": "universal", "arch": "arm64"}, | ||
{"k8sVersion": "${{ env.K8S_MAX_VERSION }}", "target": "gatewayapi", "arch": "amd64"}, | ||
{"cniNetworkPlugin": "calico", "k8sVersion": "${{ env.K8S_MAX_VERSION }}", "target": "multizone", "arch": "amd64"} | ||
] | ||
} | ||
} | ||
# You can modify the include to run one of test suites on PRs (though you'd need to then remove it) | ||
OVERRIDE_JQ_CMD: |- | ||
.test_e2e = false | ||
| .test_e2e_env.include = [] | ||
| .test_e2e_env.exclude += [{"arch": "arm64"}, {"k8sVersion": "kindIpv6"}, {"k8sVersion": "${{ env.K8S_MIN_VERSION}}"}] | ||
run: |- | ||
BASE_MATRIX_ALL='${{ env.BASE_MATRIX }}' | ||
if [[ "${{ inputs.FULL_MATRIX }}" != "true" ]]; then | ||
BASE_MATRIX_ALL=$(echo $BASE_MATRIX_ALL | jq -r '${{ env.OVERRIDE_JQ_CMD }}') | ||
fi | ||
echo "final matrix: $BASE_MATRIX_ALL" | ||
echo "matrix<<EOF" >> $GITHUB_OUTPUT | ||
echo "$BASE_MATRIX_ALL" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
test_e2e: | ||
needs: ["gen_e2e_matrix"] | ||
if: fromJSON(needs.gen_e2e_matrix.outputs.matrix).test_e2e | ||
strategy: | ||
matrix: ${{ fromJSON(needs.gen_e2e_matrix.outputs.matrix).test_e2e }} | ||
fail-fast: false | ||
uses: ./.github/workflows/_e2e.yaml | ||
with: | ||
matrix: ${{ toJSON(matrix) }} | ||
secrets: | ||
circleCIToken: ${{ secrets.CIRCLECI_TOKEN }} | ||
test_e2e_env: | ||
needs: ["gen_e2e_matrix"] | ||
if: fromJSON(needs.gen_e2e_matrix.outputs.matrix).test_e2e_env | ||
strategy: | ||
matrix: ${{ fromJSON(needs.gen_e2e_matrix.outputs.matrix).test_e2e_env }} | ||
fail-fast: false | ||
uses: ./.github/workflows/_e2e.yaml | ||
with: | ||
matrix: ${{ toJSON(matrix) }} | ||
CI_TOOLS_DIR: %{{ inputs.CI_TOOLS_DIR }} | ||
secrets: | ||
circleCIToken: ${{ secrets.CIRCLECI_TOKEN }} |