@@ -164,28 +164,32 @@ jobs:
164164 continue-on-error : true
165165 defaults :
166166 run :
167- working-directory : /home/runner/work/openflexure-microscope-server/
168- steps :
167+ working-directory : ../openflexure-microscope-server/
168+ env :
169+ REF : v3
170+ steps : &test-against-ofm-steps
169171 - uses : actions/checkout@v3
170172
171- - name : Set up Python
172- uses : actions/setup-python@v4
173+ - uses : actions/setup-python@v4
173174 with :
174- python-version : 3.11
175+ python-version : ' 3.11'
175176
176- - name : Install OpenFlexure Microscope Server
177- working-directory : /home/runner/work/
177+ - name : Clone OpenFlexure Microscope Server
178+ working-directory : .. # This step creates the default working directory
178179 run : |
179180 git clone https://gitlab.com/openflexure/openflexure-microscope-server.git
180- cd openflexure-microscope-server
181- git checkout v3
182- pip install -e .[dev]
181+
182+ - name : Check out OpenFlexure Microscope Server
183+ run : " git checkout $REF"
184+
185+ - name : Install OpenFlexure Microscope Server
186+ run : " pip install -e ../openflexure-microscope-server/[dev]"
183187
184188 - name : Install LabThings-FastAPI
185- run : pip install -e ../labthings-fastapi/labthings-fastapi/
189+ run : " pip install -e ../labthings-fastapi"
186190
187191 - name : Print installed packages
188- run : pip freeze
192+ run : " pip freeze"
189193
190194 - name : Configure Git identity
191195 run : |
@@ -207,65 +211,40 @@ jobs:
207211 - name : Type check with `mypy`
208212 run : mypy src
209213
210- test-against -ofm-feature-branch :
214+ check-for -ofm-feature-branch :
211215 # This job runs only if a feature branch is specified in the merge request description.
212216 # The line below looks for a line starting with `OFM Feature Branch:`. This should
213- # match the `grep` command in the relevant step.
217+ # match the `grep` command in the step script .
214218 if : contains(toJson(github.event.pull_request.body), '\r\nOFM Feature Branch:')
215219 runs-on : ubuntu-latest
216- continue-on-error : true
217- defaults :
218- run :
219- working-directory : /home/runner/work/openflexure-microscope-server/
220+ outputs :
221+ feature-branch : ${{ steps.determine-feature-branch.outputs.feature-branch}}
220222 steps :
221- - uses : actions/checkout@v3
222-
223- - name : Set up Python
224- uses : actions/setup-python@v4
225- with :
226- python-version : 3.11
227-
228- - name : Clone OpenFlexure Microscope Server
229- working-directory : /home/runner/work/
230- run : git clone https://gitlab.com/openflexure/openflexure-microscope-server.git
231-
232- - name : Checkout feature branch
223+ - name : Determine feature branch
233224 env :
234225 PULL_REQUEST_BODY : ${{ github.event.pull_request.body }}
235226 # The `if:` block for this job has already checked we will have a matching line.
236227 # The logic below will first extract the matching line from the PR description,
237228 # then remove the prefix so we're left with only the branch name, which we check
238229 # out.
239230 run : |
240- matching_line=$(echo "${ PULL_REQUEST_BODY} " | grep "^OFM Feature Branch:")
231+ matching_line=$(echo "$PULL_REQUEST_BODY" | grep "^OFM Feature Branch:")
241232 feature_branch="${matching_line##"OFM Feature Branch: "}"
242- git checkout "${feature_branch}"
243-
244- - name : Install OpenFlexure Microscope Server
245- run : pip install -e .[dev]
246-
247- - name : Install LabThings-FastAPI
248- run : pip install -e ../labthings-fastapi/labthings-fastapi/
249-
250- - name : Print installed packages
251- run : pip freeze
252-
253- - name : Configure Git identity
254- run : |
255- git config --global user.name "Sir Unit of Test"
256- git config --global user.email "bogus@email.com"
257-
258- - name : Pull OFM web app
259- run : python ./pull_webapp.py
260-
261- - name : Run OFM unit tests
262- run : pytest
263-
264- - name : Run OFM integration tests
265- run : pytest tests/integration_tests
233+ echo "Using feature branch '$feature_branch'"
234+ echo "feature-branch=$feature_branch" >> "$GITHUB_OUTPUT"
235+ id : determine-feature-branch
236+
237+ test-against-ofm-feature-branch :
238+ # This job uses the feature branch found by the previous job.
239+ # It is split from that job in order to allow re-use of the steps from
240+ # test-against-ofm-v3
241+ needs : check-for-ofm-feature-branch
242+ runs-on : ubuntu-latest
243+ continue-on-error : true
244+ defaults :
245+ run :
246+ working-directory : ../openflexure-microscope-server/
247+ env :
248+ REF : needs.check-for-ofm-feature-branch.outputs.feature-branch
249+ steps : *test-against-ofm-steps
266250
267- - name : Run OFM lifecycle test
268- run : tests/lifecycle_test/testfile.py
269-
270- - name : Type check with `mypy`
271- run : mypy src
0 commit comments