From 7602e42f5bf9a85b5fa1dc25a85b093ceb18dca2 Mon Sep 17 00:00:00 2001 From: YisusChrist Date: Sat, 10 Aug 2024 20:30:39 +0200 Subject: [PATCH] chore: add github files for actions --- .github/CODE_OF_CONDUCT.md | 20 +-- .github/CONTRIBUTING.md | 106 ++++++------ .github/ISSUE_TEMPLATE/bug_report.yml | 106 ++++++------ .github/ISSUE_TEMPLATE/config.yml | 18 +- .github/ISSUE_TEMPLATE/feature_request.yml | 58 +++---- .github/ISSUE_TEMPLATE/question.yml | 109 ++++++------ .github/dependabot.yml | 21 ++- .github/labels.yml | 66 ++++++++ .github/release-drafter.yml | 29 ++++ .../workflows/automerge-dependabot-prs.yml | 23 +++ .github/workflows/constraints.txt | 5 + .github/workflows/labeler.yml | 19 +++ .github/workflows/release.yml | 79 +++++++++ .github/workflows/tests.yml | 158 ++++++++++++++++++ 14 files changed, 605 insertions(+), 212 deletions(-) create mode 100644 .github/labels.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/automerge-dependabot-prs.yml create mode 100644 .github/workflows/constraints.txt create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index d55fdd4..f0b2328 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or advances of +- The use of sexualized language or imagery, and sexual attention or advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 4a40661..3dc7952 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -127,74 +127,74 @@ to allow this: type(scope)!: subject ``` -- `type`: the type of the commit is one of the following: - - - `feat`: new features. - - `fix`: bug fixes. - - `docs`: documentation changes. - - `refactor`: refactor of a particular code section without introducing - new features or bug fixes. - - `style`: code style improvements. - - `perf`: performance improvements. - - `test`: changes to the test suite. - - `ci`: changes to the CI system. - - `build`: changes to the build system (we don't yet have one so this shouldn't apply). - - `chore`: for other changes that don't match previous types. This doesn't appear - in the changelog. - -- `scope`: section of the codebase that the commit makes changes to. If it makes changes to - many sections, or if no section in particular is modified, leave blank without the parentheses. - Examples: - - - Commit that changes the `git` plugin: +- `type`: the type of the commit is one of the following: - ``` - feat(git): add alias for `git commit` - ``` + - `feat`: new features. + - `fix`: bug fixes. + - `docs`: documentation changes. + - `refactor`: refactor of a particular code section without introducing + new features or bug fixes. + - `style`: code style improvements. + - `perf`: performance improvements. + - `test`: changes to the test suite. + - `ci`: changes to the CI system. + - `build`: changes to the build system (we don't yet have one so this shouldn't apply). + - `chore`: for other changes that don't match previous types. This doesn't appear + in the changelog. - - Commit that changes many plugins: +- `scope`: section of the codebase that the commit makes changes to. If it makes changes to + many sections, or if no section in particular is modified, leave blank without the parentheses. + Examples: - ``` - style: fix inline declaration of arrays - ``` + - Commit that changes the `git` plugin: -- `!`: this goes after the `scope` (or the `type` if scope is empty), to indicate that the commit - introduces breaking changes. + ``` + feat(git): add alias for `git commit` + ``` - Optionally, you can specify a message that the changelog tool will display to the user to indicate - what's changed and what they can do to deal with it. You can use multiple lines to type this message; - the changelog parser will keep reading until the end of the commit message or until it finds an empty - line. + - Commit that changes many plugins: - Example (made up): + ``` + style: fix inline declaration of arrays + ``` - ``` - style(theme)!: change dirty git repo glyph +- `!`: this goes after the `scope` (or the `type` if scope is empty), to indicate that the commit + introduces breaking changes. - BREAKING CHANGE: the glyph to indicate when a git repository is dirty has - changed from a Powerline character to a standard UTF-8 emoji. + Optionally, you can specify a message that the changelog tool will display to the user to indicate + what's changed and what they can do to deal with it. You can use multiple lines to type this message; + the changelog parser will keep reading until the end of the commit message or until it finds an empty + line. - Fixes #420 + Example (made up): - Co-authored-by: Username - ``` + ``` + style(theme)!: change dirty git repo glyph + + BREAKING CHANGE: the glyph to indicate when a git repository is dirty has + changed from a Powerline character to a standard UTF-8 emoji. -- `subject`: a brief description of the changes. This will be displayed in the changelog. If you need - to specify other details, you can use the commit body, but it won't be visible. + Fixes #420 - Formatting tricks: the commit subject may contain: + Co-authored-by: Username + ``` - - Links to related issues or PRs by writing `#issue`. This will be highlighted by the changelog tool: +- `subject`: a brief description of the changes. This will be displayed in the changelog. If you need + to specify other details, you can use the commit body, but it won't be visible. - ``` - feat(archlinux): add support for aura AUR helper (#9467) - ``` + Formatting tricks: the commit subject may contain: - - Formatted inline code by using backticks: the text between backticks will also be highlighted by - the changelog tool: - ``` - feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774) - ``` + - Links to related issues or PRs by writing `#issue`. This will be highlighted by the changelog tool: + + ``` + feat(archlinux): add support for aura AUR helper (#9467) + ``` + + - Formatted inline code by using backticks: the text between backticks will also be highlighted by + the changelog tool: + ``` + feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774) + ``` ### Style diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d2741c0..d9b6c68 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -2,57 +2,57 @@ name: 🐛 Report a bug description: Create a report to help us improve 🤕 labels: ["bug"] assignees: - - YisusChrist + - YisusChrist body: - - type: markdown - attributes: - value: | - ## Self Check - - Look for similar errors in existing [GitHub Issues](https://github.com/YisusChrist/AnimeSnap/issues?q=is%3Aissue) (open or closed). - - Take a look at the [documentation](https://github.com/YisusChrist/AnimeSnap/wiki) for help. - - type: textarea - validations: - required: true - attributes: - label: Describe the bug - description: A clear description of what the bug is. - - type: textarea - validations: - required: true - attributes: - label: Steps to reproduce - description: | - Steps to reproduce the problem. - placeholder: | - For example: - 1. Execute with options '...' - 2. Check output '...' - 3. See error - - type: textarea - validations: - required: true - attributes: - label: Expected behavior - description: A brief description of what should happen. - - type: textarea - attributes: - label: Screenshots and recordings - description: | - If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/ - - type: input - validations: - required: true - attributes: - label: OS / Linux distribution - placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15... - - type: input - validations: - required: true - attributes: - label: AnimeSnap version - description: Run `AnimeSnap -V` to check. - placeholder: "1.0" - - type: textarea - attributes: - label: Additional context - description: Add any other context about the problem here. This can be path, platform, shell... + - type: markdown + attributes: + value: | + ## Self Check + - Look for similar errors in existing [GitHub Issues](https://github.com/YisusChrist/AnimeSnap/issues?q=is%3Aissue) (open or closed). + - Take a look at the [documentation](https://github.com/YisusChrist/AnimeSnap/wiki) for help. + - type: textarea + validations: + required: true + attributes: + label: Describe the bug + description: A clear description of what the bug is. + - type: textarea + validations: + required: true + attributes: + label: Steps to reproduce + description: | + Steps to reproduce the problem. + placeholder: | + For example: + 1. Execute with options '...' + 2. Check output '...' + 3. See error + - type: textarea + validations: + required: true + attributes: + label: Expected behavior + description: A brief description of what should happen. + - type: textarea + attributes: + label: Screenshots and recordings + description: | + If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/ + - type: input + validations: + required: true + attributes: + label: OS / Linux distribution + placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15... + - type: input + validations: + required: true + attributes: + label: AnimeSnap version + description: Run `AnimeSnap -V` to check. + placeholder: "1.0" + - type: textarea + attributes: + label: Additional context + description: Add any other context about the problem here. This can be path, platform, shell... diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 6147295..bd8b95d 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: false contact_links: - - name: Contributing to AnimeSnap - url: https://github.com/YisusChrist/AnimeSnap/blob/main/CONTRIBUTING.md - about: Guidelines for how to report an issue. - - name: Support - url: https://github.com/YisusChrist/AnimeSnap/discussions - about: Ask the community for support - - name: Documentation - url: https://github.com/YisusChrist/AnimeSnap/wiki - about: Many questions might be already answered here. + - name: Contributing to AnimeSnap + url: https://github.com/YisusChrist/AnimeSnap/blob/main/CONTRIBUTING.md + about: Guidelines for how to report an issue. + - name: Support + url: https://github.com/YisusChrist/AnimeSnap/discussions + about: Ask the community for support + - name: Documentation + url: https://github.com/YisusChrist/AnimeSnap/wiki + about: Many questions might be already answered here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index ba890fb..7f2f356 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -2,33 +2,33 @@ name: 🚀 Feature request description: Suggest a feature/idea for this project 💡 labels: ["feature"] assignees: - - YisusChrist + - YisusChrist body: - - type: markdown - attributes: - value: | - ## Self Check - - Look for similar features in existing [GitHub Issues](https://github.com/YisusChrist/AnimeSnap/issues?q=is%3Aissue) (open or closed). - - type: textarea - attributes: - label: If the feature solves a problem you have, specify it here. - description: A description of what the problem is. - placeholder: Ex. I'm always frustrated when... - - type: textarea - attributes: - label: Describe the proposed feature. - description: A description of what you want to happen. Be as specific as possible. - validations: - required: true - - type: textarea - attributes: - label: Describe alternatives you've considered - description: A description of any alternative solutions or features you've considered. This can also include other plugins or themes. - - type: textarea - attributes: - label: Additional context - description: Add any other context, screenshots or Discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. - - type: textarea - attributes: - label: Related Issues - description: Is there any open or closed issues that is related to this feature request? If so please link them below! + - type: markdown + attributes: + value: | + ## Self Check + - Look for similar features in existing [GitHub Issues](https://github.com/YisusChrist/AnimeSnap/issues?q=is%3Aissue) (open or closed). + - type: textarea + attributes: + label: If the feature solves a problem you have, specify it here. + description: A description of what the problem is. + placeholder: Ex. I'm always frustrated when... + - type: textarea + attributes: + label: Describe the proposed feature. + description: A description of what you want to happen. Be as specific as possible. + validations: + required: true + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A description of any alternative solutions or features you've considered. This can also include other plugins or themes. + - type: textarea + attributes: + label: Additional context + description: Add any other context, screenshots or Discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. + - type: textarea + attributes: + label: Related Issues + description: Is there any open or closed issues that is related to this feature request? If so please link them below! diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index d44d6f4..ac5d2fc 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -1,58 +1,57 @@ -name: ❓ Question -description: If you have a question about how to use AnimeSnap that's not well covered by our documentation +name: ❓ Ask a question +description: Submit a question to get help or clarification 🙋‍♂️ labels: ["question"] assignees: - - YisusChrist + - YisusChrist body: - - type: markdown - attributes: - value: | - ## Self Check - - Look for similar errors in existing [GitHub Issues](https://github.com/YisusChrist/AnimeSnap/issues?q=is%3Aissue) (open or closed). - - Take a look at the [documentation](https://github.com/YisusChrist/AnimeSnap/wiki) for help. - - type: textarea - validations: - required: true - attributes: - label: Describe the bug - description: A clear description of what the bug is. - - type: textarea - validations: - required: true - attributes: - label: Steps to reproduce - description: | - Steps to reproduce the problem. - placeholder: | - For example: - 1. Execute with options '...' - 2. Check output '...' - 3. See error - - type: textarea - validations: - required: true - attributes: - label: Expected behavior - description: A brief description of what should happen. - - type: textarea - attributes: - label: Screenshots and recordings - description: | - If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/ - - type: input - validations: - required: true - attributes: - label: OS / Linux distribution - placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15... - - type: input - validations: - required: true - attributes: - label: AnimeSnap version - description: Run `AnimeSnap -V` to check. - placeholder: "1.0" - - type: textarea - attributes: - label: Additional context - description: Add any other context about the problem here. This can be path, platform, shell... + - type: markdown + attributes: + value: | + ## Self Check + - Check the [documentation](https://github.com/YisusChrist/codewars-solver/wiki) and [GitHub Issues](https://github.com/YisusChrist/codewars-solver/issues?q=is%3Aissue) to see if your question has already been answered. + - type: textarea + validations: + required: true + attributes: + label: Question + description: Clearly state your question. + placeholder: "What is the purpose of the `codewars-solver` tool?" + - type: textarea + validations: + required: true + attributes: + label: Context + description: | + Provide any necessary context for your question. For example, explain the scenario or code that led to your question. + placeholder: | + I was trying to use the tool to solve a problem with the following code: + ```python + # code snippet here + ``` + - type: textarea + validations: + required: true + attributes: + label: Expected outcome or clarification needed + description: | + What do you expect to achieve, or what specific clarification are you seeking? + placeholder: | + I expected the tool to return a different output. + Can you clarify how the solver handles edge cases? + - type: input + validations: + required: true + attributes: + label: OS / Linux distribution + placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15... + - type: input + validations: + required: true + attributes: + label: codewars-solver version + description: Run `codewars-solver -V` to check. + placeholder: "1.0" + - type: textarea + attributes: + label: Additional context or resources + description: Add any other context or references (e.g., links, code snippets) that may help in answering your question. diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 90e05c4..03bc6ed 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,22 @@ version: 2 updates: - - package-ecosystem: "github-actions" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: github-actions + directory: "/" schedule: - interval: "weekly" + interval: daily + - package-ecosystem: pip + directory: "/.github/workflows" + schedule: + interval: daily + - package-ecosystem: pip + directory: "/docs" + schedule: + interval: daily + - package-ecosystem: pip + directory: "/" + schedule: + interval: daily + versioning-strategy: lockfile-only + allow: + - dependency-type: "all" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..f7f83aa --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,66 @@ +--- +# Labels names are important as they are used by Release Drafter to decide +# regarding where to record them in changelog or if to skip them. +# +# The repository labels will be automatically configured using this file and +# the GitHub Action https://github.com/marketplace/actions/github-labeler. +- name: breaking + description: Breaking Changes + color: bfd4f2 +- name: bug + description: Something isn't working + color: d73a4a +- name: build + description: Build System and Dependencies + color: bfdadc +- name: ci + description: Continuous Integration + color: 4a97d6 +- name: dependencies + description: Pull requests that update a dependency file + color: 0366d6 +- name: documentation + description: Improvements or additions to documentation + color: 0075ca +- name: duplicate + description: This issue or pull request already exists + color: cfd3d7 +- name: enhancement + description: New feature or request + color: a2eeef +- name: github_actions + description: Pull requests that update Github_actions code + color: "000000" +- name: good first issue + description: Good for newcomers + color: 7057ff +- name: help wanted + description: Extra attention is needed + color: 008672 +- name: invalid + description: This doesn't seem right + color: e4e669 +- name: performance + description: Performance + color: "016175" +- name: python + description: Pull requests that update Python code + color: 2b67c6 +- name: question + description: Further information is requested + color: d876e3 +- name: refactoring + description: Refactoring + color: ef67c4 +- name: removal + description: Removals and Deprecations + color: 9ae7ea +- name: style + description: Style + color: c120e5 +- name: testing + description: Testing + color: b1fc6f +- name: wontfix + description: This will not be worked on + color: ffffff diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..7a04410 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,29 @@ +categories: + - title: ":boom: Breaking Changes" + label: "breaking" + - title: ":rocket: Features" + label: "enhancement" + - title: ":fire: Removals and Deprecations" + label: "removal" + - title: ":beetle: Fixes" + label: "bug" + - title: ":racehorse: Performance" + label: "performance" + - title: ":rotating_light: Testing" + label: "testing" + - title: ":construction_worker: Continuous Integration" + label: "ci" + - title: ":books: Documentation" + label: "documentation" + - title: ":hammer: Refactoring" + label: "refactoring" + - title: ":lipstick: Style" + label: "style" + - title: ":package: Dependencies" + labels: + - "dependencies" + - "build" +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/automerge-dependabot-prs.yml b/.github/workflows/automerge-dependabot-prs.yml new file mode 100644 index 0000000..5b24730 --- /dev/null +++ b/.github/workflows/automerge-dependabot-prs.yml @@ -0,0 +1,23 @@ +name: Auto-merge Dependabot PRs + +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Approve a PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --rebase "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt new file mode 100644 index 0000000..127ea4d --- /dev/null +++ b/.github/workflows/constraints.txt @@ -0,0 +1,5 @@ +pip==24.2 +nox==2024.4.15 +nox-poetry==1.0.3 +poetry==1.8.3 +virtualenv==20.26.3 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..173926f --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,19 @@ +name: Labeler + +on: + push: + branches: + - main + - master + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Run Labeler + uses: crazy-max/ghaction-github-labeler@v5.0.0 + with: + skip-delete: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9a1d871 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,79 @@ +name: Release + +on: + push: + branches: + - main + - master + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Upgrade pip + run: | + pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip + pip --version + + - name: Install Poetry + run: | + pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt poetry + poetry --version + + - name: Check if there is a parent commit + id: check-parent-commit + run: | + echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)" + + - name: Detect and tag new version + id: check-version + if: steps.check-parent-commit.outputs.sha + uses: salsify/action-detect-and-tag-new-version@v2.0.3 + with: + version-command: | + bash -o pipefail -c "poetry version | awk '{ print \$2 }'" + + - name: Bump version for developmental release + if: "! steps.check-version.outputs.tag" + run: | + poetry version patch && + version=$(poetry version | awk '{ print $2 }') && + poetry version $version.dev.$(date +%s) + + - name: Build package + run: | + poetry build --ansi + + - name: Publish package on PyPI + if: steps.check-version.outputs.tag + uses: pypa/gh-action-pypi-publish@v1.9.0 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + + - name: Publish package on TestPyPI + if: "! steps.check-version.outputs.tag" + uses: pypa/gh-action-pypi-publish@v1.9.0 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + - name: Publish the release notes + uses: release-drafter/release-drafter@v6.0.0 + with: + publish: ${{ steps.check-version.outputs.tag != '' }} + tag: ${{ steps.check-version.outputs.tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..7ebb146 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,158 @@ +name: Tests + +on: + - push + - pull_request + +jobs: + tests: + name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - { python: "3.10", os: "ubuntu-latest", session: "mypy" } + - { python: "3.10", os: "ubuntu-latest", session: "tests" } + - { python: "3.11", os: "ubuntu-latest", session: "mypy" } + - { python: "3.11", os: "ubuntu-latest", session: "tests" } + - { python: "3.12", os: "macos-latest", session: "tests" } + #- { python: "3.12", os: "ubuntu-latest", session: "docs-build" } + - { python: "3.12", os: "ubuntu-latest", session: "mypy" } + - { python: "3.12", os: "ubuntu-latest", session: "pre-commit" } + #- { python: "3.12", os: "ubuntu-latest", session: "safety" } + - { python: "3.12", os: "ubuntu-latest", session: "tests" } + - { python: "3.12", os: "ubuntu-latest", session: "typeguard" } + - { python: "3.12", os: "ubuntu-latest", session: "xdoctest" } + - { python: "3.12", os: "windows-latest", session: "tests" } + - { python: "3.9", os: "ubuntu-latest", session: "mypy" } + - { python: "3.9", os: "ubuntu-latest", session: "tests" } + + env: + NOXSESSION: ${{ matrix.session }} + FORCE_COLOR: "1" + PRE_COMMIT_COLOR: "always" + + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5.1.1 + with: + python-version: ${{ matrix.python }} + + - name: Upgrade pip + run: | + pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip + pip --version + + - name: Upgrade pip in virtual environments + shell: python + run: | + import os + import pip + + with open(os.environ["GITHUB_ENV"], mode="a") as io: + print(f"VIRTUALENV_PIP={pip.__version__}", file=io) + + - name: Install Poetry + run: | + pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" poetry + poetry --version + + - name: Install Nox + run: | + pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox + pipx inject --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox nox-poetry + nox --version + + - name: Compute pre-commit cache key + if: matrix.session == 'pre-commit' + id: pre-commit-cache + shell: python + run: | + import hashlib + import subprocess + import sys + + python = "py{}.{}".format(*sys.version_info[:2]) + payload = sys.version.encode() + sys.executable.encode() + digest = hashlib.sha256(payload).hexdigest() + result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8]) + cmd = f'echo "result={result}" >> $GITHUB_OUTPUT' + subprocess.run(cmd, shell=True) + + - name: Restore pre-commit cache + uses: actions/cache@v4 + if: matrix.session == 'pre-commit' + with: + path: ~/.cache/pre-commit + key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }} + restore-keys: | + ${{ steps.pre-commit-cache.outputs.result }}- + + - name: Run Nox + run: | + nox --python=${{ matrix.python }} + + - name: Upload coverage data + if: always() && matrix.session == 'tests' + uses: "actions/upload-artifact@v4" + with: + name: coverage-data-${{ matrix.os }}-${{ matrix.python }} + path: ".coverage.*" + + - name: Upload documentation + if: matrix.session == 'docs-build' + uses: actions/upload-artifact@v4 + with: + name: docs + path: docs/_build + + coverage: + runs-on: ubuntu-latest + needs: tests + steps: + - name: Check out the repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Set up Python + uses: actions/setup-python@v5.1.1 + with: + python-version: "3.11" + + - name: Upgrade pip + run: | + pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip + pip --version + + - name: Install Poetry + run: | + pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" poetry + poetry --version + + - name: Install Nox + run: | + pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox + pipx inject --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox nox-poetry + nox --version + + - name: Download coverage data + uses: actions/download-artifact@v4 + with: + pattern: coverage-data-* + merge-multiple: true + + - name: Combine coverage data and display human readable report + run: | + nox --session=coverage + + - name: Create coverage report + run: | + nox --session=coverage -- xml + + - name: Upload coverage report + uses: codecov/codecov-action@v4.5.0