Repository navigation
79 lines (67 loc) · 2.45 KB
/
Copy pathpython-app.yml
File metadata and controls
79 lines (67 loc) · 2.45 KB
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: PyForks Tests
on:
push:
branches: [ "main", "cdci_fix_pypi" ]
pull_request:
branches: [ "main", "cdci_fix_pypi" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov setuptools build twine
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
run: |
pytest --cov=./ --cov-report=xml
- name: Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
- name: Extract version from setup.py
id: get_version
run: |
VERSION=$(python setup.py --version)
echo "version=$VERSION" >> $GITHUB_ENV
- name: Get latest version from PyPI
id: pypi_version
run: |
PACKAGE_NAME=$(python setup.py --name)
LATEST_VERSION=$(curl -s https://pypi.org/pypi/$PACKAGE_NAME/json | jq -r .info.version)
echo "latest_version=$LATEST_VERSION" >> $GITHUB_ENV
- name: Build PyPi Package
if: github.ref_name == 'main'
run: |
python -m build
- name: PyPi Publish
if: github.ref_name == 'main'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
if [ "${{ steps.get_version.outputs.version }}" != "${{ steps.pypi_version.outputs.latest_version }}" ]; then
python -m twine upload --repository pypi dist/*
exit 0
fi
echo "Version has not changed. Exiting."