Skip to content

Commit 2cfaa38

Browse files
committed
✨ github actions
1 parent c75d20f commit 2cfaa38

File tree

14 files changed

+90
-50
lines changed

14 files changed

+90
-50
lines changed

tests/example-project/.github/workflows/docker.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Docker CI/CD
2-
32
on:
43
pull_request:
54
branches: ["**"]
@@ -11,6 +10,9 @@ on:
1110
jobs:
1211
docker-ci-test:
1312
runs-on: ubuntu-latest
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
1416
steps:
1517
- name: Set up Github Workspace
1618
uses: actions/checkout@v4

tests/example-project/.github/workflows/lint.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Lint
2-
32
on:
43
pull_request:
54
branches: ["**"]
6-
75
jobs:
86
lint:
97
runs-on: ubuntu-latest
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
1011
steps:
1112
- name: Set up Github Workspace
1213
uses: actions/checkout@v4
@@ -21,6 +22,8 @@ jobs:
2122
python -m pip install --upgrade pip wheel
2223
python -m pip install -q hatch pre-commit
2324
hatch --version
25+
- name: Create Environment
26+
run: hatch env create lint
2427
- name: Lint
2528
id: lint
2629
continue-on-error: true

tests/example-project/.github/workflows/publish.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: Publishing
2-
32
on:
43
release:
54
types:
65
- published
7-
86
jobs:
97
pypi-publish:
108
name: PyPI
119
if: github.repository_owner == 'juftin'
1210
runs-on: ubuntu-latest
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.job }}
13+
cancel-in-progress: false
1314
steps:
1415
- name: Check out the repository
1516
uses: actions/checkout@v4
@@ -37,6 +38,9 @@ jobs:
3738
name: docker-hub
3839
if: github.repository_owner == 'juftin'
3940
runs-on: ubuntu-latest
41+
concurrency:
42+
group: ${{ github.workflow }}-${{ github.job }}
43+
cancel-in-progress: false
4044
steps:
4145
- name: Check out the repository
4246
uses: actions/checkout@v4

tests/example-project/.github/workflows/release.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Release
2-
32
on:
43
push:
54
branches:
65
- main
7-
6+
- next
7+
- beta
8+
- alpha
9+
- "*.x"
810
jobs:
911
release:
1012
name: github-release
@@ -14,12 +16,14 @@ jobs:
1416
contents: write
1517
issues: write
1618
pull-requests: write
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.job }}
21+
cancel-in-progress: false
1722
steps:
1823
- name: Check out the repository
1924
uses: actions/checkout@v4
2025
with:
2126
fetch-depth: 2
22-
ref: main
2327
- name: Setup Node.js
2428
uses: actions/setup-node@v4
2529
- name: Set up Python
@@ -40,7 +44,6 @@ jobs:
4044
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
4145
GIT_COMMITTER_NAME: github-actions[bot]
4246
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
43-
4447
github-pages-publish:
4548
runs-on: ubuntu-latest
4649
needs: release
@@ -51,12 +54,12 @@ jobs:
5154
environment:
5255
name: github-pages
5356
url: ${{ steps.deployment.outputs.page_url }}
57+
concurrency:
58+
group: ${{ github.workflow }}-${{ github.job }}
59+
cancel-in-progress: false
5460
steps:
5561
- name: Checkout Latest Changes
5662
uses: actions/checkout@v4
57-
with:
58-
ref: ${{ github.ref }}
59-
fetch-depth: 0
6063
- name: Set up Python Environment
6164
uses: actions/setup-python@v5
6265
with:

