{"id":19921494,"url":"https://github.com/pyapp-kit/workflows","last_synced_at":"2025-05-03T06:31:25.924Z","repository":{"id":205631259,"uuid":"714699409","full_name":"pyapp-kit/workflows","owner":"pyapp-kit","description":"Reusable Github workflows for CI, testing and deployment","archived":false,"fork":false,"pushed_at":"2025-05-01T16:03:11.000Z","size":92,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-01T17:23:25.610Z","etag":null,"topics":["reusable-workflows"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyapp-kit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-05T16:13:49.000Z","updated_at":"2025-05-01T16:03:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"c353680a-1a79-4e51-9f34-a3e06e7f38fd","html_url":"https://github.com/pyapp-kit/workflows","commit_stats":null,"previous_names":["pyapp-kit/workflows"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fworkflows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fworkflows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fworkflows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fworkflows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyapp-kit","download_url":"https://codeload.github.com/pyapp-kit/workflows/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252154738,"owners_count":21702983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["reusable-workflows"],"created_at":"2024-11-12T22:07:45.710Z","updated_at":"2025-05-03T06:31:20.914Z","avatar_url":"https://github.com/pyapp-kit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reusable workflows\n\nThis repo contains a set of reusable workflows for use in GitHub Actions.\n\nThey are used by repos in the pyapp-kit organization, but you may use them\nas well if you find them useful for your own projects.\n\n1. [test-pyrepo.yml](#run-python-tests) - use to run tests for your python package\n2. [test-dependents.yml](#test-dependent-packages) - use to test that updates to your\n   package don't break another package that depends on your package\n\n## Run python tests\n\n[`uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2`](.github/workflows/test-pyrepo.yml)\n\nStandard workflow to setup python and test a python package, in the following order:\n\n1. Checks out the repo using [`actions/checkout`](https://github.com/actions/checkout) with `inputs.fetch-depth`\n2. Runs [`actions/setup-python`](https://github.com/actions/setup-python) with `python-version`\n3. If `inputs.qt != ''`: Installs Qt libs using [tlambert03/setup-qt-libs](https://github.comtlambert03/setup-qt-libs)\n4. Installs dependencies using `pip install .[extras]`\n5. Runs `coverage run -m pytest ${{inputs.pytest-args}}` unless overridden.\n   - If `inputs.qt != ''`: Runs headlessly using [`aganders3/headless-gui`](https://github.com/actions/aganders3/headless-gui)\n6. Uploads coverage reports using [`codecov/codecov-action`](https://github.com/codecov/codecov-action)\n7. If `report-failures != ''` Opens an issue to report failures.  Useful for cron jobs for pre-release testing.\n\n### Inputs\n\n(All inputs are optional)\n\n\u003c!-- pyrepo-table --\u003e\n| Input | Type | Default | Description |\n| --- | --- | --- | --- |\n| python-version | string | 3.x | Python version to use. Passed to `actions/setup-python`. |\n| os | string | ubuntu-latest | Operating system to use. Passed to `runs-on:`. |\n| extras | string | test | Package extras to install (may use commas for multiples `'test,docs'`). If you don't have an extra named 'test' you should change this. |\n| pip-install-flags | string |  | Additional flags to pass to pip install. Can be used for `--editable`, `--no-deps`, etc. |\n| pip-install-pre-release | boolean | False | Whether to install pre-releases in the pip install phase with `--pre`. |\n| pip-install-min-reqs | boolean | False | Whether to install the *minimum* declared dependency versions. |\n| pip-pre-installs | string |  | Packages to install *before* calling `pip install .` |\n| pip-post-installs | string |  | Packages to install *after* `pip install .`. (these are called with `--force-reinstall`.) |\n| qt | string |  | Version of qt to install (or none if blank). Will also install qt-libs and run tests headlessly if not blank. |\n| fetch-depth | number | 1 | The number of commits to fetch. 0 indicates all history for all branches and tags. |\n| python-cache-dependency-path | string | pyproject.toml | passed to `actions/setup-python` |\n| pytest-args | string |  | Additional arguments to pass to pytest. Can be used to specify paths or for for `-k`, `-x`, etc. |\n| fail-on-coverage-error | boolean | True | Fail the build if codecov action fails. |\n| hatch-build-hooks-enable | boolean | False | Value for [`HATCH_BUILD_HOOKS_ENABLE`](https://hatch.pypa.io/latest/config/build/#environment-variables). |\n| report-failures | string |  | (true or false). Whether to create a GitHub issue when a test fails. If not set, will be true for scheduled runs, and false otherwise. |\n| cache-key | string |  | Cache key to use for caching. If not set, no caching will be used. |\n| cache-path | string |  | Path to cache. If not set, no caching will be used. |\n| cache-script | string |  | Script to run to create the cache. If not set, no caching will be used. |\n| coverage-upload | string | codecov | How to upload coverage data. Options are `'artifact'`, `'codecov'`. If using 'artifact', coverage must be sent to codecov in a separate workflow. (*see upload-coverage.yml*) |\n\n**Secrets:**\n\n| Input | Description |\n| --- | --- |\n| codecov_token | Token for codecov-action. Only used if `coverage-upload` is 'codecov'. |\n\u003c!-- /pyrepo-table --\u003e\n\nSee complete up-to-date list of options in [`test-pyrepo.yml`](.github/workflows/test-pyrepo.yml#L5)\n\n### Example usage\n\nYou can mix and match the inputs to suit your needs.  But here are\nsome common patterns.\n\n#### General pattern\n\n```yaml\nname: CI\n\njobs:\n  run_tests:\n    uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2\n    with:\n      os: ${{ matrix.os }}\n      python-version: ${{ matrix.python-version }}\n      extras: 'test'  # this is the default... but you can specify others\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [ubuntu-latest, macos-latest, windows-latest]\n        python-version: [\"3.10\", \"3.11\", \"3.12\"]\n```\n\n#### Testing depenency pre-releases on a schedule\n\nNote that the default value for `report-failures` is `${{ github.event_name == 'schedule' }}`, so you don't need to specify it unless you want to override the\ndefault.  However, you may wish to use\n`pip-install-pre-release: ${{ github.event_name == 'schedule' }}`\nto test pre-release versions when triggered by a cron job.\n\n```yaml\nname: CI\n\non:\n  schedule:\n    - cron: \"0 0 * * *\"\n\njobs:\n  run_tests:\n    uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2\n    with:\n      os: ${{ matrix.os }}\n      python-version: ${{ matrix.python-version }}\n      # Test pre-release versions when triggered by a schedule\n      # and open an issue if the tests fail\n      pip-install-pre-release: ${{ github.event_name == 'schedule' }}\n    strategy:\n      matrix:\n        os: [ubuntu-latest, macos-latest, windows-latest]\n        python-version: [\"3.10\", \"3.11\", \"3.12\"]\n```\n\n#### Testing things with Qt\n\nUse the `qt` input to:\n\n- install the specified Qt binding\n- install libraries on linux using [tlambert03/setup-qt-libs](https://github.com/tlambert03/setup-qt-libs)\n- run headless tests using [aganders3/headless-gui](https://github.com/aganders3/headless-gui)\n\n```yaml\nname: CI\n\njobs:\n  run_tests:\n    uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2\n    with:\n      os: ${{ matrix.os }}\n      python-version: ${{ matrix.python-version }}\n      qt: ${{ matrix.qt }}\n    strategy:\n      matrix:\n        os: [ubuntu-latest, macos-latest, windows-latest]\n        python-version: [\"3.10\", \"3.11\", \"3.12\"]\n        qt: [\"\", \"PyQt6\", \"PySide6\"]\n```\n\n#### Separate codecov reporting into a separate job\n\nBecause codecov can often fail, you might want to combine all\nreports and upload in a single step.  For this, change the\n`coverage-upload` input to `artifact` and add a separate job\nto upload the coverage report using [`upload-coverage.yml`](#combine-and-upload-coverage-artifacts).\n\n```yaml\nname: CI\n\njobs:\n  tests:\n    uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2\n    with:\n      os: ${{ matrix.os }}\n      python-version: ${{ matrix.python-version }}\n      # changing this to \"artifact\" prevents uploading to codecov here,\n      # instead it uploads an artifact with the coverage data\n      coverage-upload: artifact\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [ubuntu-latest, macos-latest, windows-latest]\n        python-version: [\"3.10\", \"3.11\", \"3.12\"]\n\n  # now add an additional job to combine and upload the coverage\n  upload_coverage:\n    if: always()\n    needs: [tests]\n    uses: pyapp-kit/workflows/.github/workflows/upload-coverage.yml@v2\n    secrets:\n      codecov_token: ${{ secrets.CODECOV_TOKEN }}\n```\n\n## Test Dependent Packages\n\n[`uses: pyapp-kit/workflows/.github/workflows/test-dependents.yml@v2`](.github/workflows/test-dependents.yml)\n\nThis workflow is useful when your package is a dependency of other packages, and you\nwould like to ensure that your changes don't break those packages.\n\n1. Checks out the \"host\" repo (the repo using this workflow) using [`actions/checkout`](https://github.com/actions/checkout).\n2. Checks out `dependency-repo` @ `dependency-ref` using [`actions/checkout`](https://github.com/actions/checkout).\n3. Runs [`actions/setup-python`](https://github.com/actions/setup-python) with `python-version`\n4. If `inputs.qt != ''`: Installs Qt libs using [tlambert03/setup-qt-libs](https://github.comtlambert03/setup-qt-libs)\n5. Installs dependencies for `dependency-repo` followed by the host repo.\n6. Runs `pytest inputs.pytest-args` (add specific paths or `-k` flags here)\n   - If `inputs.qt != ''`: Runs headlessly using [`aganders3/headless-gui`](https://github.com/actions/aganders3/headless-gui)\n\n### Inputs\n\n(Only `dependency-repo` is required)\n\n\u003c!-- deps-table --\u003e\n| Input | Type | Default | Description |\n| --- | --- | --- | --- |\n| dependency-repo | string |  | Repository name with owner of package to test (org/repo). |\n| dependency-ref | string |  | Ref to checkout in dependency-repo. Defaults to HEAD in default branch. |\n| python-version | string | 3.x | Python version to use. Passed to `actions/setup-python`. |\n| os | string | ubuntu-latest | Operating system to use. Passed to `runs-on:`. |\n| host-extras | string |  | Extras to use when installing host (package running this workflow). |\n| dependency-extras | string | test | Extras to use when installing dependency-repo. |\n| qt | string |  | Version of Qt to install. |\n| post-install-cmd | string |  | Command(s) to run after installing dependencies. |\n| pytest-args | string |  | Additional arguments to pass to pytest. Can be used to specify paths or for for `-k`, `-x`, etc. |\n\u003c!-- /deps-table --\u003e\n\n### Example dependecy test\n\nHere's an example where package Package B depends on Package A.\n\nThis workflow would go into Package A's repository, and tests that changes made to Package A don't break\nPackage B.\n\n```yaml\nname: CI\n\njobs:\n  test-package-b:\n    uses: pyapp-kit/workflows/.github/workflows/test-dependents.yml@v2\n    with:\n      os: ${{ matrix.os }}\n      python-version: ${{ matrix.python-version }}\n      dependency-repo: some-org/package-b\n      dependency-ref: ${{ matrix.package-b-version }}\n      dependency-extras: \"test\"  # Extras to use when installing dependency-repo.\n    strategy:\n      matrix:\n        os: [ubuntu-latest, windows-latest]\n        python-version: [\"3.10\", \"3.12\"]\n        package-b-version: [\"\", \"v0.5.0\"]\n```\n\n## Combine and Upload Coverage Artifacts\n\n[`uses: pyapp-kit/workflows/.github/workflows/upload-coverage.yml@v2`](.github/workflows/upload-coverage.yml)\n\nThis workflow is designed to be used in conjunction with the `test-pyrepo.yml` workflow\nwhen the `coverage-upload` input is set to `artifact`.\n\n\u003c!-- coverage-table --\u003e\n| Input | Type | Default | Description |\n| --- | --- | --- | --- |\n| fail-on-coverage-error | boolean | True | Fail if codecov action fails. |\n| artifact-pattern | string | covreport-* | glob pattern to the artifacts that should be downloaded for coverage reports. This should match the `name` you used for the `upload-artifact` step in the job that generates the coverage reports. (*This default matches the name in test-pyrepo.yml*) |\n\n**Secrets:**\n\n| Input | Description |\n| --- | --- |\n| codecov_token | Token for codecov-action. |\n\u003c!-- /coverage-table --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyapp-kit%2Fworkflows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyapp-kit%2Fworkflows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyapp-kit%2Fworkflows/lists"}