-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
formatting: | ||
name: Check Formatting | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Install | ||
run: pip install ruff | ||
- name: Run Ruff | ||
run: ruff check . | ||
|
||
tests: | ||
name: Run Unit Tests | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [self-hosted] | ||
python-version: [3.8] | ||
steps: | ||
- name: Check if PR is from owner's repository | ||
id: check-owner | ||
run: | | ||
if [[ "${{ github.actor }}" == "owner_username" ]]; then | ||
echo "::set-output name=is_owner::true" | ||
else | ||
echo "::set-output name=is_owner::false" | ||
fi | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python for Self-Hosted Linux arm64 | ||
uses: iory/[email protected] | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Check Python Version | ||
run: python --version | ||
- name: Install Pytest | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
pip install pytest hacking pytest-cov | ||
- name: Install python package | ||
run: pip install . | ||
- name: Run Pytest | ||
run: | | ||
set -o pipefail | ||
coverage erase | ||
coverage run -m pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered tests | ||
coverage xml | ||
- name: Step for Owner's PR Only | ||
if: steps.check-owner.outputs.is_owner == 'true' | ||
run: | | ||
echo "This step runs only for PRs from the owner's PR" | ||
- name: Pytest coverage comment | ||
if: steps.check-owner.outputs.is_owner == 'true' | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
pytest-xml-coverage-path: ./coverage.xml | ||
junitxml-path: ./pytest.xml | ||
|
||
pypi: | ||
name: Release To PyPi | ||
needs: [formatting, tests] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install publishing dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel build | ||
- name: Build | ||
run: | | ||
python -m build | ||
- name: Upload to PyPI | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} |