Skip to content

Commit 8508e28

Browse files
committed
Added GitHub Actions
1 parent f288166 commit 8508e28

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will deploy the Python package to PyPi.org
2+
3+
name: deploy
4+
5+
env:
6+
package: codext
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- '**/VERSION.txt'
14+
workflow_run:
15+
workflows: ["build"]
16+
types: [completed]
17+
18+
jobs:
19+
deploy:
20+
runs-on: ubuntu-latest
21+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
- name: Cleanup README
27+
run: |
28+
sed -ri 's/^(##*)\s*:.*:\s*/\1 /g' README.md
29+
awk '{if (match($0,"## Supporters")) exit; print}' README.md > README
30+
mv -f README README.md
31+
- run: python3 -m pip install --upgrade build && python3 -m build
32+
- name: Upload ${{ env.package }} to PyPI
33+
uses: pypa/gh-action-pypi-publish@release/v1
34+
with:
35+
password: ${{ secrets.PYPI_API_TOKEN }}
36+
verbose: true
37+
verify_metadata: false
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: build
5+
6+
env:
7+
package: codext
8+
9+
on:
10+
push:
11+
branches: [ "main" ]
12+
pull_request:
13+
branches: [ "main" ]
14+
15+
jobs:
16+
build:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest]
22+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install ${{ env.package }}
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m pip install flake8 pytest pytest-cov coverage
33+
pip install -r requirements.txt
34+
pip install .
35+
- name: Lint with flake8
36+
run: |
37+
# stop the build if there are Python syntax errors or undefined names
38+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
39+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
41+
- name: Test ${{ env.package }} with pytest
42+
run: |
43+
pytest --cov=$package
44+
coverage:
45+
needs: build
46+
runs-on: ubuntu-latest
47+
env:
48+
cov_badge_path: docs/coverage.svg
49+
steps:
50+
- uses: actions/checkout@v3
51+
- name: Install ${{ env.package }}
52+
run: |
53+
python -m pip install --upgrade pip
54+
python -m pip install pytest pytest-cov
55+
pip install -r requirements.txt
56+
pip install .
57+
- name: Make coverage badge for ${{ env.package }}
58+
run: |
59+
pip install genbadge[coverage]
60+
pytest --cov=$package --cov-report=xml
61+
genbadge coverage -i coverage.xml -o $cov_badge_path
62+
- name: Verify Changed files
63+
uses: tj-actions/verify-changed-files@v12
64+
id: changed_files
65+
with:
66+
files: ${{ env.cov_badge_path }}
67+
- name: Commit files
68+
if: steps.changed_files.outputs.files_changed == 'true'
69+
run: |
70+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
71+
git config --local user.name "github-actions[bot]"
72+
git add $cov_badge_path
73+
git commit -m "Updated coverage.svg"
74+
- name: Push changes
75+
if: steps.changed_files.outputs.files_changed == 'true'
76+
uses: ad-m/github-push-action@master
77+
with:
78+
github_token: ${{ secrets.github_token }}
79+
branch: ${{ github.ref }}

0 commit comments

Comments
 (0)