@@ -3,14 +3,6 @@ name: Analyses Snapshot Test
3
3
on :
4
4
workflow_dispatch :
5
5
inputs :
6
- ANALYSIS_REF :
7
- description : ' Branch or tag that provides the analysis output at test runtime'
8
- required : true
9
- default : ' edge'
10
- SNAPSHOT_REF :
11
- description : ' Branch or tag that provides the snapshot and test code at test runtime'
12
- required : true
13
- default : ' edge'
14
6
OPEN_PR_ON_FAILURE :
15
7
description : ' If the test fails, open a PR to update the snapshots'
16
8
type : boolean
@@ -41,67 +33,131 @@ concurrency:
41
33
cancel-in-progress : true
42
34
43
35
jobs :
44
- build-and-test :
45
- timeout-minutes : 15
36
+ collect-chunks :
37
+ timeout-minutes : 2
46
38
runs-on : ubuntu-latest
47
- env :
48
- BASE_IMAGE_NAME : opentrons-python-base:3.10
49
- ANALYSIS_REF : ${{ github.event.inputs.ANALYSIS_REF || github.head_ref || 'edge' }}
50
- SNAPSHOT_REF : ${{ github.event.inputs.SNAPSHOT_REF || github.head_ref || 'edge' }}
51
- # If we're running because of workflow_dispatch, use the user input to decide
52
- # whether to open a PR on failure. Otherwise, there is no user input,
53
- # so we only open a PR if the PR has the label 'gen-analyses-snapshot-pr'
54
- OPEN_PR_ON_FAILURE : ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.OPEN_PR_ON_FAILURE) || ((github.event_name != 'workflow_dispatch') && (contains(github.event.pull_request.labels.*.name, 'gen-analyses-snapshot-pr'))) }}
55
- PR_TARGET_BRANCH : ${{ github.event.pull_request.base.ref || 'not a pr'}}
39
+ outputs :
40
+ matrix_json : ${{ steps.set-matrix.outputs.json }}
56
41
steps :
57
42
- name : Checkout Repository
58
43
uses : actions/checkout@v4
44
+ - name : Setup UV
45
+ uses : astral-sh/setup-uv@v6
59
46
with :
60
- ref : ${{ env.SNAPSHOT_REF }}
61
-
47
+ python-version : ' 3.10'
48
+ enable-cache : true
49
+ cache-dependency-glob : ' ./analyses-snapshot-testing/uv.lock'
50
+ - name : Sync the project
51
+ working-directory : ./analyses-snapshot-testing
52
+ run : make ci-setup
53
+ - name : Generate Chunks
54
+ working-directory : ./analyses-snapshot-testing
55
+ run : make gen-chunks
56
+ - name : Save Chunks
57
+ uses : actions/upload-artifact@v4
58
+ with :
59
+ name : chunks
60
+ path : analyses-snapshot-testing/chunks/
61
+ - name : Set Matrix
62
+ id : set-matrix
63
+ run : echo "json=$(jq -c . analyses-snapshot-testing/chunks/matrix.json)" >> $GITHUB_OUTPUT
64
+ diff-from-target-branch :
65
+ timeout-minutes : 2
66
+ runs-on : ubuntu-latest
67
+ if : github.event_name == 'pull_request'
68
+ steps :
69
+ - name : Checkout Repository
70
+ uses : actions/checkout@v4
62
71
- name : Are the analyses snapshots in my PR branch in sync with the target branch?
63
72
if : github.event_name == 'pull_request'
64
73
run : |
65
- git fetch origin ${{ env.PR_TARGET_BRANCH }}
66
- DIFF_OUTPUT=$(git diff HEAD origin/${{ env.PR_TARGET_BRANCH }} -- analyses-snapshot-testing/tests/__snapshots__/analyses_snapshot_test)
74
+ git fetch origin ${{ github.event.pull_request.base.ref }}
75
+ DIFF_OUTPUT=$(git diff HEAD origin/${{ github.event.pull_request.base.ref }} -- analyses-snapshot-testing/tests/__snapshots__/analyses_snapshot_test)
67
76
if [ -n "$DIFF_OUTPUT" ]; then
68
- echo "Analyses snapshots do NOT match ${{ env.PR_TARGET_BRANCH }} snapshots."
69
- echo "Is this becasue you have not pulled and merged ${{ env.PR_TARGET_BRANCH }}?"
70
- echo "Or is this because you have already updated your snapshots and are all good 😊?"
77
+ echo "## Analyses Snapshot Diff Check" >> $GITHUB_STEP_SUMMARY
78
+ echo "" >> $GITHUB_STEP_SUMMARY
79
+ echo "- :x: Analyses snapshots do **NOT** match \`${{ github.event.pull_request.base.ref }}\` snapshots." >> $GITHUB_STEP_SUMMARY
80
+ echo "" >> $GITHUB_STEP_SUMMARY
81
+ echo " - Is this because you have not pulled and merged \`${{ github.event.pull_request.base.ref }}\`?" >> $GITHUB_STEP_SUMMARY
82
+ echo " - Or is this because you have already updated your snapshots and are all good 😊?" >> $GITHUB_STEP_SUMMARY
71
83
else
72
- echo "Analyses snapshots match ${{ env.PR_TARGET_BRANCH }} snapshots."
84
+ echo "## Analyses Snapshot Diff Check" >> $GITHUB_STEP_SUMMARY
85
+ echo "" >> $GITHUB_STEP_SUMMARY
86
+ echo ":white_check_mark: **Analyses snapshots match \`${{ github.event.pull_request.base.ref }}\` snapshots.**" >> $GITHUB_STEP_SUMMARY
73
87
fi
74
88
75
- - name : Set up Docker Buildx
76
- uses : docker/setup-buildx-action@v3
77
-
78
- - name : Build base image
79
- id : build_base_image
80
- uses : docker/build-push-action@v6
89
+ process-chunk :
90
+ timeout-minutes : 5
91
+ needs : collect-chunks
92
+ strategy :
93
+ matrix :
94
+ chunk : ${{ fromJson(needs.collect-chunks.outputs.matrix_json) }}
95
+ runs-on : ubuntu-latest
96
+ steps :
97
+ - name : Checkout Repository
98
+ uses : actions/checkout@v4
99
+ - name : Setup UV
100
+ uses : astral-sh/setup-uv@v6
81
101
with :
82
- context : analyses-snapshot-testing/citools
83
- file : analyses-snapshot-testing/citools/Dockerfile.base
84
- push : false
85
- load : true
86
- tags : ${{ env.BASE_IMAGE_NAME }}
87
- cache-from : type=gha
88
- cache-to : type=gha,mode=max
89
-
90
- - name : Build analysis image
91
- working-directory : analyses-snapshot-testing
92
- run : make build-opentrons-analysis BASE_IMAGE_NAME=${{ env.BASE_IMAGE_NAME }} ANALYSIS_REF=${{ env.ANALYSIS_REF }} CACHEBUST=${{ github.run_number }}
93
-
94
- - name : Set up Python 3.13
95
- uses : actions/setup-python@v5
102
+ python-version : ' 3.10'
103
+ enable-cache : true
104
+ cache-dependency-glob : ' ./analyses-snapshot-testing/uv.lock'
105
+ - name : Sync the project
106
+ working-directory : ./analyses-snapshot-testing
107
+ run : make ci-setup
108
+ - name : Install Opentrons
109
+ working-directory : ./analyses-snapshot-testing
110
+ run : make install-ot
111
+ - uses : actions/download-artifact@v4
96
112
with :
97
- python-version : ' 3.13.0'
98
- cache : ' pipenv'
99
- cache-dependency-path : analyses-snapshot-testing/Pipfile.lock
100
-
101
- - name : Setup Python Dependencies
102
- working-directory : analyses-snapshot-testing
103
- run : make setup
104
-
113
+ name : chunks
114
+ path : analyses-snapshot-testing/chunks/
115
+ - name : Generate Analyses from Chunk
116
+ working-directory : ./analyses-snapshot-testing
117
+ run : make analyze-chunk CHUNK=${{ matrix.chunk.chunk_id }}
118
+ - name : Upload Analysis Results
119
+ uses : actions/upload-artifact@v4
120
+ with :
121
+ # Each chunk uploads its files as one artifact named after the chunk
122
+ name : analysis-results-${{ matrix.chunk.chunk_id }}.zip
123
+ path : analyses-snapshot-testing/analysis_results/*
124
+ if-no-files-found : error
125
+
126
+ execute-tests :
127
+ timeout-minutes : 5
128
+ needs : process-chunk
129
+ runs-on : ubuntu-latest
130
+ env :
131
+ # If we're running because of workflow_dispatch, use the user input to decide
132
+ # whether to open a PR on failure. Otherwise, there is no user input,
133
+ # so we only open a PR if the PR has the label 'gen-analyses-snapshot-pr'
134
+ OPEN_PR_ON_FAILURE : ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.OPEN_PR_ON_FAILURE) || ((github.event_name != 'workflow_dispatch') && (contains(github.event.pull_request.labels.*.name, 'gen-analyses-snapshot-pr'))) }}
135
+ PR_TARGET_BRANCH : ${{ github.event.pull_request.base.ref || 'edge'}}
136
+ steps :
137
+ - name : Checkout Repository
138
+ uses : actions/checkout@v4
139
+ - name : Setup UV
140
+ uses : astral-sh/setup-uv@v6
141
+ with :
142
+ python-version : ' 3.10'
143
+ enable-cache : true
144
+ cache-dependency-glob : ' ./analyses-snapshot-testing/uv.lock'
145
+ - name : Sync the project
146
+ working-directory : ./analyses-snapshot-testing
147
+ run : make ci-setup
148
+ - name : Install Opentrons
149
+ working-directory : ./analyses-snapshot-testing
150
+ run : make install-ot
151
+ - name : Download All Analysis Results
152
+ uses : actions/download-artifact@v4
153
+ with :
154
+ pattern : analysis-results-*
155
+ path : all_analysis_results
156
+ - name : Consolidate Analysis Results
157
+ run : |
158
+ find all_analysis_results -type f -exec cp {} analyses-snapshot-testing/analysis_results/ \;
159
+ - name : List All Gathered Files (for debug)
160
+ run : ls -lh analyses-snapshot-testing/analysis_results/
105
161
- name : Run Test
106
162
id : run_test
107
163
working-directory : analyses-snapshot-testing
@@ -131,10 +187,10 @@ jobs:
131
187
uses : peter-evans/create-pull-request@v7
132
188
with :
133
189
commit-message : ' fix(analyses-snapshot-testing): heal analyses snapshots'
134
- title : ' fix(analyses-snapshot-testing): heal ${{ env.ANALYSIS_REF }} snapshots'
190
+ title : ' fix(analyses-snapshot-testing): heal ${{ github.event.pull_request.head.ref }} snapshots'
135
191
body : ' This PR was requested on the PR https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
136
- branch : ' analyses-snapshot-testing/${{ env.ANALYSIS_REF }}-from- ${{ env.SNAPSHOT_REF }}'
137
- base : ${{ env.SNAPSHOT_REF }}
192
+ branch : ' analyses-snapshot-testing/heal- ${{ github.event.pull_request.head.ref }}'
193
+ base : ${{ github.event.pull_request.base.ref }}
138
194
139
195
- name : Comment on feature PR
140
196
if : always() && steps.create_pull_request.outcome == 'success' && github.event_name == 'pull_request'
@@ -152,9 +208,9 @@ jobs:
152
208
- name : Create Snapshot update Request on edge overnight failure
153
209
if : always() && steps.handle_failure.outcome == 'success' && github.event_name == 'schedule'
154
210
uses : peter-evans/create-pull-request@v7
155
- with : # scheduled run uses the default values for ANALYSIS_REF and SNAPSHOT_REF which are edge
156
- commit-message : ' fix(analyses-snapshot-testing): heal ${{ env.ANALYSIS_REF }} snapshots'
157
- title : ' fix(analyses-snapshot-testing): heal ${{ env.ANALYSIS_REF }} snapshots'
158
- body : ' The ${{ env.ANALYSIS_REF }} overnight analyses snapshot test is failing. This PR was opened to alert us to the failure.'
159
- branch : ' analyses-snapshot-testing/${{ env.ANALYSIS_REF }}-from-${{ env.SNAPSHOT_REF }} '
160
- base : ${{ env.SNAPSHOT_REF }}
211
+ with :
212
+ commit-message : ' fix(analyses-snapshot-testing): heal edge snapshots'
213
+ title : ' fix(analyses-snapshot-testing): heal edge snapshots'
214
+ body : ' The edge overnight analyses snapshot test is failing. This PR was opened to alert us to the failure.'
215
+ branch : ' analyses-snapshot-testing/heal-edge '
216
+ base : edge
0 commit comments