From bf69ed14075f1cc744edcd4b77885a952eff0d37 Mon Sep 17 00:00:00 2001 From: Mike Hendricks Date: Thu, 4 Aug 2022 22:18:14 -0700 Subject: [PATCH] Add github actions - Static Analysis & Test - PyPi release --- .github/workflows/python-release.yml | 33 +++++++++ .../python-static-analysis-and-test.yml | 71 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 .github/workflows/python-release.yml create mode 100644 .github/workflows/python-static-analysis-and-test.yml diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml new file mode 100644 index 0000000..65bd13f --- /dev/null +++ b/.github/workflows/python-release.yml @@ -0,0 +1,33 @@ +on: + release: + types: [created] + +jobs: + + build-and-publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade setuptools wheel twine + - name: Build wheel + run: | + python setup.py build bdist_wheel + - name: Publish to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + twine upload --verbose dist/* diff --git a/.github/workflows/python-static-analysis-and-test.yml b/.github/workflows/python-static-analysis-and-test.yml new file mode 100644 index 0000000..7a0fc45 --- /dev/null +++ b/.github/workflows/python-static-analysis-and-test.yml @@ -0,0 +1,71 @@ +name: Static Analysis & Test + +on: [push, pull_request] + +jobs: + + static-analysis: + + # We want to run on external PRs, but not on our own internal PRs as they'll + # be run by the push to the branch. Without this if check, checks are + # duplicated since internal PRs match both the push and pull_request events. + # https://github.com/psf/black/blob/f51e53726b39a177355a7917c91c56f390dda7ef/.github/workflows/lint.yml#L7-L12 + if: + github.event_name == 'push' || github.event.pull_request.head.repo.full_name != + github.repository + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox + + - name: Lint with flake8 + run: tox -e flake8 + + - name: Format with black + run: tox -e black + + + # test: + + # # We want to run on external PRs, but not on our own internal PRs as they'll + # # be run by the push to the branch. Without this if check, checks are + # # duplicated since internal PRs match both the push and pull_request events. + # if: + # github.event_name == 'push' || github.event.pull_request.head.repo.full_name != + # github.repository + + # runs-on: ubuntu-latest + + # strategy: + # matrix: + # python: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"] + + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + + # - name: Setup Python + # uses: actions/setup-python@v2 + # with: + # python-version: ${{ matrix.python }} + + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # python -m pip install tox + + # - name: Run Tox + # run: | + # tox -e py