forked from zeta-chain/node
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (146 loc) · 6.34 KB
/
sim.yml
File metadata and controls
159 lines (146 loc) · 6.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: sim
on:
push:
branches:
- develop
- release/**
pull_request:
types: [opened, synchronize, labeled]
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
make-targets:
description: 'Comma separated list of make targets to run (e.g., test-sim-nondeterminism, test-sim-fullappsimulation)'
required: true
default: 'test-sim-nondeterminism'
concurrency:
group: simulation-${{ github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
changed-files:
runs-on: ubuntu-22.04
outputs:
relevant_changed: ${{ steps.relevant-changes.outputs.any_changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files in relevant directories
id: relevant-changes
uses: zeta-chain/gh-action-changed-files@9200e69727eb73eb060652b19946b8a2fdfb654b
with:
files: |
x/**
app/**
cmd/**
matrix-conditionals:
needs: changed-files
runs-on: ubuntu-22.04
outputs:
SIM_TEST_NOND: ${{ steps.matrix-conditionals.outputs.SIM_TEST_NOND }}
SIM_TEST_FULL: ${{ steps.matrix-conditionals.outputs.SIM_TEST_FULL }}
SIM_TEST_IMPORT_EXPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT }}
SIM_TEST_AFTER_IMPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT }}
steps:
- id: matrix-conditionals
uses: actions/github-script@v7
with:
script: |
const defaultTargets = ['test-sim-nondeterminism', 'test-sim-fullappsimulation', 'test-sim-import-export', 'test-sim-after-import'];
let makeTargets = [];
if (context.eventName === 'pull_request') {
const changedFiles = ${{ needs.changed-files.outputs.relevant_changed }};
const pull_number = context.payload.pull_request.number;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
});
const labels = pr.labels.map(label => label.name);
console.log(`labels for ${pull_number}:`, labels);
console.log(`changedFiles for ${pull_number}:`, changedFiles);
if (changedFiles || labels.includes('SIM_TESTS')) {
makeTargets = defaultTargets;
}
} else if (context.eventName === 'schedule') {
makeTargets = defaultTargets;
} else {
const makeTargetsInput = context.payload.inputs ? context.payload.inputs['make-targets'] : null;
makeTargets = makeTargetsInput ? makeTargetsInput.split(',') : defaultTargets;
}
console.log('makeTargets: ', makeTargets);
core.setOutput('SIM_TEST_NOND', makeTargets.includes('test-sim-nondeterminism'));
core.setOutput('SIM_TEST_FULL', makeTargets.includes('test-sim-fullappsimulation'));
core.setOutput('SIM_TEST_IMPORT_EXPORT', makeTargets.includes('test-sim-import-export'));
core.setOutput('SIM_TEST_AFTER_IMPORT', makeTargets.includes('test-sim-after-import'));
simulation-tests:
needs:
- matrix-conditionals
strategy:
fail-fast: false
matrix:
include:
- make-target: "test-sim-nondeterminism"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_NOND == 'true' }}
- make-target: "test-sim-fullappsimulation"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_FULL == 'true' }}
- make-target: "test-sim-import-export"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT == 'true' }}
- make-target: "test-sim-after-import"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT == 'true' }}
name: ${{ matrix.make-target }}
uses: ./.github/workflows/reusable-sim.yml
with:
make-target: ${{ matrix.make-target }}
run: ${{ matrix.run }}
sim-ok:
runs-on: ubuntu-22.04
needs:
- simulation-tests
if: ${{ !cancelled() }}
steps:
- name: Send slack message with results
uses: actions/github-script@v7
if: ${{ github.event_name == 'schedule' || (github.event_name == 'push' && needs.simulation-tests.result == 'failure') }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CI_ALERTS }}
with:
script: |
const {data} = await github.rest.actions.listJobsForWorkflowRunAttempt({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
attempt_number: ${{ github.run_attempt }},
});
const simJobs = data.jobs.filter(job => job.name.includes('/') && job.conclusion != 'skipped');
const simResults = simJobs.map(job => {
const icon = job.conclusion === 'success' ? ':white_check_mark:' : ':x:';
const cleanName = job.name.split("/")[0];
return `${icon} ${cleanName}`;
});
simResults.sort();
const overallResultStr = '${{ needs.simulation-tests.result }}';
const overallResultPassing = overallResultStr === 'success' || overallResultStr === 'skipped';
const overallResultIcon = overallResultPassing ? ':white_check_mark:' : ':x:';
let overallResultText = `<https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}|Simulation Test Run Results>`;
if (context.eventName === 'push') {
overallResultText += ` for push to ${context.ref}`;
} else if (context.eventName === 'schedule') {
overallResultText += ` for scheduled run`;
}
const msg = `${overallResultIcon} ${overallResultText}\n${simResults.join('\n')}`;
await fetch(process.env.SLACK_WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({text: msg}),
});
- name: Aggregate Results
run: |
result="${{ needs.simulation-tests.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi