Skip to content

Commit c1d189c

Browse files
authored
Merge pull request #101 from smarie/feature/100_virtualenv
Feature/100 virtualenv
2 parents 525ce1f + 2b65f3d commit c1d189c

7 files changed

Lines changed: 371 additions & 236 deletions

File tree

.github/workflows/base.yml

Lines changed: 73 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,32 @@ on:
1212
pull_request:
1313
branches:
1414
- main
15+
16+
defaults:
17+
run:
18+
shell: bash -l {0}
19+
1520
jobs:
1621
# pre-job to read nox tests matrix - see https://stackoverflow.com/q/66747359/7262247
1722
list_nox_test_sessions:
1823
runs-on: ubuntu-latest
1924
steps:
20-
- uses: actions/checkout@v2
21-
- uses: actions/setup-python@v1
25+
- name: Checkout
26+
uses: actions/checkout@v4.1.1
27+
28+
- name: Install python 3.9
29+
uses: actions/setup-python@v5.0.0
2230
with:
23-
python-version: 3.7
31+
python-version: 3.9
2432
architecture: x64
2533

2634
- name: Install noxfile requirements
27-
shell: bash -l {0}
2835
run: pip install -r noxfile-requirements.txt
2936

30-
- name: List 'tests' nox sessions
37+
- name: List 'tests' nox sessions and required python versions
3138
id: set-matrix
32-
run: echo "::set-output name=matrix::$(nox -s gha_list -- tests)"
39+
run: echo "::set-output name=matrix::$(nox -s gha_list -- -s tests -v)"
40+
3341
outputs:
3442
matrix: ${{ steps.set-matrix.outputs.matrix }} # save nox sessions list to outputs
3543

@@ -38,45 +46,72 @@ jobs:
3846
strategy:
3947
fail-fast: false
4048
matrix:
49+
# see https://github.com/actions/setup-python/issues/544
50+
# os: [ ubuntu-20.04 ]
4151
os: [ ubuntu-latest ] # , macos-latest, windows-latest]
4252
# all nox sessions: manually > dynamically from previous job
4353
# nox_session: ["tests-2.7", "tests-3.7"]
4454
nox_session: ${{ fromJson(needs.list_nox_test_sessions.outputs.matrix) }}
4555

46-
name: ${{ matrix.os }} ${{ matrix.nox_session }} # ${{ matrix.name_suffix }}
56+
name: ${{ matrix.os }} ${{ matrix.nox_session.python }} ${{ matrix.nox_session.session }} # ${{ matrix.name_suffix }}
4757
runs-on: ${{ matrix.os }}
4858
steps:
49-
- uses: actions/checkout@v2
59+
- name: Checkout
60+
uses: actions/checkout@v4.1.1
61+
62+
- name: Install python ${{ matrix.nox_session.python }} for tests
63+
uses: MatteoH2O1999/setup-python@v3.0.0 # actions/setup-python@v5.0.0
64+
id: set-py
65+
with:
66+
python-version: ${{ matrix.nox_session.python }}
67+
architecture: x64
68+
allow-build: info
69+
cache-build: true
5070

51-
# Conda install
52-
- name: Install conda v3.7
53-
uses: conda-incubator/setup-miniconda@v2
71+
- name: Install python 3.12 for nox
72+
uses: actions/setup-python@v5.0.0
5473
with:
55-
# auto-update-conda: true
56-
python-version: 3.7
57-
activate-environment: noxenv
58-
- run: conda info
59-
shell: bash -l {0} # so that conda works
60-
- run: conda list
61-
shell: bash -l {0} # so that conda works
62-
63-
# Nox install + run
74+
python-version: 3.12
75+
architecture: x64
76+
77+
- name: pin virtualenv==20.15.1 in old python versions
78+
# pinned to keep compatibility with old versions, see https://github.com/MatteoH2O1999/setup-python/issues/28#issuecomment-1745613621
79+
if: contains(fromJson('["2.7", "3.5", "3.6"]'), matrix.nox_session.python )
80+
run: sed -i "s/virtualenv/virtualenv==20.15.1/g" noxfile-requirements.txt
81+
6482
- name: Install noxfile requirements
65-
shell: bash -l {0} # so that conda works
6683
run: pip install -r noxfile-requirements.txt
67-
- run: conda list
68-
shell: bash -l {0} # so that conda works
69-
- run: nox -s "${{ matrix.nox_session }}"
70-
shell: bash -l {0} # so that conda works
84+
85+
- name: Run nox session ${{ matrix.nox_session.session }}
86+
run: nox -s "${{ matrix.nox_session.session }}" -v
7187

