From 4e8314571f4a6ee8a82bb70bce181759260895d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Sat, 2 Dec 2023 21:55:22 -0800 Subject: [PATCH] Simplify and improve Github Actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- .github/ISSUE_TEMPLATE/bug.md | 4 +- .github/ISSUE_TEMPLATE/feature_request.md | 4 +- .github/PULL_REQUEST_TEMPLATE.md | 6 +- .../workflows/create_tests_package_lists.yml | 43 ++++---- .github/workflows/exhaustive_package_test.yml | 82 +++++++------- .github/workflows/tests.yml | 101 +++++++----------- 6 files changed, 113 insertions(+), 127 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 6ec0cbc10d..21f55bfcfc 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,7 +1,6 @@ --- name: Bug about: Report a bug or unexpected behavior. - --- **Describe the bug** + **How to reproduce** + **Expected behavior** + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 143b301d5d..a9fc0b9b52 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,14 +1,16 @@ --- name: Feature request about: Suggest an idea or new feature for this project - --- **How would this feature be useful?** + **Describe the solution you'd like** + **Describe alternatives you've considered** + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3b16b09b24..72d0e0e3d3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,15 @@ -* [ ] I have added an entry to `docs/changelog.md` + +- [ ] I have added an entry to `docs/changelog.md` ## Summary of changes ## Test plan + + Tested by running + ``` # command(s) to exercise these changes ``` diff --git a/.github/workflows/create_tests_package_lists.yml b/.github/workflows/create_tests_package_lists.yml index db472412ca..997ae0704f 100644 --- a/.github/workflows/create_tests_package_lists.yml +++ b/.github/workflows/create_tests_package_lists.yml @@ -2,7 +2,7 @@ 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: @@ -10,24 +10,27 @@ jobs: 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 diff --git a/.github/workflows/exhaustive_package_test.yml b/.github/workflows/exhaustive_package_test.yml index cf40bc833e..a4891224e2 100644 --- a/.github/workflows/exhaustive_package_test.yml +++ b/.github/workflows/exhaustive_package_test.yml @@ -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: @@ -15,24 +15,22 @@ 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 @@ -40,26 +38,26 @@ jobs: 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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d813a2a110..5e3fcade8a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: @@ -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" @@ -36,32 +27,21 @@ 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 @@ -69,24 +49,22 @@ jobs: 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/gh-action-pypi-publish@v1.8.11 - 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/gh-action-pypi-publish@v1.8.11 + with: + user: __token__ + password: ${{ secrets.pypi_password }} build-zipapp: name: Build zipapp @@ -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: