Skip to content

Commit ecaa1a3

Browse files
committed
chore(ci): workflow trick
1 parent 0f31b1b commit ecaa1a3

File tree

1 file changed

+165
-6
lines changed

1 file changed

+165
-6
lines changed
Lines changed: 165 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,173 @@
1-
# Placeholder workflow file allowing running it without having to merge to main first
2-
name: Placeholder Workflow
1+
# Run benchmarks of the tfhe-zk-pok crate on an instance and return parsed results to Slab CI bot.
2+
name: tfhe-zk-pok benchmarks
33

44
on:
55
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
schedule:
10+
# Weekly benchmarks will be triggered each Saturday at 3a.m.
11+
- cron: '0 3 * * 6'
12+
env:
13+
CARGO_TERM_COLOR: always
14+
RESULTS_FILENAME: parsed_benchmark_results_${{ github.sha }}.json
15+
PARSE_INTEGER_BENCH_CSV_FILE: tfhe_rs_integer_benches_${{ github.sha }}.csv
16+
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
17+
RUST_BACKTRACE: "full"
18+
RUST_MIN_STACK: "8388608"
19+
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
20+
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png
21+
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
22+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
623

724
jobs:
8-
placeholder:
9-
name: Placeholder
25+
should-run:
1026
runs-on: ubuntu-latest
27+
if: github.event_name == 'workflow_dispatch' ||
28+
((github.event_name == 'push' || github.event_name == 'schedule') && github.repository == 'zama-ai/tfhe-rs')
29+
outputs:
30+
zk_pok_changed: ${{ steps.changed-files.outputs.zk_pok_any_changed }}
31+
steps:
32+
- name: Checkout tfhe-rs
33+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Check for file changes
38+
id: changed-files
39+
uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c
40+
with:
41+
since_last_remote_commit: true
42+
files_yaml: |
43+
zk_pok:
44+
- tfhe-zk-pok/**
45+
- .github/workflows/benchmark_tfhe_zk_pok.yml
46+
47+
setup-instance:
48+
name: Setup instance (tfhe-zk-pok-benchmarks)
49+
runs-on: ubuntu-latest
50+
needs: should-run
51+
if: github.event_name == 'workflow_dispatch' ||
52+
(github.event_name == 'schedule' && github.repository == 'zama-ai/tfhe-rs') ||
53+
(github.event_name == 'push' &&
54+
github.repository == 'zama-ai/tfhe-rs' &&
55+
needs.should-run.outputs.zk_pok_changed == 'true')
56+
outputs:
57+
runner-name: ${{ steps.start-instance.outputs.label }}
58+
steps:
59+
- name: Start instance
60+
id: start-instance
61+
uses: zama-ai/slab-github-runner@801df0b8db5ea2b06128b7476c652f5ed5f193a8
62+
with:
63+
mode: start
64+
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
65+
slab-url: ${{ secrets.SLAB_BASE_URL }}
66+
job-secret: ${{ secrets.JOB_SECRET }}
67+
backend: aws
68+
profile: bench
69+
70+
tfhe-zk-pok-benchmarks:
71+
name: Execute tfhe-zk-pok benchmarks
72+
if: needs.setup-instance.result != 'skipped'
73+
needs: setup-instance
74+
concurrency:
75+
group: ${{ github.workflow }}_${{github.event_name}}_${{ github.ref }}${{ github.ref == 'refs/heads/main' && github.sha || '' }}
76+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
77+
runs-on: ${{ needs.setup-instance.outputs.runner-name }}
78+
steps:
79+
- name: Checkout tfhe-rs repo with tags
80+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
81+
with:
82+
fetch-depth: 0
83+
token: ${{ secrets.FHE_ACTIONS_TOKEN }}
84+
85+
- name: Get benchmark details
86+
run: |
87+
{
88+
echo "BENCH_DATE=$(date --iso-8601=seconds)";
89+
echo "COMMIT_DATE=$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})";
90+
echo "COMMIT_HASH=$(git describe --tags --dirty)";
91+
} >> "${GITHUB_ENV}"
92+
93+
- name: Install rust
94+
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a
95+
with:
96+
toolchain: nightly
1197

98+
- name: Checkout Slab repo
99+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
100+
with:
101+
repository: zama-ai/slab
102+
path: slab
103+
token: ${{ secrets.FHE_ACTIONS_TOKEN }}
104+
105+
- name: Run benchmarks with AVX512
106+
run: |
107+
make bench_tfhe_zk_pok
108+
109+
- name: Parse results
110+
run: |
111+
python3 ./ci/benchmark_parser.py target/criterion ${{ env.RESULTS_FILENAME }} \
112+
--database tfhe_rs \
113+
--crate tfhe-zk-pok \
114+
--hardware "hpc7a.96xlarge" \
115+
--backend cpu \
116+
--project-version "${{ env.COMMIT_HASH }}" \
117+
--branch ${{ github.ref_name }} \
118+
--commit-date "${{ env.COMMIT_DATE }}" \
119+
--bench-date "${{ env.BENCH_DATE }}" \
120+
--walk-subdirs \
121+
--name-suffix avx512 \
122+
--throughput
123+
124+
- name: Upload parsed results artifact
125+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
126+
with:
127+
name: ${{ github.sha }}_tfhe_zk_pok
128+
path: ${{ env.RESULTS_FILENAME }}
129+
130+
- name: Checkout Slab repo
131+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
132+
with:
133+
repository: zama-ai/slab
134+
path: slab
135+
token: ${{ secrets.FHE_ACTIONS_TOKEN }}
136+
137+
- name: Send data to Slab
138+
shell: bash
139+
run: |
140+
python3 slab/scripts/data_sender.py ${{ env.RESULTS_FILENAME }} "${{ secrets.JOB_SECRET }}" \
141+
--slab-url "${{ secrets.SLAB_URL }}"
142+
143+
- name: Slack Notification
144+
if: ${{ failure() }}
145+
continue-on-error: true
146+
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990
147+
env:
148+
SLACK_COLOR: ${{ job.status }}
149+
SLACK_MESSAGE: "tfhe-zk-pok benchmarks finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"
150+
151+
teardown-instance:
152+
name: Teardown instance (tfhe-zk-pok-benchmarks)
153+
if: ${{ always() && needs.setup-instance.result != 'skipped' }}
154+
needs: [ setup-instance, tfhe-zk-pok-benchmarks ]
155+
runs-on: ubuntu-latest
12156
steps:
13-
- run: |
14-
echo "Hello this is a Placeholder Workflow"
157+
- name: Stop instance
158+
id: stop-instance
159+
uses: zama-ai/slab-github-runner@801df0b8db5ea2b06128b7476c652f5ed5f193a8
160+
with:
161+
mode: stop
162+
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
163+
slab-url: ${{ secrets.SLAB_BASE_URL }}
164+
job-secret: ${{ secrets.JOB_SECRET }}
165+
label: ${{ needs.setup-instance.outputs.runner-name }}
166+
167+
- name: Slack Notification
168+
if: ${{ failure() }}
169+
continue-on-error: true
170+
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990
171+
env:
172+
SLACK_COLOR: ${{ job.status }}
173+
SLACK_MESSAGE: "Instance teardown (tfhe-zk-pok-benchmarks) finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"

0 commit comments

Comments
 (0)