|
| 1 | +--- |
| 2 | +name: Reusable Tests Workflow |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + arch: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + runs-on: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | +permissions: read-all |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + runs-on: ${{ inputs.runs-on }} |
| 17 | + # this is to prevent arm64 jobs from running at forked projects |
| 18 | + if: inputs.arch == 'amd64' || github.repository == 'etcd-io/etcd' |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + target: |
| 23 | + - linux-${{ inputs.arch }}-integration-1-cpu |
| 24 | + - linux-${{ inputs.arch }}-integration-2-cpu |
| 25 | + - linux-${{ inputs.arch }}-integration-4-cpu |
| 26 | + - linux-${{ inputs.arch }}-unit-4-cpu |
| 27 | + - linux-386-unit-1-cpu |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 30 | + - id: goversion |
| 31 | + run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" |
| 32 | + - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 |
| 33 | + with: |
| 34 | + go-version: ${{ steps.goversion.outputs.goversion }} |
| 35 | + - env: |
| 36 | + TARGET: ${{ matrix.target }} |
| 37 | + run: | |
| 38 | + set -euo pipefail |
| 39 | + go clean -testcache |
| 40 | +
|
| 41 | + mkdir "${TARGET}" |
| 42 | + export JUNIT_REPORT_DIR=$(realpath ${TARGET}) |
| 43 | + case "${TARGET}" in |
| 44 | + linux-${{ inputs.arch }}-integration-1-cpu) |
| 45 | + make gofail-enable |
| 46 | + GOOS=linux GOARCH=${{ inputs.arch }} CPU=1 make test-integration |
| 47 | + ;; |
| 48 | + linux-${{ inputs.arch }}-integration-2-cpu) |
| 49 | + make gofail-enable |
| 50 | + GOOS=linux GOARCH=${{ inputs.arch }} CPU=2 make test-integration |
| 51 | + ;; |
| 52 | + linux-${{ inputs.arch }}-integration-4-cpu) |
| 53 | + make gofail-enable |
| 54 | + GOOS=linux GOARCH=${{ inputs.arch }} CPU=4 make test-integration |
| 55 | + ;; |
| 56 | + linux-${{ inputs.arch }}-unit-4-cpu) |
| 57 | + GOOS=linux GOARCH=${{ inputs.arch }} CPU=4 GO_TEST_FLAGS='-p=2' make test-unit |
| 58 | + ;; |
| 59 | + linux-386-unit-1-cpu) |
| 60 | + # skip running single-threaded 386 unit tests only if arch is arm64 |
| 61 | + if [ "${{ inputs.arch }}" == "arm64" ]; then exit; fi |
| 62 | + GOOS=linux GOARCH=386 CPU=1 GO_TEST_FLAGS='-p=4' make test-unit |
| 63 | + ;; |
| 64 | + *) |
| 65 | + echo "Failed to find target" |
| 66 | + exit 1 |
| 67 | + ;; |
| 68 | + esac |
| 69 | + - uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9 # v4.4.1 |
| 70 | + if: always() |
| 71 | + with: |
| 72 | + name: "${{ matrix.target }}" |
| 73 | + path: ./**/junit_*.xml |
0 commit comments