Skip to content

Commit 495f3ca

Browse files
Merge pull request #56 from swryan/workflow
Add a GitHub Actions test workflow
2 parents f59fcf6 + 04f0828 commit 495f3ca

File tree

1 file changed

+290
-0
lines changed

1 file changed

+290
-0
lines changed
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
# Run pyCycle Tests
2+
name: pyCycle Tests
3+
4+
on:
5+
# Trigger on push or pull request events for the master branch
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
# Allow running the workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
inputs:
15+
16+
run_name:
17+
type: string
18+
description: 'Name of workflow run as it will appear under Actions tab:'
19+
required: false
20+
default: ""
21+
22+
Ubuntu_Baseline:
23+
type: boolean
24+
description: 'Include Ubuntu Baseline test in the test matrix'
25+
required: false
26+
default: true
27+
28+
MacOS_Baseline:
29+
type: boolean
30+
description: 'Include MacOS Baseline test in the test matrix'
31+
required: false
32+
default: true
33+
34+
Windows_Baseline:
35+
type: boolean
36+
description: 'Include Windows Baseline test in the test matrix'
37+
required: false
38+
default: true
39+
40+
OpenMDAO_Dev:
41+
type: boolean
42+
description: 'Include latest/development test in the test matrix'
43+
required: false
44+
default: true
45+
46+
run-name: ${{ inputs.run_name }}
47+
48+
jobs:
49+
50+
tests:
51+
52+
timeout-minutes: 120
53+
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
include:
58+
# test baseline versions on Ubuntu
59+
- NAME: Ubuntu Baseline
60+
OS: ubuntu-latest
61+
PY: '3.12'
62+
NUMPY: '1.26'
63+
SCIPY: '1.14'
64+
OPENMDAO: 'latest'
65+
EXCLUDE: ${{ github.event_name == 'workflow_dispatch' && ! inputs.Ubuntu_Baseline }}
66+
67+
# test baseline versions on MacOS
68+
- NAME: MacOS Baseline
69+
OS: macos-latest
70+
PY: '3.12'
71+
NUMPY: '1.26'
72+
SCIPY: '1.14'
73+
OPENMDAO: 'latest'
74+
EXCLUDE: ${{ github.event_name == 'workflow_dispatch' && ! inputs.MacOS_Baseline }}
75+
76+
# test with latest/development versions
77+
# only run when selected via workflow_dispatch
78+
- NAME: OpenMDAO Dev
79+
OS: ubuntu-latest
80+
PY: 3
81+
NUMPY: 2
82+
SCIPY: 1
83+
OPENMDAO: 'dev'
84+
EXCLUDE: ${{ github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && ! inputs.OpenMDAO_Dev) }}
85+
86+
runs-on: ${{ matrix.OS }}
87+
88+
name: ${{ matrix.NAME }}
89+
90+
defaults:
91+
run:
92+
shell: bash -l {0}
93+
94+
steps:
95+
- name: Display run details
96+
run: |
97+
echo "============================================================="
98+
echo "Run #${GITHUB_RUN_NUMBER}"
99+
echo "Run ID: ${GITHUB_RUN_ID}"
100+
echo "Testing: ${GITHUB_REPOSITORY}"
101+
echo "Triggered by: ${GITHUB_EVENT_NAME}"
102+
echo "Initiated by: ${GITHUB_ACTOR}"
103+
echo "Excluded: ${{ matrix.EXCLUDE }}"
104+
echo "============================================================="
105+
106+
- name: Checkout code
107+
if: ${{ ! matrix.EXCLUDE }}
108+
uses: actions/checkout@v3
109+
110+
- name: Setup conda
111+
if: ${{ ! matrix.EXCLUDE }}
112+
uses: conda-incubator/setup-miniconda@v3
113+
with:
114+
python-version: ${{ matrix.PY }}
115+
miniforge-version: "latest"
116+
117+
- name: Install OpenMDAO
118+
if: ${{ ! matrix.EXCLUDE }}
119+
shell: bash -l {0}
120+
run: |
121+
conda install numpy=${{ matrix.NUMPY }} scipy=${{ matrix.SCIPY }} -q -y
122+
123+
python -m pip install --upgrade pip
124+
125+
echo "============================================================="
126+
echo "Install OpenMDAO"
127+
echo "============================================================="
128+
if [[ "${{ matrix.OPENMDAO }}" == "dev" ]]; then
129+
pip install git+https://github.com/OpenMDAO/OpenMDAO
130+
elif [[ "${{ matrix.OPENMDAO }}" == "latest" ]]; then
131+
echo "The latest release of OpenMDAO will be installed from pypi per the pyCycle dependency"
132+
else
133+
pip install openmdao==${{ matrix.OPENMDAO }}
134+
fi
135+
136+
- name: Install pyCycle
137+
if: ${{ ! matrix.EXCLUDE }}
138+
run: |
139+
echo "============================================================="
140+
echo "Install pyCycle"
141+
echo "============================================================="
142+
python -m pip install -e .[all]
143+
144+
- name: Display environment info
145+
if: ${{ ! matrix.EXCLUDE }}
146+
run: |
147+
conda info
148+
conda list
149+
150+
- name: Run tests
151+
if: ${{ ! matrix.EXCLUDE }}
152+
id: run_tests
153+
run: |
154+
echo "============================================================="
155+
echo "Run tests (from directory other than repo root)"
156+
echo "============================================================="
157+
cd $HOME
158+
RPT_FILE=`pwd`/deprecations.txt
159+
echo "RPT_FILE=$RPT_FILE" >> $GITHUB_ENV
160+
testflo -n 1 pycycle --timeout=240 --show_skipped --deprecations_report=$RPT_FILE --coverage --coverpkg pycycle --durations=20
161+
162+
- name: Deprecations Report
163+
if: ${{ ! matrix.EXCLUDE }}
164+
id: deprecations_report
165+
continue-on-error: true
166+
run: |
167+
echo "============================================================="
168+
echo "Display deprecations report"
169+
echo "============================================================="
170+
cat $RPT_FILE
171+
172+
echo 'summary<<EOF' >> $GITHUB_OUTPUT
173+
head -n 6 $RPT_FILE | cut -d':' -f 1 >> $GITHUB_OUTPUT
174+
echo 'EOF' >> $GITHUB_OUTPUT
175+
176+
grep '^0 unique deprecation warnings' $RPT_FILE
177+
178+
- name: Check NumPy 2.0 Compatibility
179+
if: ${{ ! matrix.EXCLUDE }}
180+
run: |
181+
echo "============================================================="
182+
echo "Check code for NumPy 2.0 compatibility"
183+
echo "See: https://numpy.org/devdocs/numpy_2_0_migration_guide.html"
184+
echo "============================================================="
185+
python -m pip install ruff
186+
cd ${{ github.workspace }}
187+
ruff check . --select NPY201
188+
189+
- name: Slack unit test failure
190+
if: steps.run_tests.outcome == 'failure'
191+
uses: act10ns/slack@v2.0.0
192+
with:
193+
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
194+
status: ${{ steps.run_tests.outcome }}
195+
message: |
196+
`pyCycle`: Unit testing failed on `${{ matrix.NAME }}` build.
197+
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
198+
199+
- name: Slack deprecation warnings
200+
if: steps.deprecations_report.outcome == 'failure' && matrix.NAME == 'Ubuntu Baseline'
201+
uses: act10ns/slack@v2.0.0
202+
with:
203+
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
204+
status: 'warning'
205+
message: |
206+
`pyCycle`: Deprecations were detected on `${{ matrix.NAME }}` build.
207+
```${{ steps.deprecations_report.outputs.summary }}```
208+
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
209+
210+
windows_tests:
211+
runs-on: windows-latest
212+
213+
timeout-minutes: 60
214+
215+
strategy:
216+
fail-fast: false
217+
matrix:
218+
include:
219+
# baseline versions
220+
- NAME: Windows Baseline
221+
PY: '3.12'
222+
NUMPY: '1.26'
223+
SCIPY: '1.14'
224+
EXCLUDE: ${{ github.event_name == 'workflow_dispatch' && ! inputs.Windows_Baseline }}
225+
226+
name: ${{ matrix.NAME }}
227+
228+
defaults:
229+
run:
230+
shell: pwsh
231+
232+
steps:
233+
- name: Display run details
234+
run: |
235+
echo "============================================================="
236+
echo "Run #$env:GITHUB_RUN_NUMBER"
237+
echo "Run ID: $env:GITHUB_RUN_ID"
238+
echo "Testing: $env:GITHUB_REPOSITORY"
239+
echo "Triggered by: $env:GITHUB_EVENT_NAME"
240+
echo "Initiated by: $env:GITHUB_ACTOR"
241+
echo "Excluded: ${{ matrix.EXCLUDE }}"
242+
echo "============================================================="
243+
244+
- name: Checkout code
245+
if: ${{ ! matrix.EXCLUDE }}
246+
uses: actions/checkout@v3
247+
248+
- name: Setup conda
249+
if: ${{ ! matrix.EXCLUDE }}
250+
uses: conda-incubator/setup-miniconda@v3
251+
with:
252+
python-version: ${{ matrix.PY }}
253+
miniforge-version: "latest"
254+
255+
- name: Install pyCycle
256+
if: ${{ ! matrix.EXCLUDE }}
257+
run: |
258+
conda install numpy=${{ matrix.NUMPY }} scipy=${{ matrix.SCIPY }} -q -y
259+
260+
python -m pip install --upgrade pip
261+
262+
echo "============================================================="
263+
echo "Install pyCycle"
264+
echo "============================================================="
265+
python -m pip install -e .[all]
266+
267+
- name: Display environment info
268+
if: ${{ ! matrix.EXCLUDE }}
269+
run: |
270+
conda info
271+
conda list
272+
273+
- name: Run tests
274+
if: ${{ ! matrix.EXCLUDE }}
275+
id: run_tests
276+
run: |
277+
echo "============================================================="
278+
echo "Run tests with coverage"
279+
echo "============================================================="
280+
testflo -n 1 pycycle --timeout=240 --show_skipped --coverage --coverpkg pycycle --durations=20
281+
282+
- name: Slack unit test failure
283+
if: failure()
284+
uses: act10ns/slack@v2.0.0
285+
with:
286+
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
287+
status: ${{ steps.run_tests.outcome }}
288+
message: |
289+
`pyCycle`: Unit testing failed on `${{ matrix.NAME }}` build.
290+
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 commit comments

Comments
 (0)