|
1 | | -# Placeholder workflow file allowing running it without having to merge to main first |
2 | 1 | name: placeholder_workflow |
3 | 2 |
|
4 | 3 | on: |
5 | | - workflow_dispatch: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + run-pcc-cpu-batch: |
| 7 | + type: string |
| 8 | + run-pcc-hpu: |
| 9 | + type: boolean |
| 10 | + default: false |
| 11 | + run-build: |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + run-build-layers: |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + run-build-c-api: |
| 18 | + type: boolean |
| 19 | + default: false |
| 20 | + run-build-tfhe-full: |
| 21 | + type: boolean |
| 22 | + default: false |
| 23 | + runners-to-use: # Additional runners to run builds command against |
| 24 | + type: string # Use comma separated values to generate an array |
| 25 | + default: "" |
| 26 | + secrets: |
| 27 | + REPO_CHECKOUT_TOKEN: |
| 28 | + required: true |
| 29 | + SLAB_ACTION_TOKEN: |
| 30 | + required: true |
| 31 | + SLAB_BASE_URL: |
| 32 | + required: true |
| 33 | + SLAB_URL: |
| 34 | + required: true |
| 35 | + JOB_SECRET: |
| 36 | + required: true |
| 37 | + SLACK_CHANNEL: |
| 38 | + required: true |
| 39 | + BOT_USERNAME: |
| 40 | + required: true |
| 41 | + SLACK_WEBHOOK: |
| 42 | + required: true |
6 | 43 |
|
7 | | -permissions: {} |
| 44 | +env: |
| 45 | + CARGO_TERM_COLOR: always |
| 46 | + RUSTFLAGS: "-C target-cpu=native" |
| 47 | + RUST_BACKTRACE: "full" |
| 48 | + RUST_MIN_STACK: "8388608" |
| 49 | + CHECKOUT_TOKEN: ${{ secrets.REPO_CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} |
| 50 | + # Secrets will be available only to zama-ai organization members |
| 51 | + SECRETS_AVAILABLE: ${{ secrets.JOB_SECRET != '' }} |
| 52 | + EXTERNAL_CONTRIBUTION_RUNNER: "large_ubuntu_16" |
| 53 | + |
| 54 | +permissions: |
| 55 | + contents: read |
8 | 56 |
|
9 | 57 | jobs: |
10 | | - placeholder: |
11 | | - name: placeholder_workflow/placeholder |
| 58 | + setup-instance: |
| 59 | + name: cargo_build_common/setup-instance |
12 | 60 | runs-on: ubuntu-latest |
| 61 | + outputs: |
| 62 | + runner-name: ${{ steps.start-remote-instance.outputs.label || steps.start-github-instance.outputs.runner_group }} |
| 63 | + steps: |
| 64 | + - name: Start remote instance |
| 65 | + id: start-remote-instance |
| 66 | + if: env.SECRETS_AVAILABLE == 'true' |
| 67 | + uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac |
| 68 | + with: |
| 69 | + mode: start |
| 70 | + github-token: ${{ secrets.SLAB_ACTION_TOKEN }} |
| 71 | + slab-url: ${{ secrets.SLAB_BASE_URL }} |
| 72 | + job-secret: ${{ secrets.JOB_SECRET }} |
| 73 | + backend: aws |
| 74 | + profile: cpu-build |
| 75 | + |
| 76 | + # This instance will be spawned especially for pull-request from forked repository |
| 77 | + - name: Start GitHub instance |
| 78 | + id: start-github-instance |
| 79 | + if: env.SECRETS_AVAILABLE == 'false' |
| 80 | + run: | |
| 81 | + echo "runner_group=${EXTERNAL_CONTRIBUTION_RUNNER}" >> "$GITHUB_OUTPUT" |
| 82 | +
|
| 83 | + prepare-matrix: |
| 84 | + name: cargo_build_common/prepare-matrix |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: setup-instance |
| 87 | + outputs: |
| 88 | + runners: ${{ steps.set_matrix_runners.outputs.runners }} |
| 89 | + steps: |
| 90 | + - name: Parse runners |
| 91 | + shell: python |
| 92 | + run: | # zizmor: ignore[template-injection] these env variables are safe |
| 93 | + runners = ["${{ needs.setup-instance.outputs.runner-name }}", ] |
| 94 | + if "${{ inputs.runners-to-use }}": |
| 95 | + split_runners = "${{ inputs.runners-to-use }}".replace(" ", "").split(",") |
| 96 | + runners.extend(split_runners) |
| 97 | + |
| 98 | + with open("${{ github.env }}", "a") as f: |
| 99 | + f.write(f"""RUNNERS=["{'", "'.join(runners)}"]\n""") |
| 100 | +
|
| 101 | + - name: Set martix runners outputs |
| 102 | + id: set_matrix_runners |
| 103 | + run: | # zizmor: ignore[template-injection] these env variable are safe |
| 104 | + echo "runners=${{ toJSON(env.RUNNERS) }}" >> "${GITHUB_OUTPUT}" |
13 | 105 |
|
| 106 | + builds: |
| 107 | + name: cargo_build_common/builds |
| 108 | + needs: [ setup-instance, prepare-matrix ] |
| 109 | + runs-on: ${{ matrix.runner }} |
| 110 | + strategy: |
| 111 | + matrix: |
| 112 | + runner: ${{ fromJSON(needs.prepare-matrix.outputs.runners) }} |
| 113 | + fail-fast: false |
14 | 114 | steps: |
15 | | - - run: | |
16 | | - echo "Hello this is a Placeholder Workflow" |
| 115 | + - name: Checkout tfhe-rs repo |
| 116 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 |
| 117 | + with: |
| 118 | + persist-credentials: 'false' |
| 119 | + token: ${{ env.CHECKOUT_TOKEN }} |
| 120 | + |
| 121 | + - name: Install latest stable |
| 122 | + uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # zizmor: ignore[stale-action-refs] this action doesn't create releases |
| 123 | + with: |
| 124 | + toolchain: stable |
| 125 | + |
| 126 | + - name: Run pcc checks batch |
| 127 | + if: inputs.run-pcc-cpu-batch |
| 128 | + run: | |
| 129 | + make "${COMMAND}" |
| 130 | + env: |
| 131 | + COMMAND: ${{ inputs.run-pcc-cpu-batch }} |
| 132 | + |
| 133 | + - name: Run Hpu pcc checks |
| 134 | + if: inputs.run-pcc-hpu |
| 135 | + run: | |
| 136 | + make pcc_hpu |
| 137 | +
|
| 138 | + - name: Build Release tfhe full |
| 139 | + if: inputs.run-build-tfhe-full |
| 140 | + run: | |
| 141 | + make build_tfhe_full |
| 142 | +
|
| 143 | + - name: Install and run newline linter checks |
| 144 | + if: inputs.run-build |
| 145 | + run: | |
| 146 | + wget https://github.com/fernandrone/linelint/releases/download/0.0.6/linelint-linux-amd64 |
| 147 | + echo "16b70fb7b471d6f95cbdc0b4e5dc2b0ac9e84ba9ecdc488f7bdf13df823aca4b linelint-linux-amd64" > checksum |
| 148 | + sha256sum -c checksum || exit 1 |
| 149 | + chmod +x linelint-linux-amd64 |
| 150 | + mv linelint-linux-amd64 /usr/local/bin/linelint |
| 151 | + make check_newline |
| 152 | +
|
| 153 | + - name: Build tfhe-csprng |
| 154 | + if: inputs.run-build |
| 155 | + run: | |
| 156 | + make build_tfhe_csprng |
| 157 | +
|
| 158 | + - name: Build with MSRV |
| 159 | + if: inputs.run-build |
| 160 | + run: | |
| 161 | + make build_tfhe_msrv |
| 162 | +
|
| 163 | + - name: Build coverage tests |
| 164 | + if: inputs.run-build |
| 165 | + run: | |
| 166 | + make build_tfhe_coverage |
| 167 | +
|
| 168 | + - name: Build Release core |
| 169 | + if: inputs.run-build-layers |
| 170 | + run: | |
| 171 | + make build_core AVX512_SUPPORT=ON |
| 172 | + make build_core_experimental AVX512_SUPPORT=ON |
| 173 | +
|
| 174 | + - name: Build Release boolean |
| 175 | + if: inputs.run-build-layers |
| 176 | + run: | |
| 177 | + make build_boolean |
| 178 | +
|
| 179 | + - name: Build Release shortint |
| 180 | + if: inputs.run-build-layers |
| 181 | + run: | |
| 182 | + make build_shortint |
| 183 | +
|
| 184 | + - name: Build Release integer |
| 185 | + if: inputs.run-build-layers |
| 186 | + run: | |
| 187 | + make build_integer |
| 188 | +
|
| 189 | + - name: Build Release c_api |
| 190 | + if: inputs.run-build-c-api |
| 191 | + run: | |
| 192 | + make build_c_api |
| 193 | +
|
| 194 | + # The wasm build check is a bit annoying to set-up here and is done during the tests in |
| 195 | + # aws_tfhe_tests.yml |
| 196 | + |
| 197 | + teardown-instance: |
| 198 | + name: cargo_build_common/teardown-instance |
| 199 | + if: ${{ always() && needs.setup-instance.result == 'success' }} |
| 200 | + needs: [setup-instance, builds] |
| 201 | + runs-on: ubuntu-latest |
| 202 | + steps: |
| 203 | + - name: Stop remote instance |
| 204 | + id: stop-instance |
| 205 | + if: env.SECRETS_AVAILABLE == 'true' |
| 206 | + uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac |
| 207 | + with: |
| 208 | + mode: stop |
| 209 | + github-token: ${{ secrets.SLAB_ACTION_TOKEN }} |
| 210 | + slab-url: ${{ secrets.SLAB_BASE_URL }} |
| 211 | + job-secret: ${{ secrets.JOB_SECRET }} |
| 212 | + label: ${{ needs.setup-instance.outputs.runner-name }} |
| 213 | + |
| 214 | + - name: Slack Notification |
| 215 | + if: ${{ failure() }} |
| 216 | + continue-on-error: true |
| 217 | + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 |
| 218 | + env: |
| 219 | + SLACK_COLOR: ${{ job.status }} |
| 220 | + SLACK_MESSAGE: "Instance teardown (cargo-builds) finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" |
0 commit comments