Skip to content

Commit 6e0f78c

Browse files
author
Sylvain MARIE
committed
Migration from Travis to Github Actions
1 parent 65efcc4 commit 6e0f78c

22 files changed

+1520
-658
lines changed

.github/workflows/base.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# .github/workflows/base.yml
2+
name: Build
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
jobs:
13+
# pre-job to read nox tests matrix - see https://stackoverflow.com/q/66747359/7262247
14+
list_nox_test_sessions:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-python@v1
19+
with:
20+
python-version: 3.7
21+
architecture: x64
22+
23+
- name: Install noxfile requirements
24+
shell: bash -l {0}
25+
run: pip install -r noxfile-requirements.txt
26+
27+
- name: List 'tests' nox sessions
28+
id: set-matrix
29+
run: echo "::set-output name=matrix::$(nox -s gha_list -- tests)"
30+
outputs:
31+
matrix: ${{ steps.set-matrix.outputs.matrix }} # save nox sessions list to outputs
32+
33+
run_all_tests:
34+
needs: list_nox_test_sessions
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
os: [ ubuntu-latest ] # , macos-latest, windows-latest]
39+
# all nox sessions: manually > dynamically from previous job
40+
# nox_session: ["tests-2.7(env='pytest2.x')", "tests-3.7(env='pytest-latest')"]
41+
nox_session: ${{ fromJson(needs.list_nox_test_sessions.outputs.matrix) }}
42+
43+
name: ${{ matrix.os }} ${{ matrix.nox_session }} # ${{ matrix.name_suffix }}
44+
runs-on: ${{ matrix.os }}
45+
steps:
46+
- uses: actions/checkout@v2
47+
48+
# Conda install
49+
- name: Install conda v3.7
50+
uses: conda-incubator/setup-miniconda@v2
51+
with:
52+
# auto-update-conda: true
53+
python-version: 3.7
54+
activate-environment: noxenv
55+
- run: conda info
56+
shell: bash -l {0} # so that conda works
57+
- run: conda list
58+
shell: bash -l {0} # so that conda works
59+
60+
# Nox install + run
61+
- name: Install noxfile requirements
62+
shell: bash -l {0} # so that conda works
63+
run: pip install -r noxfile-requirements.txt
64+
- run: conda list
65+
shell: bash -l {0} # so that conda works
66+
- run: nox -s "${{ matrix.nox_session }}"
67+
shell: bash -l {0} # so that conda works
68+
69+
# Share ./docs/reports so that they can be deployed with doc in next job
70+
- name: Share reports with other jobs
71+
# if: matrix.nox_session == '...': not needed, if empty wont be shared
72+
uses: actions/upload-artifact@master
73+
with:
74+
name: reports_dir
75+
path: ./docs/reports
76+
77+
publish_release:
78+
needs: run_all_tests
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: GitHub context to debug conditional steps
82+
env:
83+
GITHUB_CONTEXT: ${{ toJSON(github) }}
84+
run: echo "$GITHUB_CONTEXT"
85+
86+
- uses: actions/checkout@v2
87+
with:
88+
fetch-depth: 0 # so that gh-deploy works
89+
90+
# 1) retrieve the reports generated previously
91+
- name: Retrieve reports
92+
uses: actions/download-artifact@master
93+
with:
94+
name: reports_dir
95+
path: ./docs/reports
96+
97+
# Conda install
98+
- name: Install conda v3.7
99+
uses: conda-incubator/setup-miniconda@v2
100+
with:
101+
# auto-update-conda: true
102+
python-version: 3.7
103+
activate-environment: noxenv
104+
- run: conda info
105+
shell: bash -l {0} # so that conda works
106+
- run: conda list
107+
shell: bash -l {0} # so that conda works
108+
109+
# Nox install
110+
- name: Install noxfile requirements
111+
shell: bash -l {0} # so that conda works
112+
run: pip install -r noxfile-requirements.txt
113+
- run: conda list
114+
shell: bash -l {0} # so that conda works
115+
116+
117+
# -------------- only on Ubuntu + MAIN PUSH (no pull request, no tag) -----------
118+
119+
# 5) Publish the doc and test reports
120+
- name: \[not on TAG\] Publish documentation, tests and coverage reports
121+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') # startsWith(matrix.os,'ubuntu')
122+
shell: bash -l {0} # so that conda works
123+
run: nox -s publish
124+
125+
# 6) Publish coverage report
126+
- name: \[not on TAG\] Create codecov.yaml with correct paths
127+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads')
128+
shell: bash
129+
run: |
130+
cat << EOF > codecov.yml
131+
# codecov.yml
132+
fixes:
133+
- "/home/runner/work/smarie/python-pytest-cases/::" # Correct paths
134+
EOF
135+
- name: \[not on TAG\] Publish coverage report
136+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads')
137+
uses: codecov/codecov-action@v1
138+
with:
139+
files: ./docs/reports/coverage/coverage.xml
140+
141+
# -------------- only on Ubuntu + TAG PUSH (no pull request) -----------
142+
143+
# 7) Create github release and build the wheel
144+
- name: \[TAG only\] Build wheel and create github release
145+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
146+
shell: bash -l {0} # so that conda works
147+
run: nox -s release -- ${{ secrets.GITHUB_TOKEN }}
148+
149+
# 8) Publish the wheel on PyPi
150+
- name: \[TAG only\] Deploy on PyPi
151+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
152+
uses: pypa/gh-action-pypi-publish@release/v1
153+
with:
154+
user: __token__
155+
password: ${{ secrets.PYPI_API_TOKEN }}
156+
157+
delete-artifacts:
158+
needs: publish_release
159+
runs-on: ubuntu-latest
160+
steps:
161+
- uses: kolpav/purge-artifacts-action@v1
162+
with:
163+
token: ${{ secrets.GITHUB_TOKEN }}
164+
expire-in: 0 # Setting this to 0 will delete all artifacts

