-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (79 loc) · 2.29 KB
/
python-CI.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
name: CI for Tests and Package Publishing
on:
push:
branches:
- '**'
pull_request:
branches:
- main
release:
types:
- published
workflow_dispatch:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
- name: Install dependencies
run: |
poetry install
- name: Run pre-commit hooks
run: |
poetry run pre-commit run --all-files
- name: Run tests with tox
run: |
poetry run tox
- name: Stop on failure
if: failure()
run: exit 1
- name: Upload to Codecov
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: unittests
fail_ci_if_error: true
verbose: true
- name: Upload test results to Codecov
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && !cancelled()
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload HTML coverage report
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov/
publish:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'release' # Exécuter uniquement lors d'une release
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
- name: Install dependencies
run: poetry install --no-dev
- name: Build package
run: poetry build
- name: Publish package
run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}