Skip to content

Commit

Permalink
Simplify and improve Github Actions
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <[email protected]>
  • Loading branch information
gaborbernat committed Dec 3, 2023
1 parent 2198e2b commit 4e83145
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 127 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
name: Bug
about: Report a bug or unexpected behavior.

---

<!--
Expand All @@ -12,10 +11,13 @@ https://pypa.github.io/pipx/troubleshooting/
-->

**Describe the bug**

<!-- Please be as detailed as possible! -->

**How to reproduce**

<!-- If possible, include output of `pipx --verbose ...` -->

**Expected behavior**

<!-- What should have happened? -->
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
name: Feature request
about: Suggest an idea or new feature for this project

---

**How would this feature be useful?**

<!-- Describe any use cases this solves or frustrations it alleviates. -->

**Describe the solution you'd like**

<!-- If you have an idea of how to do this, write it here! -->

**Describe alternatives you've considered**

<!-- If there's some workaround or alternative solutions, let us know. -->
6 changes: 5 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<!-- add an 'x' in the brackets below -->
* [ ] I have added an entry to `docs/changelog.md`

- [ ] I have added an entry to `docs/changelog.md`

## Summary of changes

## Test plan

<!-- provide evidence of testing, preferably with command(s) that can be copy+pasted by others -->

Tested by running

```
# command(s) to exercise these changes
```
43 changes: 23 additions & 20 deletions .github/workflows/create_tests_package_lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@ name: Create tests package lists for offline tests
on:
workflow_dispatch:
concurrency:
group: check-${{ github.ref }}
group: create-tests-package-lists-${{ github.ref }}
cancel-in-progress: true
jobs:
create_package_lists:
name: Create package lists
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]

include:
- os: macos-latest
python-version: "3.12"
- os: windows-latest
python-version: "3.12"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Create lists
run: |
nox --non-interactive --session create_test_package_list-${{ matrix.python-version }} -- ./new_tests_packages
- name: Store reports as artifacts
uses: actions/upload-artifact@v3
with:
name: lists
path: ./new_tests_packages
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install nox
run: python -m pip install nox
- name: Create lists
run:
nox --non-interactive --session create_test_package_list-${{ matrix.python-version }} -- ./new_tests_packages
- name: Store reports as artifacts
uses: actions/upload-artifact@v3
with:
name: lists
path: ./new_tests_packages
82 changes: 40 additions & 42 deletions .github/workflows/exhaustive_package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Exhaustive Package Test (slow)
on:
workflow_dispatch:
concurrency:
group: check-${{ github.ref }}
group: exhaustive-package-test-${{ github.ref }}
cancel-in-progress: true
jobs:
test_all_packages:
Expand All @@ -15,51 +15,49 @@ jobs:
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Execute Tests
continue-on-error: true
run: |
nox --non-interactive --session test_all_packages-${{ matrix.python-version }}
- name: Store reports as artifacts
uses: actions/upload-artifact@v3
with:
name: reports-raw
path: reports
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install nox
run: python -m pip install nox
- name: Execute Tests
continue-on-error: true
run: nox --non-interactive --session test_all_packages-${{ matrix.python-version }}
- name: Store reports as artifacts
uses: actions/upload-artifact@v3
with:
name: reports-raw
path: reports

report_all_packages:
name: Collate test reports
needs: test_all_packages
runs-on: ubuntu-latest

