-
Notifications
You must be signed in to change notification settings - Fork 7
117 lines (117 loc) · 3.89 KB
/
build.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Build
on:
push:
branches:
- main
tags:
- '*'
pull_request:
permissions:
# https://github.community/t/permissions-nesecary-to-comment-on-a-pr/179047/5
pull-requests: write
jobs:
build:
name: Build
strategy:
matrix:
python-version: [ '3.9', '3.10', 'pypy3.9' ]
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Update version number
if: startsWith(github.ref, 'refs/tags/')
run: sed -i -e "s/0.0.0/${GITHUB_REF##*/}/" pyproject.toml
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install python style and linting tools
run: pip install black flake8 autoflake isort docformatter
- name: Check unused code
run: autoflake --remove-all-unused-imports --remove-unused-variables --check .
- name: Check import order (isort)
run: isort --check --profile black --line-length 79 .
- name: Check docstring formatting
run: docformatter --check --recursive --black --wrap-descriptions 79 --wrap-summaries 79 .
- name: Error and style linting
id: flake8
run: flake8 --max-line-length 79 --ignore E203,W503 .
- name: Check error linting
if: steps.flake8.outputs.number > 0
run: exit 1
- name: Install poetry
run: |
python -m pip install poetry==1.4.2
- name: Configure poetry
run: |
python -m poetry config virtualenvs.in-project true
- name: Upload logs on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: logs
path: "*.log"
- name: Cache the virtualenv
uses: actions/cache@v3
with:
path: ./.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
python -m poetry install
- name: Run tests with coverage
run: |
# Run the unit tests
python -m poetry run coverage run -a -m unittest discover -v src
# Run the example plugin
python -m poetry run coverage run -a ./example_plugin.py -f example.yaml
# Test the example plugin
python -m poetry run coverage run -a ./test_example_plugin.py
# Generate the coverage HTML report
python -m poetry run coverage html
- name: Publish coverage report to job summary
# publishing only once
if: ${{ matrix.python-version == '3.9'}}
run: |
poetry run html2text --ignore-images --ignore-links -b 0 htmlcov/index.html >> $GITHUB_STEP_SUMMARY
- name: Generate documentation
run: |
poetry run sphinx-apidoc -o docs/ -f -a -e src/ --doc-project "Python SDK for Arcaflow"
poetry run make -C docs html
- name: Build
run: poetry build
- name: Upload dist artifact
uses: actions/upload-artifact@v3
with:
name: dist-${{ matrix.python-version }}
path: dist
if-no-files-found: error
- name: Upload coverage HTML artifact
uses: actions/upload-artifact@v3
with:
name: coverage
path: htmlcov
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- build
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: dist-${{ matrix.python-version }}
path: dist
- name: Install twine
run: pip install -U twine
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}}
TWINE_NON_INTERACTIVE: true
run: twine upload dist/*