-
Notifications
You must be signed in to change notification settings - Fork 11
129 lines (112 loc) · 4.14 KB
/
release-install-tests.yml
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
name: Release install
on:
workflow_dispatch:
release:
types: [released]
push:
branches:
- main
env:
PACKAGE_NAME: somata
RELEASE_HTTP: https://github.com/mh105/somata/releases/latest
jobs:
pip-install:
name: pip-install-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- name: "Create environment for 'pip install' on Unix"
if: runner.os != 'Windows'
uses: mamba-org/setup-micromamba@v1
with:
environment-name: pip_env
create-args:
pip
cmdstanpy # avoids having to run 'install_cmdstan' after pip install
- name: "Create environment for 'pip install' on Windows"
if: runner.os == 'Windows'
uses: mamba-org/setup-micromamba@v1
with:
environment-name: pip_env
create-args:
pip
cmdstanpy
numpy<2
spectrum # avoids building 'spectrum' on Windows that requires VC++ v14+
- name: "- Pip install ${{ env.PACKAGE_NAME }}"
run: pip install ${{ env.PACKAGE_NAME }}
- name: "- Pip list"
run: pip list
- name: "- Get the latest release version"
run: |
python --version
latest_version=$(python -c "import requests; url = '${{ env.RELEASE_HTTP }}'; r = requests.get(url); print(r.url.split('/')[-1])" | awk '{print substr($0, 2)}')
if [ -n "$latest_version" ]; then
echo "latest_version extracted from GitHub releases: $latest_version"
echo "latest_version=$latest_version" >> $GITHUB_ENV
else
echo "failed to retrieve latest_version."
exit 1
fi
- name: "- Verify installed package version"
run: |
installed_version=$(pip show ${{ env.PACKAGE_NAME }} | grep Version | awk '{print $2}')
if [ "$installed_version" != "${{ env.latest_version }}" ]; then
echo "Installed version from PyPI ($installed_version) does not match the latest release version on GitHub (${{ env.latest_version }})."
exit 1
else
echo "Installed version from PyPI ($installed_version) matches the latest release version on GitHub (${{ env.latest_version }})."
fi
- name: "- Run tests with pytest"
run: |
pip install pytest
pytest -vv
conda-install:
name: conda-install-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- name: "Install ${{ env.PACKAGE_NAME }} with 'conda create'"
uses: mamba-org/setup-micromamba@v1
with:
environment-name: conda_env
create-args:
-c pytorch
-c conda-forge
${{ env.PACKAGE_NAME }}
- name: "- Get the latest release version"
run: |
python --version
latest_version=$(python -c "import requests; url = '${{ env.RELEASE_HTTP }}'; r = requests.get(url); print(r.url.split('/')[-1])" | awk '{print substr($0, 2)}')
if [ -n "$latest_version" ]; then
echo "latest_version extracted from GitHub releases: $latest_version"
echo "latest_version=$latest_version" >> $GITHUB_ENV
else
echo "failed to retrieve latest_version."
exit 1
fi
- name: "- Verify installed package version"
run: |
installed_version=$(micromamba list ${{ env.PACKAGE_NAME }} | grep ${{ env.PACKAGE_NAME }} | awk '{print $2}')
if [ "$installed_version" != "${{ env.latest_version }}" ]; then
echo "Installed version from conda-forge ($installed_version) does not match the latest release version on GitHub (${{ env.latest_version }})."
exit 1
else
echo "Installed version from conda-forge ($installed_version) matches the latest release version on GitHub (${{ env.latest_version }})."
fi
- name: "- Run tests with pytest"
run: |
micromamba install pytest
pytest -vv