|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + inputs: |
| 4 | + runner: |
| 5 | + description: "The runner to use" |
| 6 | + required: true |
| 7 | + default: "ubuntu-22.04" |
| 8 | + type: string |
| 9 | + triplet: |
| 10 | + description: "The triplet to use" |
| 11 | + required: true |
| 12 | + default: "x64-linux" |
| 13 | + type: string |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +env: |
| 19 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + _VCPKG_: ${{ github.workspace }}/external/microsoft/vcpkg |
| 21 | + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" |
| 22 | + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/external/microsoft/vcpkg/bincache |
| 23 | + VCPKG_FEATURE_FLAGS: "dependencygraph" |
| 24 | + |
| 25 | +jobs: |
| 26 | + build: |
| 27 | + runs-on: ${{ inputs.runner }} |
| 28 | + steps: |
| 29 | + - name: Check out repository code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + submodules: "true" |
| 33 | + |
| 34 | + - uses: actions/github-script@v6 |
| 35 | + with: |
| 36 | + script: | |
| 37 | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); |
| 38 | + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); |
| 39 | +
|
| 40 | + - name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'" |
| 41 | + run: mkdir -p ${{ github.workspace }}/external/microsoft/vcpkg/bincache |
| 42 | + shell: bash |
| 43 | + |
| 44 | + - uses: lukka/get-cmake@latest |
| 45 | + with: |
| 46 | + cmakeVersion: "3.29.0" |
| 47 | + |
| 48 | + - name: Restore vcpkg |
| 49 | + uses: actions/cache@v3 |
| 50 | + with: |
| 51 | + path: | |
| 52 | + ${{ env._VCPKG_ }} |
| 53 | + !${{ env._VCPKG_ }}/buildtrees |
| 54 | + !${{ env._VCPKG_ }}/packages |
| 55 | + !${{ env._VCPKG_ }}/downloads |
| 56 | + !${{ env._VCPKG_ }}/installed |
| 57 | + key: | |
| 58 | + ${{ inputs.triplet }}-${{ hashFiles( '.git/modules/external/microsoft/vcpkg/HEAD' )}} |
| 59 | +
|
| 60 | + - name: Configure |
| 61 | + env: |
| 62 | + CMAKE_VERBOSE_MAKEFILE: 1 |
| 63 | + VCPKG_DEBUG: 1 |
| 64 | + run: | |
| 65 | + echo "Configuring for triplet ${{ inputs.triplet }}" |
| 66 | + TRIPLET=${{ inputs.triplet }} make configure |
| 67 | +
|
| 68 | + - name: Build |
| 69 | + run: NPROC=1 make build |
| 70 | + |
| 71 | + - uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: build-${{ inputs.triplet }}-${{ github.sha }} |
| 74 | + path: build |
| 75 | + retention-days: 1 |
| 76 | + |
| 77 | + test: |
| 78 | + needs: [build] |
| 79 | + runs-on: ${{ inputs.runner }} |
| 80 | + steps: |
| 81 | + - name: Check out repository code |
| 82 | + uses: actions/checkout@v4 |
| 83 | + with: |
| 84 | + submodules: "true" |
| 85 | + |
| 86 | + - uses: actions/github-script@v6 |
| 87 | + with: |
| 88 | + script: | |
| 89 | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); |
| 90 | + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); |
| 91 | +
|
| 92 | + - name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'" |
| 93 | + run: mkdir -p ${{ github.workspace }}/external/microsoft/vcpkg/bincache |
| 94 | + shell: bash |
| 95 | + |
| 96 | + - uses: lukka/get-cmake@latest |
| 97 | + with: |
| 98 | + cmakeVersion: "3.29.0" |
| 99 | + |
| 100 | + - uses: actions/download-artifact@v4 |
| 101 | + with: |
| 102 | + name: build-${{ inputs.triplet }}-${{ github.sha }} |
| 103 | + path: build |
| 104 | + |
| 105 | + - name: Run tests |
| 106 | + run: make test |
| 107 | + shell: bash |
0 commit comments