Skip to content

Commit

Permalink
feat: add poetry update workflow to generated projects (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed Apr 5, 2023
1 parent 3c52cfa commit 575ddc0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ _tasks:
# Setup GitHub
- "{% if setup_github %}gh repo create {{ github_username }}/{{ project_slug }} -d '{{ project_short_description }}' --public --remote=origin --source=. --push{% endif %}"
- "{% if setup_github %}gh repo edit --delete-branch-on-merge --enable-projects=false --enable-wiki=false{% endif %}"
- "{% if setup_github %}gh secret set PYPI_TOKEN -b'changeme'{% endif %}"
- "{% if setup_github %}gh secret set GH_PAT -b'changeme'{% endif %}"
- "{% if setup_github %}gh secret set PYPI_TOKEN -b 'changeme'{% endif %}"
- "{% if setup_github %}gh secret set GH_PAT -b 'changeme'{% endif %}"
# Setup pre-commit
- "{% if setup_pre_commit %}pre-commit install{% endif %}"
# Add me as a contributor
Expand Down
12 changes: 12 additions & 0 deletions project/.github/workflows/poetry-upgrade.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Upgrader

on:
workflow_dispatch:
schedule:
- cron: "{{ range(0, 60) | random }} {{ range(0, 24) | random }} {{ range(1, 28) | random }} * *"

jobs:
upgrade:
uses: browniebroke/github-actions/.github/workflows/poetry-upgrade.yml@v1
secrets:
gh_pat: {% raw %}${{ secrets.GH_PAT }}{% endraw %}
11 changes: 11 additions & 0 deletions tests/test_generate_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import re
from pathlib import Path
from typing import Sequence

Expand Down Expand Up @@ -66,6 +67,16 @@ def test_defaults_values(
'license = "MIT"',
],
)
upgrade_path = dst_path / ".github" / "workflows" / "poetry-upgrade.yml"
assert upgrade_path.exists()
content = upgrade_path.read_text()
found = False
for line in content.split("\n"):
if "cron:" in line:
found = True
cron_expression = re.search(r"\d+ \d+ \d+ \* \*", line)
assert cron_expression, f"Invalid cron expression: {line}"
assert found, f"No cron expression in {content}"


@pytest.mark.parametrize(
Expand Down

0 comments on commit 575ddc0

Please sign in to comment.