1212 pull_request :
1313 branches :
1414 - main
15+
16+ defaults :
17+ run :
18+ shell : bash -l {0}
19+
1520jobs :
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@v2
27+
28+ - name : Install python 3.9
29+ uses : actions/setup-python@v4
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,36 +46,44 @@ 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(env='pytest2.x')", "tests-3.7(env='pytest-latest')"]
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@v2
61+
62+ - name : Install python ${{ matrix.nox_session.python }} for tests
63+ uses : MatteoH2O1999/setup-python@v1 # actions/setup-python@v4
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@v4
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
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@v2
102+
103+ - name : Install python 3.9 for nox
104+ uses : actions/setup-python@v4
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@v2
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@v4
132+ with :
133+ python-version : 3.9
134+ architecture : x64
135+
94136 # 1) retrieve the reports generated previously
95137 - name : Retrieve reports
96138 uses : actions/download-artifact@master
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
@@ -151,7 +176,6 @@ 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
0 commit comments