From 6ddfc2d2ef0cde47ede22ddb13d7e6fbec238cd2 Mon Sep 17 00:00:00 2001 From: Dario Curreri Date: Sat, 21 Sep 2024 15:23:45 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=92=AA=20Add=20workflow=20to=20aut?= =?UTF-8?q?omatize=20release=20#18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 33 ++++++++++++++++++++++++ .github/workflows/test_simple.yml | 2 +- .github/workflows/test_with_options.yml | 7 +++-- .github/workflows/test_with_output.yml | 7 +++-- .github/workflows/test_with_paths.yml | 11 ++++---- .github/workflows/test_with_show.yml | 9 +++---- .github/workflows/validate_action.yml | 2 +- .pre-commit-config.yaml | 34 +++++++++++++++---------- README.md | 18 ++++++------- environment.yml | 14 +++++----- noxfile.py | 33 ++++++++++++++++++++++++ pyproject.toml | 5 ++++ setup.cfg | 8 ------ 13 files changed, 125 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 noxfile.py create mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..26c23b8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release + +on: + push: + branches: + - master + + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Checkout origin repo + uses: actions/checkout@v4.1.7 + + - name: Set up Python + uses: actions/setup-python@main + with: + python-version: "3.12" + + - name: Install Python dependencies + run: pip install --disable-pip-version-check nox pyyaml + + - name: Update tags + id: tags + run: nox -s update-tags + + - name: Create Github release + uses: softprops/action-gh-release@v2.0.8 + with: + tag_name: ${{ steps.tags.outputs.tag }} diff --git a/.github/workflows/test_simple.yml b/.github/workflows/test_simple.yml index 0ac30eb..9efde81 100644 --- a/.github/workflows/test_simple.yml +++ b/.github/workflows/test_simple.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main diff --git a/.github/workflows/test_with_options.yml b/.github/workflows/test_with_options.yml index 42bbdde..c11f1ef 100644 --- a/.github/workflows/test_with_options.yml +++ b/.github/workflows/test_with_options.yml @@ -1,13 +1,12 @@ name: "[TEST] with options" on: - workflow_dispatch: - branches: - - develop push: branches: - develop + workflow_dispatch: + jobs: options: runs-on: ubuntu-latest @@ -17,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main diff --git a/.github/workflows/test_with_output.yml b/.github/workflows/test_with_output.yml index 21c3f58..b583824 100644 --- a/.github/workflows/test_with_output.yml +++ b/.github/workflows/test_with_output.yml @@ -1,13 +1,12 @@ name: "[TEST] with output" on: - workflow_dispatch: - branches: - - develop push: branches: - develop + workflow_dispatch: + jobs: output: runs-on: ubuntu-latest @@ -17,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main diff --git a/.github/workflows/test_with_paths.yml b/.github/workflows/test_with_paths.yml index 138089a..1fd3f87 100644 --- a/.github/workflows/test_with_paths.yml +++ b/.github/workflows/test_with_paths.yml @@ -1,13 +1,12 @@ name: "[TEST] with paths" on: - workflow_dispatch: - branches: - - develop push: branches: - develop + workflow_dispatch: + jobs: single-path: runs-on: ubuntu-latest @@ -17,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main @@ -33,7 +32,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main @@ -51,7 +50,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main diff --git a/.github/workflows/test_with_show.yml b/.github/workflows/test_with_show.yml index 0758aa7..ac7b41c 100644 --- a/.github/workflows/test_with_show.yml +++ b/.github/workflows/test_with_show.yml @@ -1,13 +1,12 @@ name: "[TEST] with show" on: - workflow_dispatch: - branches: - - develop push: branches: - develop + workflow_dispatch: + jobs: show-all: runs-on: ubuntu-latest @@ -17,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main @@ -33,7 +32,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main diff --git a/.github/workflows/validate_action.yml b/.github/workflows/validate_action.yml index 71bf52c..7e2aeec 100644 --- a/.github/workflows/validate_action.yml +++ b/.github/workflows/validate_action.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@main with: - python-version: "3.10" + python-version: "3.12" - name: Run tests uses: dariocurr/pytest-summary@main diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1fc3432..06dfd6d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,23 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: + - id: check-ast + - id: check-builtin-literals - id: check-case-conflict - id: check-docstring-first - id: check-json - id: check-merge-conflict - id: check-symlinks + - id: check-toml - id: check-vcs-permalinks + - id: check-xml + - id: check-yaml + args: ["--unsafe"] + - id: debug-statements - id: destroyed-symlinks + - id: detect-aws-credentials + args: [--allow-missing-credentials] - id: detect-private-key - id: end-of-file-fixer - id: fix-byte-order-marker @@ -16,26 +25,23 @@ repos: - id: name-tests-test args: [--pytest-test-first] - id: no-commit-to-branch - args: [-b, main] + args: [-b, master, -b, qa] - id: pretty-format-json - args: [--autofix, --no-sort-keys] + args: [--autofix] - id: sort-simple-yaml - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 23.3.0 + - repo: https://github.com/gitleaks/gitleaks + rev: v8.18.4 hooks: - - id: black + - id: gitleaks - - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.1 hooks: - - id: flake8 - - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort + - id: ruff + args: [ --fix ] + - id: ruff-format ci: autoupdate_branch: develop diff --git a/README.md b/README.md index d0bb395..9695cb8 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ This helps you understand at-a-glance the impact to the changes in your pull req Pillars: -* Integrates tests easily with your existing GitHub Actions workflow -* Produces summaries from `pytest` output -* Customizable to show just a summary, just failed tests, or all test results. +* Integrates tests easily with your existing GitHub Actions workflow +* Produces summaries from `pytest` output +* Customizable to show just a summary, just failed tests, or all test results. --- @@ -32,7 +32,7 @@ A tutorial to learn how to use this action can be found [here](https://dariocurr >- name: Set up Python > uses: actions/setup-python@main > with: -> python-version: "3.10" +> python-version: "3.12" >``` To set up the `pytest` summary action, just add the following line of YAML to your GitHub Actions workflow: @@ -47,7 +47,7 @@ To set up the `pytest` summary action, just add the following line of YAML to yo Options are specified on the [`with`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswith) map of the action. -* **extensions**: the `pytest` extensions to install along `pytest` (optional, by default no extensions are included) +* **extensions**: the `pytest` extensions to install along `pytest` (optional, by default no extensions are included) For example: ```yaml @@ -56,7 +56,7 @@ For example: extensions: pytest-asyncio pytest-cov ``` -* **`options`**: the `pytest` options (optional, by default no options are include) +* **`options`**: the `pytest` options (optional, by default no options are include) To specify them correctly, please have a look [here](https://docs.pytest.org). For example: ```yaml @@ -65,7 +65,7 @@ To specify them correctly, please have a look [here](https://docs.pytest.org). F options: -vv -s ``` -* **`output`**: the path where to create the output (optional, by default the output will be the workflow summary) +* **`output`**: the path where to create the output (optional, by default the output will be the workflow summary) The path to the GitHub-flavored Markdown (GFM) output file to populate with the `pytest` summary markdown data. For example: ```yaml @@ -74,7 +74,7 @@ To specify them correctly, please have a look [here](https://docs.pytest.org). F output: test-summary.md ``` -* **`paths`**: the path to the folders or files containing the tests (optional, by default `tests`) +* **`paths`**: the path to the folders or files containing the tests (optional, by default `tests`) You can specify glob patterns, including `**` to match the pattern recursively or specify multiple test paths on multiple lines. For example: ```yaml @@ -93,7 +93,7 @@ To specify them correctly, please have a look [here](https://docs.pytest.org). F tests/test_file_2.py ``` -* **`show`**: which tests have to be shown in the summary (optional, by default `fail`) +* **`show`**: which tests have to be shown in the summary (optional, by default `fail`) This controls whether a test summary table is created or not, as well as what tests are included. It could be all, none, pass, skip, or fail. The default is fail - that is, the summary table will only show the failed tests. For example, if you wanted to show failed and skipped tests: ```yaml diff --git a/environment.yml b/environment.yml index 1f07676..226bae1 100644 --- a/environment.yml +++ b/environment.yml @@ -1,9 +1,11 @@ name: pytest-summary dependencies: - - python=3.10 - - black - - flake8 - - isort - - pre-commit - - pytest + - python>=3.12,<3.13 + - pip + - pip: + - nox + - pre-commit + - pyyaml + - pytest + - ruff diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..041cd13 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,33 @@ +import nox +import yaml + + +@nox.session +def update_tags(session: nox.Session): + with open(file="action.yml") as stream: + action = yaml.safe_load(stream=stream) + action = action["runs"]["steps"][2]["uses"] + version = action.split("@")[1] + major = version.split(".")[0] + for tag in [version, major]: + session.run( + "git", + "tag", + "--annotate", + "--force", + "--message", + "", + tag, + external=True, + ) + session.run( + "git", + "push", + "--force", + "origin", + tag, + external=True, + ) + output_file = session.env["GITHUB_OUTPUT"] + with open(file=output_file, mode="a") as f: + f.write(f"tag={version}\n") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..04b59a2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.ruff.lint] +select = ["A", "C", "C4", "E", "F", "I", "Q", "T", "SIM", "UP", "W"] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 439ab2a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,8 +0,0 @@ -[black] -line-length = 88 - -[flake8] -max-line-length = 88 - -[isort] -profile = black