Skip to content

Commit d44a2d9

Browse files
committed
Merge branch 'improvement/MK8S-68-use-smart-cron-trigger' into tmp/octopus/w/133.0/improvement/MK8S-68-use-smart-cron-trigger
2 parents 56cf94c + c6119ec commit d44a2d9

File tree

1 file changed

+83
-4
lines changed

1 file changed

+83
-4
lines changed

.github/workflows/crons.yaml

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,42 @@ on:
44
# NOTE: Schedule is only run on the latest commit of the default branch,
55
# so we need to schedule Cron Jobs for all branches here
66
schedule:
7+
# Daily builds, scheduled before nightlies every weekday at 22:00
8+
- cron: "0 22 * * 1-5"
9+
710
# Run V 0 nightly every weekday at 01:00
811
- cron: "0 1 * * 1-5"
912

1013
# Run V -1 nightly every weekday at 02:00
1114
- cron: "0 2 * * 1-5"
1215

16+
# Retry failed nightlies every weekday at 06:00 (4 hours after last nightly)
17+
- cron: "0 6 * * 1-5"
18+
1319
jobs:
1420
crons:
1521
runs-on: ubuntu-24.04
22+
env:
23+
MAX_RETRIES: '2'
1624
strategy:
1725
fail-fast: false
1826
matrix:
1927
include:
28+
# Daily build jobs, needed to make sure we have at least one build
29+
# on latests commits of each branch. It is especially needed because
30+
# artifacts from builds expire after 2 weeks and nightly builds fail
31+
# current=132.0
32+
- name: "Build for MetalK8s 132.0"
33+
cron: "0 22 * * 1-5"
34+
branch: "development/132.0"
35+
workflow: "build.yaml"
36+
# old=131.0
37+
- name: "Build for MetalK8s 131.0"
38+
cron: "0 22 * * 1-5"
39+
branch: "development/131.0"
40+
workflow: "build.yaml"
41+
42+
# Nightly jobs
2043
# these helper comments are needed by the dev branch workflow
2144
# please do not edit them unless you're changing the version as well
2245
# current=133.0
@@ -29,12 +52,68 @@ jobs:
2952
cron: "0 2 * * 1-5"
3053
branch: "development/132.0"
3154
workflow: "nightly.yaml"
55+
56+
# Nightly retry jobs
57+
# current=132.0
58+
- name: "Retry Nightly for MetalK8s 132.0"
59+
cron: "0 6 * * 1-5"
60+
branch: "development/132.0"
61+
workflow: "nightly.yaml"
62+
type: "retry"
63+
# old=131.0
64+
- name: "Retry Nightly for MetalK8s 131.0"
65+
cron: "0 6 * * 1-5"
66+
branch: "development/131.0"
67+
workflow: "nightly.yaml"
68+
type: "retry"
3269
steps:
3370
- name: Checkout
3471
if: github.event.schedule == matrix.cron
3572
uses: actions/checkout@v6
36-
- name: Run ${{ matrix.name }}
37-
if: github.event.schedule == matrix.cron
73+
- name: "Smart trigger for ${{ matrix.name }}"
74+
if: github.event.schedule == matrix.cron && matrix.type != 'retry'
75+
uses: scality/actions/actions-nightly-trigger@1.17.0
76+
with:
77+
branch: ${{ matrix.branch }}
78+
workflow: ${{ matrix.workflow }}
79+
access_token: ${{ secrets.GIT_ACCESS_TOKEN }}
80+
- name: "Retry workflow for ${{ matrix.name }}"
81+
id: retry
82+
if: github.event.schedule == matrix.cron && matrix.type == 'retry'
83+
uses: scality/actions/action-retry-workflow@1.17.0
84+
with:
85+
branch: ${{ matrix.branch }}
86+
workflow: ${{ matrix.workflow }}
87+
step-name: 'Spawn cluster with Terraform'
88+
max-retries: ${{ env.MAX_RETRIES }}
89+
retry-mode: 'failed-only'
90+
access_token: ${{ secrets.GITHUB_TOKEN }}
91+
- name: Notify Slack on retry triggered
92+
if: matrix.type == 'retry' && steps.retry.outputs.was-retried == 'true'
93+
uses: slackapi/slack-github-action@v1
94+
with:
95+
channel-id: '#squad-supsetup-alerts'
96+
slack-message: |
97+
Nightly retry triggered for ${{ matrix.branch }}
98+
Job: ${{ matrix.name }}
99+
Status: ${{ steps.retry.outputs.status }}
100+
Retries performed: ${{ steps.retry.outputs.retry-count }}
101+
Retried run: https://github.com/${{ github.repository }}/actions/runs/${{ steps.retry.outputs.run-id }}
102+
Cron run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
103+
env:
104+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
105+
- name: Notify Slack on manual action needed
106+
if: matrix.type == 'retry' && steps.retry.outputs.retry-count != '' && fromJSON(steps.retry.outputs.retry-count) >= fromJSON(env.MAX_RETRIES)
107+
uses: slackapi/slack-github-action@v1
108+
with:
109+
channel-id: '#squad-supsetup-alerts'
110+
slack-message: |
111+
⚠️ MANUAL ACTION REQUIRED ⚠️
112+
Nightly for ${{ matrix.branch }} failed after ${{ steps.retry.outputs.retry-count }} retry attempts
113+
Job: ${{ matrix.name }}
114+
Max retries (${{ env.MAX_RETRIES }}) exhausted - manual intervention needed
115+
Workflow: ${{ matrix.workflow }}
116+
Failed run: https://github.com/${{ github.repository }}/actions/runs/${{ steps.retry.outputs.run-id }}
117+
Cron run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
38118
env:
39-
GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
40-
run: gh workflow run ${{ matrix.workflow }} --ref=${{ matrix.branch }}
119+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 commit comments

Comments
 (0)