-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (148 loc) · 5.14 KB
/
tests.yaml
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
160
161
162
163
164
165
166
167
name: Tests for PROTEUS
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:
jobs:
test:
if: github.event.pull_request.draft == false
name: Run Coverage and Tests
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest']
python-version: ['3.11', '3.13']
include:
- os: ubuntu-latest
INSTALL_DEPS: sudo apt-get install libnetcdff-dev netcdf-bin
CC: gcc
CXX: g++
FC: gfortran
- os: macos-latest
INSTALL_DEPS: brew install gfortran netcdf netcdf-fortran
CC: gcc
CXX: g++
FC: gfortran
env:
FWL_DATA: ${{ github.workspace }}/fwl_data
RAD_DIR: ${{ github.workspace }}/SOCRATES
runs-on: ${{ matrix.os }}
steps:
# https://stackoverflow.com/a/65356209
- name: Install system dependencies
run: ${{ matrix.INSTALL_DEPS }}
# MacOS only: create symbolic link for gfortran
- name: Symlink gfortran
if: runner.os == 'macOS'
run: |
sudo ln -s /opt/homebrew/bin/gfortran-13 /opt/homebrew/bin/gfortran
sudo ln -s /opt/homebrew/Cellar/gcc/12.*/lib/gcc/12/*.dylib /opt/homebrew/lib/
which gfortran
# Checkout PROTEUS
- name: Checkout PROTEUS
uses: actions/checkout@v4
# Checkout SOCRATES
- name: Checkout SOCRATES radiative transfer model
uses: actions/checkout@v4
with:
repository: 'nichollsh/SOCRATES'
path: ${{ env.RAD_DIR }}
# Try to restore SOCRATES from the cache
- name: Restore SOCRATES from cache
uses: actions/cache@v4
id: cache-socrates
with:
path: |
${{ env.RAD_DIR }}/bin
${{ env.RAD_DIR }}/sbin
${{ env.RAD_DIR }}/set_rad_env
key: socrates-${{ hashFiles('SOCRATES/version') }}-${{ runner.os }}
# Build SOCRATES if we can't restore it from the cache
- name: Build SOCRATES
if: steps.cache-socrates.outputs.cache-hit != 'true'
run: |
export LD_LIBRARY_PATH=""
echo $RAD_DIR
cd $RAD_DIR
./configure
./build_code
cd ..
# Setup Python using the version defined in the matrix
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Try to restore the Python environment from the cache
- name: Restore Python environment from cache
uses: actions/cache@v4
id: cache-virtualenv
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: Install Python dependencies
run: python -m pip install -e .[develop]
# Get lookup data for PROTEUS
- name: Get FWL data from cache
uses: actions/cache@v4
id: cache-fwl-data
with:
path: ${{ env.FWL_DATA }}
key: fwl-data-2
# Get FWL data
- name: Get additional FWL data
if: steps.cache-fwl-data.cache-hit != 'true'
run: |
proteus get stellar
proteus get spectral --name Frostflow --bands 48
# Run PROTEUS tests
- name: Test with pytest
run: coverage run -m pytest
# Upload output run images if tests fail
- name: Upload PNG plots as artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: png-plots
path: |
output/physical/plot_atmosphere.png
output/physical/plot_escape.png
output/physical/plot_global_log.png
output/physical/plot_observables.png
output/physical/plot_stacked.png
output/physical/plot_elements.png
output/physical/plot_fluxes_atmosphere.png
output/physical/plot_interior_cmesh.png
output/physical/plot_sflux_cross.png
output/physical/plot_emission.png
output/physical/plot_interior.png
output/physical/plot_sflux.png
- name: Report coverage
run: |
coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "Total coverage: $TOTAL"
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
echo $'\n```' >> $GITHUB_STEP_SUMMARY
coverage report >> $GITHUB_STEP_SUMMARY
echo $'\n```' >> $GITHUB_STEP_SUMMARY
- name: Make coverage badge
if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.13' }}
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: b4ee7dab92e20644bcb3a5ad09f71165
filename: covbadge.svg
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}