.gitignore

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ parts/
2020
sdist/
2121
var/
2222
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
2325
*.egg-info/
2426
.installed.cfg
2527
*.egg
@@ -38,14 +40,17 @@ pip-delete-this-directory.txt
3840
# Unit test / coverage reports
3941
htmlcov/
4042
.tox/
43+
.nox/
4144
.coverage
4245
.coverage.*
4346
.cache
4447
nosetests.xml
4548
coverage.xml
4649
*.cover
50+
*.py,cover
4751
.hypothesis/
4852
.pytest_cache/
53+
makefun/_version.py
4954

5055
# Translations
5156
*.mo
@@ -55,6 +60,7 @@ coverage.xml
5560
*.log
5661
local_settings.py
5762
db.sqlite3
63+
db.sqlite3-journal
5864

5965
# Flask stuff:
6066
instance/
@@ -72,11 +78,26 @@ target/
7278
# Jupyter Notebook
7379
.ipynb_checkpoints
7480

81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
7585
# pyenv
7686
.python-version
7787

78-
# celery beat schedule file
88+
# pipenv
89+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
90+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
91+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
92+
# install all needed dependencies.
93+
#Pipfile.lock
94+
95+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
96+
__pypackages__/
97+
98+
# Celery stuff
7999
celerybeat-schedule
100+
celerybeat.pid
80101

81102
# SageMath parsed files
82103
*.sage.py
@@ -85,7 +106,7 @@ celerybeat-schedule
85106
.env
86107
.venv
87108
env/
88-
venv/
109+
venv*/
89110
ENV/
90111
env.bak/
91112
venv.bak/
@@ -102,13 +123,20 @@ venv.bak/
102123

103124
# mypy
104125
.mypy_cache/
126+
.dmypy.json
127+
dmypy.json
128+
129+
# Pyre type checker
130+
.pyre/
131+
132+
# PyCharm development
133+
/.idea
105134

106-
# Pycharm
107-
.idea/
135+
# OSX
136+
.DS_Store
108137

109-
# Mkdocs
110-
site/
138+
# JUnit and coverage reports
139+
docs/reports
111140

112-
# travis CI
113-
github_travis_rsa*
114-
reports
141+
# ODSClient cache
142+
.odsclient

0 commit comments

Comments
 (0)