1- name : Full CI
1+ name : CI for Tests and Package Publishing
22
33on :
44 push :
5- branches : [main, dev]
5+ branches :
6+ - ' **'
7+ pull_request :
8+ branches :
9+ - main
610 release :
7- types : [published]
11+ types :
12+ - published
813 workflow_dispatch :
9- inputs :
10- job :
11- description : ' Choose which job to run'
12- required : true
13- default : ' deploy'
14- type : choice
15- options :
16- - publish-module
17- - test-Django
18- - coverage
19- - all
2014
2115permissions :
2216 contents : read
2317
2418jobs :
25- test-Django :
26- if : github.event.inputs.job == 'test-Django' || github.event.inputs.job == 'all' || github.event_name == 'release' || github.event_name == 'push'
19+ test :
2720 runs-on : ubuntu-latest
28- strategy :
29- matrix :
30- python-version : ["3.10", "3.11", "3.12"]
3121
3222 steps :
33- - uses : actions/checkout@v4
34- - name : Set up Python ${{ matrix.python-version }}
35- uses : actions/setup-python@v5
36- with :
37- python-version : ${{ matrix.python-version }}
38- - name : Install Dependencies
39- run : |
40- cd ./test/app/
41- python -m pip install --upgrade pip
42- pip install -r requirements.txt
43- pip install ../../
44- - name : Run Tests
45- run : |
46- cd ./test/app/
47- python manage.py test
48-
49- coverage :
50- if : github.event.inputs.job == 'coverage' || github.event.inputs.job == 'all' || github.event_name == 'release' || github.event_name == 'push'
51- runs-on : ubuntu-latest
52- needs : test-Django
53- steps :
54- - uses : actions/checkout@v4
55- - name : Set up Python
56- uses : actions/setup-python@v5
57- with :
58- python-version : ' 3.11'
59- - name : Install Dependencies
60- run : |
61- cd ./test/app/
62- python -m pip install --upgrade pip
63- pip install -r requirements.txt
64- pip install coverage
65- pip install ../../
66- - name : Run Coverage
67- run : |
68- cd ./test/app/ && coverage run manage.py test && coverage html && coverage xml
69- - name : Upload Coverage to GitHub
70- uses : actions/upload-artifact@v4
71- with :
72- name : coverage-report
73- path : ./test/app/htmlcov
74- - name : Report Coverage
75- uses : codecov/codecov-action@v4.0.1
76- with :
77- token : ${{ secrets.CODECOV_TOKEN }}
78- files : ./test/app/htmlcov/coverage.xml
79-
80- publish-module :
81- if : github.event_name == 'release' || github.event.inputs.job == 'publish-module' || github.event.inputs.job == 'all'
23+ - uses : actions/checkout@v4
24+
25+ - name : Set up Python
26+ uses : actions/setup-python@v3
27+ with :
28+ python-version : ' 3.x'
29+
30+ - name : Install Poetry
31+ run : |
32+ curl -sSL https://install.python-poetry.org | python3 -
33+ export PATH="$HOME/.local/bin:$PATH"
34+
35+ - name : Install dependencies
36+ run : |
37+ poetry install
38+
39+ - name : Run pre-commit hooks
40+ run : |
41+ poetry run pre-commit run --all-files
42+
43+ - name : Run tests with tox
44+ run : |
45+ poetry run tox
46+
47+ - name : Stop on failure
48+ if : failure()
49+ run : exit 1
50+
51+ - name : Upload to Codecov
52+ uses : codecov/codecov-action@v3
53+ with :
54+ token : ${{ secrets.CODECOV_TOKEN }}
55+ files : coverage.xml
56+ flags : unittests
57+ fail_ci_if_error : true
58+ verbose : true
59+
60+ - name : Upload test results to Codecov
61+ if : ${{ !cancelled() }}
62+ uses : codecov/test-results-action@v1
63+ with :
64+ token : ${{ secrets.CODECOV_TOKEN }}
65+
66+ - name : Upload HTML coverage report
67+ if : always()
68+ uses : actions/upload-artifact@v3
69+ with :
70+ name : coverage-report
71+ path : htmlcov/
72+
73+ publish :
8274 runs-on : ubuntu-latest
83- needs : [test-Django, coverage]
75+ needs : test
76+
77+ if : github.event_name == 'release' # Exécuter uniquement lors d'une release
78+
8479 steps :
85- - uses : actions/checkout@v4
86- - name : Set up Python
87- uses : actions/setup-python@v5
88- with :
89- python-version : ' 3.11 '
90- - name : Install dependencies
91- run : |
92- python -m pip install --upgrade pip
93- pip install build
94- - name : Check current folder
95- run : |
96- ls
97- - name : Build package
98- run : |
99- python -m build
100- - name : Publish build
101- uses : pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
102- with :
103- user : __token__
104- password : ${{ secrets.PYPI_API_TOKEN }}
80+ - uses : actions/checkout@v4
81+
82+ - name : Set up Python
83+ uses : actions/setup-python@v3
84+ with :
85+ python-version : ' 3.x '
86+
87+ - name : Install Poetry
88+ run : |
89+ curl -sSL https://install.python-poetry.org | python3 -
90+ export PATH="$HOME/.local/bin:$PATH"
91+
92+ - name : Install dependencies
93+ run : poetry install --no-dev
94+
95+ - name : Build package
96+ run : poetry build
97+
98+ - name : Publish package
99+ run : poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
0 commit comments