From a75f6fb09a9a3697d80c3f4d0a3573663cf40616 Mon Sep 17 00:00:00 2001 From: Forest Gregg Date: Thu, 26 Sep 2024 11:25:24 -0400 Subject: [PATCH] Create python-package.yml --- .github/workflows/python-package.yml | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..05e5159 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,81 @@ +name: Test and Publish Python Package + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.12" + - name: Install dependencies + run: | + pip install --upgrade pip + pip install .[dev] + - name: flake8 + run: flake8 parserator + - name: isort + if: always() + run: isort --check-only . + - name: black + if: always() + run: black . --check + test: + timeout-minutes: 40 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e . + - name: Install test dependencies + run: pip install -r requirements.txt + - name: pytest + run: pytest + - name: Code Coverage + uses: codecov/codecov-action@v4 + env: + OS: ${{ matrix.os }} + PYTHON: '3.12' + with: + env_vars: OS,PYTHON + + deploy: + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + needs: [test, lint] + + 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 dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }}