Skip to content

Commit

Permalink
Add script to create cookiecutter project and to run pre-commit on th…
Browse files Browse the repository at this point in the history
…e generated project
  • Loading branch information
kumaranvpl committed Nov 8, 2024
1 parent 3d9aa92 commit 09b0bb4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ jobs:
- name: Install Cookiecutter
run: pip install cookiecutter

- name: Run cookiecutter
run: cookiecutter --replay-file ./cookiecutter_replay/${{ matrix.app-type }}_${{ matrix.python-version }}.json ./
- name: Test Cookiecutter
run: ./scripts/test-cookiecutter.sh ${{ matrix.app-type }} ${{ matrix.python-version }}

- name: Install Generated Project Dependencies
run: cd my_fastagency_app && pip install .[dev]
# - name: Run cookiecutter
# run: cookiecutter --replay-file ./cookiecutter_replay/${{ matrix.app-type }}_${{ matrix.python-version }}.json ./

- name: Run Pre-commit
run: |
cd my_fastagency_app
ls -lah
git init
git add .
pre-commit run --show-diff-on-failure --color=always --all-files
# - name: Install Generated Project Dependencies
# run: cd my_fastagency_app && pip install .[dev]

# - name: Run Pre-commit
# run: |
# cd my_fastagency_app
# ls -lah
# git init
# git add .
# pre-commit run --show-diff-on-failure --color=always --all-files

# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
Expand Down
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
__pycache__
dist
.idea
venv*
.venv*
.env
.env*
*.lock
.vscode
.pypirc
.pytest_cache
.ruff_cache
.mypy_cache
.coverage*
.cache
htmlcov
token
.DS_Store

generated/
22 changes: 22 additions & 0 deletions scripts/test_cookiecutter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# This script is used to test the cookiecutter template
# It will create a new project using the cookiecutter template under the generated/ directory
# The script accepts two positional arguments: app-type and python-version
# The cookiecutter replay file is used to provide the default values for the cookiecutter template

# Accept two arguments: app-type and python-version
echo "Generating project using cookiecutter template with app-type: $1 and python-version: $2"
cookiecutter -f --replay-file ./cookiecutter_replay/$1_$2.json --output-dir generated/ ./

# Install generated project's dependencies
echo "Installing dependencies for the generated project"
cd generated/my_fastagency_app && pip install -e .[dev] && cd ../../

# Initialize git in the generated project(needed for pre-commit)
echo "Initializing git in the generated project"
cd generated/my_fastagency_app && git init && git add . && cd ../../

# Run pre-commit
echo "Running pre-commit"
cd generated/my_fastagency_app && pre-commit run --show-diff-on-failure --color=always --all-files && cd ../../

0 comments on commit 09b0bb4

Please sign in to comment.