|
| 1 | +name: unit-test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + target: |
| 7 | + description: "Build target (e.g. aarch64 or aarch64_minimal)" |
| 8 | + default: "x86_64" |
| 9 | + type: string |
| 10 | + parallel: |
| 11 | + description: 'Massive parallel build of each image' |
| 12 | + default: true |
| 13 | + type: boolean |
| 14 | + name: |
| 15 | + description: "Name (for spin overrides)" |
| 16 | + default: "infix" |
| 17 | + type: string |
| 18 | + infix_repo: |
| 19 | + description: 'Repo to checkout (for spin overrides)' |
| 20 | + default: kernelkit/infix |
| 21 | + type: string |
| 22 | + infix_branch: |
| 23 | + description: 'Branch/tag/commit to checkout (for spin overrides)' |
| 24 | + default: '' |
| 25 | + type: string |
| 26 | + |
| 27 | + workflow_call: |
| 28 | + inputs: |
| 29 | + target: |
| 30 | + required: true |
| 31 | + type: string |
| 32 | + name: |
| 33 | + required: true |
| 34 | + type: string |
| 35 | + infix_repo: |
| 36 | + required: false |
| 37 | + type: string |
| 38 | + default: kernelkit/infix |
| 39 | + infix_branch: |
| 40 | + required: false |
| 41 | + type: string |
| 42 | + default: '' |
| 43 | + description: 'Branch/tag/commit to checkout (for spin overrides). Defaults to github.ref if not specified' |
| 44 | + parallel: |
| 45 | + required: false |
| 46 | + type: boolean |
| 47 | + default: true |
| 48 | + pre_build_script: |
| 49 | + required: false |
| 50 | + type: string |
| 51 | + default: '' |
| 52 | + description: 'Optional script to run after checkout (for spin customization)' |
| 53 | + secrets: |
| 54 | + CHECKOUT_TOKEN: |
| 55 | + required: false |
| 56 | + description: 'Token for cross-repository access' |
| 57 | + |
| 58 | +env: |
| 59 | + NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }} |
| 60 | + TARGET: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }} |
| 61 | + INFIX_REPO: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.infix_repo || inputs.infix_repo }} |
| 62 | + INFIX_BRANCH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.infix_branch || inputs.infix_branch }} |
| 63 | + |
| 64 | +jobs: |
| 65 | + unit-tests: |
| 66 | + name: Build ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }} |
| 67 | + runs-on: [ self-hosted, latest ] |
| 68 | + env: |
| 69 | + PARALLEL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.parallel == 'true' || github.event_name != 'workflow_dispatch' && inputs.parallel == true }} |
| 70 | + strategy: |
| 71 | + fail-fast: false |
| 72 | + steps: |
| 73 | + - name: Cleanup Build Folder |
| 74 | + run: | |
| 75 | + ls -la ./ |
| 76 | + rm -rf ./* || true |
| 77 | + rm -rf ./.??* || true |
| 78 | + ls -la ./ |
| 79 | +
|
| 80 | + - name: Checkout infix repo |
| 81 | + uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + repository: ${{ env.INFIX_REPO }} |
| 84 | + ref: ${{ env.INFIX_BRANCH != '' && env.INFIX_BRANCH || github.ref }} |
| 85 | + clean: true |
| 86 | + fetch-depth: 0 |
| 87 | + submodules: recursive |
| 88 | + token: ${{ secrets.CHECKOUT_TOKEN || github.token }} |
| 89 | + |
| 90 | + - uses: ./.github/actions/podman-cleanup |
| 91 | + |
| 92 | + - name: Run pre-build script |
| 93 | + if: ${{ inputs.pre_build_script != '' }} |
| 94 | + run: | |
| 95 | + cat > ./pre-build.sh << 'EOF' |
| 96 | + ${{ inputs.pre_build_script }} |
| 97 | + EOF |
| 98 | + chmod +x ./pre-build.sh |
| 99 | + bash ./pre-build.sh |
| 100 | +
|
| 101 | + - uses: ./.github/actions/cache-restore |
| 102 | + with: |
| 103 | + target: ${{ env.TARGET }} |
| 104 | + |
| 105 | + - name: Configure ${{ env.TARGET }} |
| 106 | + run: | |
| 107 | + make ${{ env.TARGET }}_defconfig |
| 108 | +
|
| 109 | + - name: Cleanup stale containers and ports |
| 110 | + run: | |
| 111 | + podman rm -af || true |
| 112 | + pkill -9 -f rootlessport || true |
| 113 | +
|
| 114 | + - name: Unit Test ${{ env.TARGET }} |
| 115 | + run: | |
| 116 | + make test-unit |
0 commit comments