From 6977e6e0c3b0e646cf594e5c5160fd79b043c076 Mon Sep 17 00:00:00 2001 From: ftsell <dev@ftsell.de> Date: Mon, 12 Feb 2024 15:18:12 +0100 Subject: [PATCH] add github action for testing --- .github/workflows/test.yml | 50 +++++++++++++++++++ hooks/post_gen_project.py | 2 +- .../.pre-commit-config.yaml | 4 +- 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4e139ba --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,50 @@ +name: test +on: + push: + branches: [ "*" ] + +env: + artifact_name: test_project + +jobs: + create-test-project: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: install dependencies + run: | + sudo apt install cookiecutter pre-commit npm + pip install pipenv + npm install -g pnpm + - name: create project with cookiecutter + run: | + git config --global init.defaultBranch main + git config --global user.email "github-actions@github.com" + git config --global user.name "GitHub Actions" + cookiecutter --no-input --output-dir /tmp ./ project_slug=github_test_project + - id: upload-artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ env.artifact_name }} + path: | + /tmp/github_test_project + !/tmp/github_test_project/**/node_modules + retention-days: 1 + + run-test-project: + runs-on: ubuntu-latest + needs: [ create-test-project ] + steps: + - name: install system dependencies + run: | + sudo apt install npm + pip install pipenv + npm install -g pnpm + - uses: actions/download-artifact@v4 + with: + name: ${{ env.artifact_name }} + - run: ls src + - name: install project dependencies + run: pipenv sync --dev + - name: manage.py --help + run: pipenv run ./src/manage.py --help diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 5d3eb6a..8efa583 100755 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -17,5 +17,5 @@ def git_commit(message: str): # lock & install dependencies subprocess.check_call("pipenv lock".split(" ")) subprocess.check_call("pipenv sync".split(" ")) - subprocess.check_call("pnpm install".split(" "), cwd="./src/{{ cookiecutter.project_slug }}_gui") + subprocess.check_call("pnpm install --no-frozen-lockfile".split(" "), cwd="./src/{{ cookiecutter.project_slug }}_gui") git_commit("lock dependencies") diff --git a/{{ cookiecutter.project_slug }}/.pre-commit-config.yaml b/{{ cookiecutter.project_slug }}/.pre-commit-config.yaml index 14378dd..3d7af29 100644 --- a/{{ cookiecutter.project_slug }}/.pre-commit-config.yaml +++ b/{{ cookiecutter.project_slug }}/.pre-commit-config.yaml @@ -9,11 +9,11 @@ repos: - id: check-added-large-files - repo: https://github.com/psf/black.git - rev: "23.11.0" + rev: "24.1.1" hooks: - id: black - repo: https://github.com/PyCQA/isort.git - rev: "5.12.0" + rev: "5.13.2" hooks: - id: isort