Skip to content

Commit 44e9d96

Browse files
authored
Add unit tests to publish-release.yml (#11)
1 parent adf951a commit 44e9d96

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

.github/workflows/publish-release.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ permissions:
1414

1515
jobs:
1616
compile-and-deploy:
17-
runs-on: ubuntu-latest
17+
runs-on: ${{ matrix.os }}
1818
strategy:
1919
fail-fast: false
2020
matrix:
21+
os: ['ubuntu-latest']
2122
include:
2223
- matlab: "R2020b"
2324
python: "2.7"
25+
os: 'ubuntu-20.04'
2426

2527
- matlab: "R2020b"
2628
python: "3.8"
@@ -29,6 +31,7 @@ jobs:
2931

3032
- matlab: "R2021a"
3133
python: "2.7"
34+
os: 'ubuntu-20.04'
3235

3336
- matlab: "R2021a"
3437
python: "3.8"
@@ -37,6 +40,7 @@ jobs:
3740

3841
- matlab: "R2021b"
3942
python: "2.7"
43+
os: 'ubuntu-20.04'
4044

4145
- matlab: "R2021b"
4246
python: "3.9"
@@ -45,6 +49,7 @@ jobs:
4549

4650
- matlab: "R2022a"
4751
python: "2.7"
52+
os: 'ubuntu-20.04'
4853

4954
- matlab: "R2022a"
5055
python: "3.9"
@@ -53,6 +58,7 @@ jobs:
5358

5459
- matlab: "R2022b"
5560
python: "2.7"
61+
os: 'ubuntu-20.04'
5662

5763
- matlab: "R2022b"
5864
python: "3.10"
@@ -149,7 +155,42 @@ jobs:
149155
- name: Build package
150156
run: python -m build --sdist --wheel
151157

152-
- name: Detect Pre-release
158+
- name: Extract MATLAB path to file
159+
uses: matlab-actions/run-command@v2
160+
with:
161+
command: |
162+
fileID = fopen('matlab_path.txt', 'w');
163+
matlabpath = matlabroot;
164+
matlabpath = strrep(matlabpath, filesep, '/');
165+
matlabpath = strrep(matlabpath, '\', '\\');
166+
matlabpath = strrep(matlabpath, 'C:', '/c/');
167+
matlabpath = strrep(matlabpath, 'D:', '/d/');
168+
fprintf(fileID, matlabpath);
169+
fclose(fileID);
170+
# sometimes this step hangs when closing matlab, automatically terminating after 2 minutes solves the issue
171+
timeout-minutes: 2
172+
continue-on-error: true
173+
174+
- name: Set environment variable with MATLAB path
175+
shell: bash # Works on Windows as well because of shell: bash
176+
run: |
177+
matlab_path=$(cat matlab_path.txt)
178+
echo "MATLAB_PATH=$matlab_path" >> $GITHUB_ENV
179+
180+
- name: Install package
181+
run: |
182+
python -m pip install $(find ./dist -name "*.whl")
183+
184+
- name: Run unit tests
185+
run: |
186+
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\
187+
${{ env.MATLAB_PATH }}/runtime/glnxa64:\
188+
${{ env.MATLAB_PATH }}/bin/glnxa64:\
189+
${{ env.MATLAB_PATH }}/sys/os/glnxa64:\
190+
${{ env.MATLAB_PATH }}/extern/bin/glnxa64"
191+
python -m unittest discover tests -v
192+
193+
- name: Detect pre-release
153194
shell: bash
154195
run: |
155196
if echo "${{ github.ref_name }}" | grep -q '^[0-9][0-9]\.[0-9][0-9]\.[A-Za-z]'; then
@@ -158,12 +199,13 @@ jobs:
158199
echo "PRERELEASE=false" >> $GITHUB_ENV
159200
fi
160201
echo PRERELEASE=${{ env.PRERELEASE }}
161-
202+
162203
- name: Release package
163204
uses: softprops/action-gh-release@v2
164205
with:
165206
prerelease: ${{ env.PRERELEASE }}
166207
files: ./dist/spm_python*.whl
208+
continue-on-error: true
167209

168210
- name: Publish package
169211
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29

0 commit comments

Comments
 (0)