Skip to content

Commit 2083203

Browse files
committed
chore(ci): print out parameters check analysis duration
The workflow might succeed even if it doesn't scan any parameters set or a smaller one. In this case the analysis duration would be much lower than usual. As being sent to a Slack channel, this improved message would warn maintainers about a potential issue.
1 parent 3ccaa0a commit 2083203

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.github/workflows/parameters_check.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,35 @@ jobs:
7676
run: |
7777
CARGO_PROFILE=devo make write_params_to_file
7878
79+
- name: Get start time
80+
if: ${{ always() }}
81+
id: start-time
82+
run: |
83+
echo "value=$(date +%s)" >> $GITHUB_OUTPUT
84+
7985
- name: Perform security check
8086
run: |
8187
PYTHONPATH=lattice_estimator sage ci/lattice_estimator.sage
8288
89+
- name: Get time elapsed
90+
if: ${{ always() }}
91+
shell: python
92+
env:
93+
START_DATE: ${{ steps.start-time.outputs.value }}
94+
run: |
95+
import datetime
96+
import math
97+
import os
98+
99+
env_file = os.environ["GITHUB_ENV"]
100+
101+
start_date = datetime.datetime.fromtimestamp(int(os.environ["START_DATE"]))
102+
end_date = datetime.datetime.now()
103+
total_minutes = math.floor((end_date - start_date).total_seconds() / 60)
104+
105+
with open(env_file, "a") as f:
106+
f.write(f"TIME_ELAPSED={total_minutes}\n")
107+
83108
- name: Slack Notification
84109
if: ${{ always() }}
85110
continue-on-error: true
@@ -88,7 +113,7 @@ jobs:
88113
SLACK_COLOR: ${{ job.status }}
89114
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
90115
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png
91-
SLACK_MESSAGE: "Security check for parameters finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"
116+
SLACK_MESSAGE: "Security check for parameters finished with status: ${{ job.status }} (analysis took: ${{ env.TIME_ELAPSED }} mins). (${{ env.ACTION_RUN_URL }})"
92117
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
93118
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
94119

0 commit comments

Comments
 (0)