Skip to content

Commit

Permalink
fix: 💪 Add workflow to automatize release #18
Browse files Browse the repository at this point in the history
  • Loading branch information
dariocurr committed Sep 21, 2024
1 parent 868e54c commit 70cbd6f
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 58 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
- main

workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout origin repo
uses: actions/[email protected]

- 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/[email protected]
with:
tag_name: ${{ steps.tags.outputs.tag }}
2 changes: 1 addition & 1 deletion .github/workflows/test_simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test_with_options.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: "[TEST] with options"

on:
workflow_dispatch:
branches:
- develop
push:
branches:
- develop

workflow_dispatch:

jobs:
options:
runs-on: ubuntu-latest
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test_with_output.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: "[TEST] with output"

on:
workflow_dispatch:
branches:
- develop
push:
branches:
- develop

workflow_dispatch:

jobs:
output:
runs-on: ubuntu-latest
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/test_with_paths.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/test_with_show.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 20 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
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
- id: mixed-line-ending
- 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
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
14 changes: 8 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

0 comments on commit 70cbd6f

Please sign in to comment.