Skip to content

Commit

Permalink
chore: Update templates (#2820)
Browse files Browse the repository at this point in the history
* chore: Update templates

* Update `pass_env`

* Use uv to install all Python tools in e2e workflow
  • Loading branch information
edgarrmondragon authored Jan 20, 2025
1 parent b4c6ecc commit 1079131
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ updates:
- "patch"
versioning-strategy: increase-if-necessary
- package-ecosystem: pip
directory: "/.github/workflows"
directory: "/.github/workflows/resources"
schedule:
interval: weekly
time: "12:00"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Install tools
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
python -Im pip install -U pip
pipx install griffe nox
Expand Down
22 changes: 9 additions & 13 deletions .github/workflows/cookiecutter-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,32 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Upgrade pip
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pip install pip
pip --version

- uses: astral-sh/setup-uv@v5
with:
version: ">=0.4.30"

- name: Install Poetry
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
pipx install poetry
uv tool install poetry
poetry --version
- uses: actions/setup-python@v5
with:
python-version: 3.x

- uses: astral-sh/setup-uv@v5
with:
version: ">=0.4.30"

- name: Install pre-commit
env:
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
uv tool install --with=pre-commit-uv pre-commit
pre-commit --version
- name: Install Nox
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
uv tool install nox
nox --version
Expand Down
File renamed without changes.
18 changes: 8 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,27 @@ on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "cookiecutter/**"
- "samples/**"
- "singer_sdk/**"
- "tests/**"
- "noxfile.py"
- "poetry.lock"
- "pyproject.toml"
- ".github/workflows/test.yml"
- ".github/workflows/constraints.txt"
- ".github/workflows/resources/requirements.txt"
push:
branches:
- main
- v*
paths:
- "cookiecutter/**"
- "samples/**"
- "singer_sdk/**"
- "tests/**"
- "noxfile.py"
- "poetry.lock"
- "pyproject.toml"
- ".github/workflows/test.yml"
- ".github/workflows/constraints.txt"
- ".github/workflows/resources/requirements.txt"
workflow_dispatch:
inputs: {}

Expand Down Expand Up @@ -73,14 +71,14 @@ jobs:

- name: Upgrade pip
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
pip install pip
pip --version
- name: Install Nox
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
pipx install 'nox[uv]'
nox --version
Expand Down Expand Up @@ -128,14 +126,14 @@ jobs:

- name: Upgrade pip
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
pip install pip
pip --version
- name: Install Nox
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
pipx install 'nox[uv]'
nox --version
Expand All @@ -161,7 +159,7 @@ jobs:

- name: Upgrade pip
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
pip install pip
pip --version
Expand All @@ -173,7 +171,7 @@ jobs:

- name: Install Nox
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
pipx install 'nox[uv]'
nox --version
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ repos:
)$
- repo: https://github.com/python-poetry/poetry
rev: 2.0.1
rev: 2.0.0
hooks:
- id: poetry-check
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: {{ '${{ steps.baipp.outputs.package_version }}' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
id: baipp

publish:
name: Publish to PyPI
Expand All @@ -23,7 +24,13 @@ jobs:
## TODO: optionally provide the name of the environment for the trusted
## publisher on PyPI
## https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
# environment: pypi
# environment:
# name: pypi
{%- if cookiecutter.variant != "None (Skip)" %}
# url: https://pypi.org/project/"{{cookiecutter.variant}}-{{cookiecutter.mapper_id}}"/{{ '${{ steps.baipp.outputs.package_version }}' }}
{%- else %}
# url: https://pypi.org/project/"{{cookiecutter.mapper_id}}"/{{ '${{ steps.baipp.outputs.package_version }}' }}
{%- endif %}
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
rev: 0.31.0
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
rev: v0.9.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.1
hooks:
- id: mypy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tool.poetry]
[project]
{%- if cookiecutter.variant != "None (Skip)" %}
name = "{{cookiecutter.variant}}-{{cookiecutter.mapper_id}}"
{%- else %}
Expand All @@ -7,14 +7,15 @@ name = "{{cookiecutter.mapper_id}}"
version = "0.0.1"
description = "Singer mapper {{cookiecutter.name}}, built with the Meltano Singer SDK."
readme = "README.md"
authors = ["{{ cookiecutter.admin_name }} <{{ cookiecutter.admin_email }}>"]
authors = [{ name = "{{ cookiecutter.admin_name }}", email = "{{ cookiecutter.admin_email }}" }]
keywords = [
"ELT",
"Mapper",
"{{cookiecutter.name}}",
]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -23,14 +24,18 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]
license = "Apache-2.0"
license-files = [ "LICENSE" ]
requires-python = ">=3.9"
dynamic = ["dependencies"]

[tool.poetry]
{%- if cookiecutter.variant != "None (Skip)" %}
packages = [
{ include = "{{cookiecutter.library_name}}" },
]
{%- endif %}

[tool.poetry.dependencies]
python = ">=3.9"
singer-sdk = { version="~=0.43.1"{{ ', extras = ["faker"]' if cookiecutter.faker_extra }} }
fs-s3fs = { version = "~=1.1.1", optional = true }

Expand All @@ -42,7 +47,9 @@ singer-sdk = { version="~=0.43.1", extras = ["testing"] }
s3 = ["fs-s3fs"]

[tool.pytest.ini_options]
addopts = '--durations=10'
addopts = [
"--durations=10",
]

[tool.mypy]
python_version = "3.12"
Expand All @@ -54,7 +61,6 @@ target-version = "py39"
[tool.ruff.lint]
ignore = [
"COM812", # missing-trailing-comma
"ISC001", # single-line-implicit-string-concatenation
]
select = ["ALL"]

Expand All @@ -65,7 +71,7 @@ allow-star-arg-any = true
convention = "google"

[build-system]
requires = ["poetry-core"]
requires = ["poetry-core>=2,<3"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ requires =
tox>=4.19

[testenv]
pass_env =
{{cookiecutter.mapper_id.replace('-', '_').upper()}}_*
deps =
pytest
commands =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: {{ '${{ steps.baipp.outputs.package_version }}' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
id: baipp

publish:
name: Publish to PyPI
Expand All @@ -23,7 +24,13 @@ jobs:
## TODO: optionally provide the name of the environment for the trusted
## publisher on PyPI
## https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
# environment: pypi
# environment:
# name: pypi
{%- if cookiecutter.variant != "None (Skip)" %}
# url: https://pypi.org/project/"{{cookiecutter.variant}}-{{cookiecutter.tap_id}}"/{{ '${{ steps.baipp.outputs.package_version }}' }}
{%- else %}
# url: https://pypi.org/project/"{{cookiecutter.tap_id}}"/{{ '${{ steps.baipp.outputs.package_version }}' }}
{%- endif %}
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
rev: 0.31.0
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
rev: v0.9.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.1
hooks:
- id: mypy
additional_dependencies:
Expand Down
3 changes: 2 additions & 1 deletion cookiecutter/tap-template/{{cookiecutter.tap_id}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ Now you can test and orchestrate using Meltano:
```bash
# Test invocation:
meltano invoke {{ cookiecutter.tap_id }} --version
# OR run a test `elt` pipeline:

# OR run a test ELT pipeline:
meltano run {{ cookiecutter.tap_id }} target-jsonl
```

Expand Down
Loading

0 comments on commit 1079131

Please sign in to comment.