7288
# Share ./docs/reports so that they can be deployed with doc in next job
7389
- name: Share reports with other jobs
74-
# if: matrix.nox_session == '...': not needed, if empty wont be shared
75-
uses: actions/upload-artifact@master
90+
# if: matrix.nox_session == '...': not needed, if empty won't be shared
91+
uses: actions/upload-artifact@v4.3.0
7692
with:
7793
name: reports_dir
7894
path: ./docs/reports
7995

96+
build_doc:
97+
runs-on: ubuntu-latest
98+
if: github.event_name == 'pull_request'
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v4.1.1
102+
103+
- name: Install python 3.9 for nox
104+
uses: actions/setup-python@v5.0.0
105+
with:
106+
python-version: 3.9
107+
architecture: x64
108+
109+
- name: Install noxfile requirements
110+
run: pip install -r noxfile-requirements.txt
111+
112+
- name: Build the doc including example gallery
113+
run: nox -s docs -- build
114+
80115
publish_release:
81116
needs: run_all_tests
82117
runs-on: ubuntu-latest
@@ -87,47 +122,37 @@ jobs:
87122
GITHUB_CONTEXT: ${{ toJSON(github) }}
88123
run: echo "$GITHUB_CONTEXT"
89124

90-
- uses: actions/checkout@v2
125+
- name: Checkout with no depth
126+
uses: actions/checkout@v4.1.1
91127
with:
92128
fetch-depth: 0 # so that gh-deploy works
93129

130+
- name: Install python 3.9 for nox
131+
uses: actions/setup-python@v5.0.0
132+
with:
133+
python-version: 3.9
134+
architecture: x64
135+
94136
# 1) retrieve the reports generated previously
95137
- name: Retrieve reports
96-
uses: actions/download-artifact@master
138+
uses: actions/download-artifact@v4.1.1
97139
with:
98140
name: reports_dir
99141
path: ./docs/reports
100142

101-
# Conda install
102-
- name: Install conda v3.7
103-
uses: conda-incubator/setup-miniconda@v2
104-
with:
105-
# auto-update-conda: true
106-
python-version: 3.7
107-
activate-environment: noxenv
108-
- run: conda info
109-
shell: bash -l {0} # so that conda works
110-
- run: conda list
111-
shell: bash -l {0} # so that conda works
112-
113143
# Nox install
114144
- name: Install noxfile requirements
115-
shell: bash -l {0} # so that conda works
116145
run: pip install -r noxfile-requirements.txt
117-
- run: conda list
118-
shell: bash -l {0} # so that conda works
119146

120147
# 5) Run the flake8 report and badge
121148
- name: Run flake8 analysis and generate corresponding badge
122-
shell: bash -l {0} # so that conda works
123149
run: nox -s flake8
124150

125151
# -------------- only on Ubuntu + MAIN PUSH (no pull request, no tag) -----------
126152

127153
# 5) Publish the doc and test reports
128154
- name: \[not on TAG\] Publish documentation, tests and coverage reports
129155
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') # startsWith(matrix.os,'ubuntu')
130-
shell: bash -l {0} # so that conda works
131156
run: nox -s publish
132157

133158
# 6) Publish coverage report
@@ -142,7 +167,7 @@ jobs:
142167
EOF
143168
- name: \[not on TAG\] Publish coverage report
144169
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads')
145-
uses: codecov/codecov-action@v1
170+
uses: codecov/codecov-action@v4.0.1
146171
with:
147172
files: ./docs/reports/coverage/coverage.xml
148173

@@ -151,13 +176,12 @@ jobs:
151176
# 7) Create github release and build the wheel
152177
- name: \[TAG only\] Build wheel and create github release
153178
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
154-
shell: bash -l {0} # so that conda works
155179
run: nox -s release -- ${{ secrets.GITHUB_TOKEN }}
156180

157181
# 8) Publish the wheel on PyPi
158182
- name: \[TAG only\] Deploy on PyPi
159183
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
160-
uses: pypa/gh-action-pypi-publish@release/v1
184+
uses: pypa/gh-action-pypi-publish@v1.8.11
161185
with:
162186
user: __token__
163187
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ coverage.xml
5050
*.py,cover
5151
.hypothesis/
5252
.pytest_cache/
53-
makefun/_version.py
53+
src/makefun/_version.py
5454

5555
# Translations
5656
*.mo

0 commit comments

Comments
 (0)