steps:
- name: Get report artifacts
uses: actions/download-artifact@v3
with:
name: reports-raw
- name: Collate reports
run: |
ls # DEBUG
mkdir reports
cat all_packages_report_legend.txt > all_nodeps_reports_lf.txt
cat all_packages_nodeps_report_* >> all_nodeps_reports_lf.txt
tr -d '\r' < all_nodeps_reports_lf.txt > reports/all_nodeps_reports.txt
cat all_packages_nodeps_errors_* > all_nodeps_errors_lf.txt
tr -d '\r' < all_nodeps_errors_lf.txt > reports/all_nodeps_errors.txt
cat all_packages_report_legend.txt > all_deps_reports_lf.txt
cat all_packages_deps_report_* >> all_deps_reports_lf.txt
tr -d '\r' < all_deps_reports_lf.txt > reports/all_deps_reports.txt
cat all_packages_deps_errors_* > all_deps_errors_lf.txt
tr -d '\r' < all_deps_errors_lf.txt > reports/all_deps_errors.txt
- name: Store collated and raw reports as artifacts
uses: actions/upload-artifact@v3
with:
name: reports-final
path: reports
- name: Get report artifacts
uses: actions/download-artifact@v3
with:
name: reports-raw
- name: Collate reports
run: |
ls # DEBUG
mkdir reports
cat all_packages_report_legend.txt > all_nodeps_reports_lf.txt
cat all_packages_nodeps_report_* >> all_nodeps_reports_lf.txt
tr -d '\r' < all_nodeps_reports_lf.txt > reports/all_nodeps_reports.txt
cat all_packages_nodeps_errors_* > all_nodeps_errors_lf.txt
tr -d '\r' < all_nodeps_errors_lf.txt > reports/all_nodeps_errors.txt
cat all_packages_report_legend.txt > all_deps_reports_lf.txt
cat all_packages_deps_report_* >> all_deps_reports_lf.txt
tr -d '\r' < all_deps_reports_lf.txt > reports/all_deps_reports.txt
cat all_packages_deps_errors_* > all_deps_errors_lf.txt
tr -d '\r' < all_deps_errors_lf.txt > reports/all_deps_errors.txt
- name: Store collated and raw reports as artifacts
uses: actions/upload-artifact@v3
with:
name: reports-final
path: reports
101 changes: 39 additions & 62 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
#
# Needed GitHub Repository Secret:
# PYPI_PASSWORD - PyPI API token allowing write, release access to PyPI.
# Limit scope to just project.
# (See package.python.org example link above.)

name: tests

on:
Expand All @@ -14,10 +6,9 @@ on:
schedule:
- cron: "0 8 * * *"
concurrency:
group: check-${{ github.ref }}
group: tests-${{ github.ref }}
cancel-in-progress: true

# If changing default-python be sure to change job "tests" matrix: include: also
env:
default-python: "3.12"

Expand All @@ -36,57 +27,44 @@ jobs:
python-version: "3.12"

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Persistent Github pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip${{ matrix.python-version }}
- name: Persistent .pipx_tests/package_cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.pipx_tests/package_cache/${{ matrix.python-version }}
key: pipx-tests-package-cache-${{ runner.os }}-${{ matrix.python-version }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Execute Tests
run: |
nox --non-interactive --session tests-${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Persistent .pipx_tests/package_cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.pipx_tests/package_cache/${{ matrix.python-version }}
key: pipx-tests-package-cache-${{ runner.os }}-${{ matrix.python-version }}
- name: Install nox
run: python -m pip install nox
- name: Execute Tests
run: nox --non-interactive --session tests-${{ matrix.python-version }}

pypi-publish:
name: Publish pipx to PyPI on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
pip install nox
- name: Build sdist and wheel
run: |
nox --error-on-missing-interpreters --non-interactive --session build
- name: Publish to PyPi
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Install nox
run: pip install nox
- name: Build sdist and wheel
run: nox --error-on-missing-interpreters --non-interactive --session build
- name: Publish to PyPi
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}

build-zipapp:
name: Build zipapp
Expand All @@ -100,16 +78,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install shiv
run: |
python -m pip install --upgrade pip
pip install shiv
cache: "pip"
- name: Install shiv
run: pip install shiv
- name: Build zipapp
run: shiv -c pipx -o ./pipx.pyz git+https://github.com/pypa/pipx@${{ github.ref_name }}
- name: Test zipapp
run: |
python ./pipx.pyz --version
python ./pipx.pyz install black
- name: Show zipapp version
run: python ./pipx.pyz --version
- name: Test zipapp by installing black
run: python ./pipx.pyz install black
- name: Upload to releases
uses: softprops/action-gh-release@v1
with:
Expand Down

0 comments on commit 4e83145

Please sign in to comment.