tests/example-project/.github/workflows/tests.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
name: Tests
2-
32
on:
43
push:
54
branches:
65
- main
76
paths:
87
- example_project/**
8+
- tests/**
99
- pyproject.toml
1010
- .github/workflows/tests.yaml
1111
pull_request:
1212
branches: ["**"]
1313
paths:
1414
- example_project/**
15+
- tests/**
1516
- pyproject.toml
1617
- .github/workflows/tests.yaml
1718
schedule:
@@ -45,6 +46,8 @@ jobs:
4546
python -m pip install -q --upgrade pip wheel
4647
python -m pip install -q hatch pre-commit
4748
hatch --version
49+
- name: Create Environment
50+
run: hatch --env all run +py=${{ matrix.python }} -- python --version
4851
- name: Test Suite
4952
run: |
5053
echo "::add-matcher::.github/workflows/matchers/python.json"

tests/example-project/docs/contributing.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
hatch env create
2929
```
3030
31-
3. If you need to, you can link hatch's virtual environment to your IDE.
32-
It's located in the `.venv` directory at the root of the project.
31+
3. If you need to, you can link a hatch virtual environment to your IDE.
32+
They can be located by name with the `env find` command:
33+
34+
```shell
35+
hatch env find default
36+
```
3337
3438
4. Activate the Virtual Environment
3539
@@ -41,16 +45,15 @@
4145
4246
### Hatch Cheat Sheet
4347
44-
| Command Description | Command | Notes |
45-
| ------------------------------ | --------------------------- | ---------------------------------------------------------- |
46-
| Run Tests | `hatch run cov` | Runs tests with `pytest` and `coverage` |
47-
| Run Formatting | `hatch run lint:fmt` | Runs `ruff` code formatter |
48-
| Run Linting | `hatch run lint:all` | Runs `ruff` and `mypy` linters / type checkers |
49-
| Run Type Checking | `hatch run lint:typing` | Runs `mypy` type checker |
50-
| Update Requirements Lock Files | `hatch run gen:reqs` | Updating lock file using `pip-compile` |
51-
| Upgrade Dependencies | `hatch run gen:reqs-update` | Updating lock file using `pip-compile` and `--update` flag |
52-
| Serve the Documentation | `hatch run docs:serve` | Serve the documentation using MkDocs |
53-
| Run the `pre-commit` Hooks | `hatch run lint:precommit` | Runs the `pre-commit` hooks on all files |
48+
| Command Description | Command | Notes |
49+
| -------------------------- | -------------------------- | ---------------------------------------------- |
50+
| Run Tests | `hatch run cov` | Runs tests with `pytest` and `coverage` |
51+
| Run Formatting | `hatch run lint:fmt` | Runs `ruff` code formatter |
52+
| Run Linting | `hatch run lint:style` | Runs `ruff` code linter |
53+
| Run Type Checking | `hatch run lint:typing` | Runs `mypy` type checker |
54+
| Run All Static Analysis | `hatch run lint:all` | Runs `ruff` and `mypy` linters / type checkers |
55+
| Serve the Documentation | `hatch run docs:serve` | Serve the documentation using MkDocs |
56+
| Run the `pre-commit` Hooks | `hatch run lint:precommit` | Runs the `pre-commit` hooks on all files |
5457
5558
### Hatch Explanation
5659

tests/example-project/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ exclude_lines = [
4141
"if __name__ == .__main__.:",
4242
"if TYPE_CHECKING:"
4343
]
44+
show_missing = true
4445

4546
[tool.coverage.run]
4647
branch = true
@@ -173,6 +174,7 @@ select = [
173174
"FBT", # flake8-boolean-trap
174175
"I", # isort
175176
"ICN", # flake8-import-conventions
177+
"ISC", # flake8-implicit-str-concat
176178
"N", # pep8-naming
177179
"PLC", # Pylint (Convention message)
178180
"PLE", # Pylint (Error message)

{{cookiecutter.repo_name}}/.github/workflows/docker.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Docker CI/CD
2-
32
on:
43
pull_request:
54
branches: ["**"]
@@ -11,6 +10,9 @@ on:
1110
jobs:
1211
docker-ci-test:
1312
runs-on: ubuntu-latest
13+
concurrency:
14+
group: ${{"{{"}} github.workflow {{"}}"}}-${{"{{"}} github.ref {{"}}"}}
15+
cancel-in-progress: true
1416
steps:
1517
- name: Set up Github Workspace
1618
uses: actions/checkout@v4

{{cookiecutter.repo_name}}/.github/workflows/lint.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Lint
2-
32
on:
43
pull_request:
54
branches: ["**"]
6-
75
jobs:
86
lint:
97
runs-on: ubuntu-latest
8+
concurrency:
9+
group: ${{"{{"}} github.workflow {{"}}"}}-${{"{{"}} github.ref {{"}}"}}
10+
cancel-in-progress: true
1011
steps:
1112
- name: Set up Github Workspace
1213
uses: actions/checkout@v4
@@ -21,6 +22,8 @@ jobs:
2122
python -m pip install --upgrade pip wheel
2223
python -m pip install -q hatch pre-commit
2324
hatch --version
25+
- name: Create Environment
26+
run: hatch env create lint
2427
- name: Lint
2528
id: lint
2629
continue-on-error: true

{{cookiecutter.repo_name}}/.github/workflows/publish.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
name: Publishing
2-
32
on:
43
release:
54
types:
65
- published
7-
86
jobs:
97
{% if cookiecutter.publish_to_pypi == True -%}
108
pypi-publish:
119
name: PyPI
1210
if: github.repository_owner == '{{ cookiecutter.github_username }}'
1311
runs-on: ubuntu-latest
12+
concurrency:
13+
group: ${{"{{"}} github.workflow {{"}}"}}-${{"{{"}} github.job {{"}}"}}
14+
cancel-in-progress: false
1415
steps:
1516
- name: Check out the repository
1617
uses: actions/checkout@v4
@@ -38,6 +39,9 @@ jobs:
3839
name: docker-hub
3940
if: github.repository_owner == '{{ cookiecutter.github_username }}'
4041
runs-on: ubuntu-latest
42+
concurrency:
43+
group: ${{"{{"}} github.workflow {{"}}"}}-${{"{{"}} github.job {{"}}"}}
44+
cancel-in-progress: false
4145
steps:
4246
- name: Check out the repository
4347
uses: actions/checkout@v4

0 commit comments

Comments
 (0)