Skip to content

Commit 8c4dc0c

Browse files
cookiecutter (WIP)
1 parent c853ed9 commit 8c4dc0c

File tree

16 files changed

+120
-78
lines changed

16 files changed

+120
-78
lines changed

.github/workflows/codeql_analysis.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"version": "0.1.0",
1010
"use_pytest": "n",
1111
"use_black": "n",
12-
"use_pypi_deployment_with_travis": "y",
12+
"use_pypi_deployment_with_travis": "n",
1313
"add_pyup_badge": "n",
1414
"command_line_interface": [
1515
"Click",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: []
4+
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
5+
# patreon: # Replace with a single Patreon username
6+
# open_collective: # Replace with a single Open Collective username
7+
# ko_fi: # Replace with a single Ko-fi username
8+
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
9+
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
10+
# liberapay: # Replace with a single Liberapay username
11+
# issuehunt: # Replace with a single IssueHunt username
12+
# otechie: # Replace with a single Otechie username
13+
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
6+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#directory
7+
8+
version: 2
9+
updates:
10+
- package-ecosystem: "pip" # package manager
11+
directory: "/" # Files stored in repository root
12+
schedule:
13+
interval: "weekly"
14+
day: "saturday"
15+
time: "10:00"
16+
timezone: "America/Chicago"
17+
open-pull-requests-limit: 5
18+
versioning-strategy: increase-if-necessary

.github/workflows/auto_merge.yml renamed to {{cookiecutter.project_slug}}/.github/workflows/auto_merge.yml

File renamed without changes.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Autoupdate project structure
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: "0 0 * * *" # at the end of every day
6+
{% raw %}
7+
jobs:
8+
auto-update-project:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.10
16+
17+
- name: Install dependencies
18+
run: python -m pip install cruft poetry jello tabulate
19+
20+
- name: Update project structure
21+
run: |
22+
cruft update -y
23+
24+
- name: Check if there are changes
25+
id: changes
26+
run: echo "::set-output name=changed::$(git status --porcelain | wc -l)"
27+
28+
- name: apply additional changes and fixes
29+
if: steps.changes.outputs.changed > 0
30+
run: |
31+
poetry lock --no-update # add new dependencies
32+
poetry install
33+
poetry run pre-commit run -a || true # we have to fix other issues manually
34+
35+
- name: Get template versions
36+
id: get_versions
37+
if: steps.changes.outputs.changed > 0
38+
shell: bash
39+
run: |
40+
CURRENT_VERSION=$(git show HEAD:.cruft.json | jello -r "_['commit'][:8]")
41+
NEXT_VERSION=$(jello -r "_['commit'][:8]" < .cruft.json)
42+
echo ::set-output name="current_version::$CURRENT_VERSION"
43+
echo ::set-output name="next_version::$NEXT_VERSION"
44+
45+
- name: Get changelog
46+
id: get_changelog
47+
if: steps.changes.outputs.changed > 0
48+
shell: bash
49+
run: |
50+
TEMPLATE=$(jello -r "_['template']" < .cruft.json)
51+
git clone "$TEMPLATE" /tmp/template
52+
cd /tmp/template
53+
body=$( (echo "Date;Change;Hash"; git log --pretty=format:"%as;%s;%h" ${{ steps.get_versions.outputs.current_version }}..${{ steps.get_versions.outputs.next_version }}) | tabulate --header --format github -s ';' -)
54+
body=$(cat <<EOF
55+
Changes from $TEMPLATE
56+
57+
$body
58+
EOF
59+
)
60+
body="${body//'%'/'%25'}"
61+
body="${body//$'\n'/'%0A'}"
62+
body="${body//$'\r'/'%0D'}"
63+
echo ::set-output name="changelog::$body"
64+
65+
# behaviour if PR already exists: https://github.com/marketplace/actions/create-pull-request#action-behaviour
66+
- name: Create Pull Request
67+
env:
68+
# a PAT is required to be able to update workflows
69+
GITHUB_TOKEN: ${{ secrets.AUTO_UPDATE_GITHUB_TOKEN }}
70+
if: ${{ steps.changes.outputs.changed > 0 && env.GITHUB_TOKEN != 0 }}
71+
uses: peter-evans/create-pull-request@v3
72+
with:
73+
token: ${{ env.GITHUB_TOKEN }}
74+
commit-message: >-
75+
chore: update project structure to ${{ steps.get_versions.outputs.next_version }}
76+
title: "[Actions] Auto-Update cookiecutter template"
77+
body: ${{ steps.get_changelog.outputs.changelog }}
78+
branch: chore/auto-update-project-from-template
79+
delete-branch: true{% endraw %}

.github/workflows/echo_secret.yml renamed to {{cookiecutter.project_slug}}/.github/workflows/echo_secret.yml

File renamed without changes.

.github/workflows/hooks/pre-commit.py renamed to {{cookiecutter.project_slug}}/.github/workflows/hooks/pre-commit.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ def gitleaksEnabled():
1515

1616

1717
if gitleaksEnabled():
18-
exitCode = os.WEXITSTATUS(os.system('gitleaks protect -v --staged'))
18+
exitCode = os.WEXITSTATUS(os.system("gitleaks protect -v --staged"))
1919
if exitCode == 1:
20-
print('''Warning: gitleaks has detected sensitive information in your changes.
20+
print(
21+
"""Warning: gitleaks has detected sensitive information in your changes.
2122
To disable the gitleaks precommit hook run the following command:
2223
2324
git config hooks.gitleaks false
24-
''')
25+
"""
26+
)
2527
sys.exit(1)
2628
else:
27-
print('gitleaks precommit disabled\
28-
(enable with `git config hooks.gitleaks true`)')
29+
print(
30+
"gitleaks precommit disabled\
31+
(enable with `git config hooks.gitleaks true`)"
32+
)

.github/workflows/main.yml renamed to {{cookiecutter.project_slug}}/.github/workflows/main.yml

File renamed without changes.

.github/workflows/push.yml renamed to {{cookiecutter.project_slug}}/.github/workflows/push.yml

File renamed without changes.

0 commit comments

Comments
 (0)