From f431d35b6701b685f2c8cd98c41bfd0f26832991 Mon Sep 17 00:00:00 2001 From: Ben Beecher Date: Fri, 31 Jan 2025 17:33:46 -0500 Subject: [PATCH] create the project instance --- .github/workflows/project_ci.yml | 252 ++++++++++++---------- mise.toml | 5 + template/.github/workflows/fly-deploy.yml | 18 -- 3 files changed, 144 insertions(+), 131 deletions(-) create mode 100644 mise.toml delete mode 100644 template/.github/workflows/fly-deploy.yml diff --git a/.github/workflows/project_ci.yml b/.github/workflows/project_ci.yml index b2834528..227111ac 100644 --- a/.github/workflows/project_ci.yml +++ b/.github/workflows/project_ci.yml @@ -1,7 +1,3 @@ -# Instructions to clear caches: -# 1) List all caches for this repo using the Github CLI: gh api -H "Accept: application/vnd.github+json" /repos/Lightmatter/django-hydra/actions/caches -# 2) Delete each cache id from the list, e.g.: gh api --method DELETE -H "Accept: application/vnd.github+json" /repos/Lightmatter/django-hydra/actions/caches/1 - name: Project CI on: push: @@ -15,119 +11,149 @@ concurrency: cancel-in-progress: true jobs: - create_and_test_project: - name: Create and test Django project + generate_project: + name: Generate Project Instance runs-on: ubuntu-latest - env: - DATABASE_URL: "psql://postgres:postgres@localhost/postgres" - DJANGO_SECRET_KEY: "!!!! Change me !!!!" - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/checkout@v4 + - uses: jdx/mise-action@v2 - - name: Install and configure Poetry + - name: Generate project from template run: | - pipx install poetry==1.3.2 - poetry config virtualenvs.create true - poetry config virtualenvs.in-project false - poetry config installer.parallel true - - - name: Install Python - uses: actions/setup-python@v4 - id: setup_python - with: - python-version-file: ".python-version" - cache: "poetry" + uvx copier copy . ../test-output --trust --defaults - - name: Install Hydra dependencies + - name: Initialize git repo + working-directory: ../test-output run: | - poetry env use ${{ steps.setup_python.outputs.python-version }} - poetry install --no-interaction --no-root - - - name: Instantiate project using the values in cookiecutter.json - run: poetry run cookiecutter . --no-input --accept-hooks no - - - name: Install Node - uses: actions/setup-node@v3 + git init + git add . + git config --global user.email "test@example.com" + git config --global user.name "Test User" + git commit -m "Initial commit" + + # Upload the generated project as an artifact + - name: Upload generated project + uses: actions/upload-artifact@v4 with: - node-version: lts/* - cache: "npm" - cache-dependency-path: "**/package-lock.json" - - - name: Install + build NPM - working-directory: ./sampleapp - run: | - npm ci - npm run build - - - name: Install Sample App dependencies - working-directory: ./sampleapp - run: | - poetry env use ${{ steps.setup_python.outputs.python-version }} - poetry install --no-interaction --no-root - poetry run playwright install chromium - - - name: Run tests - working-directory: ./sampleapp - run: poetry run coverage run --source='.' -m pytest - - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: postgres - - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - dependabot_approve: - name: Approve Dependabot prs - runs-on: ubuntu-latest - - permissions: - pull-requests: write - - if: ${{ github.actor == 'dependabot[bot]' }} - needs: create_and_test_project - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v1.1.1 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - name: Approve a PR - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - dependabot_merge: - name: Auto Merge Dependabot prs - runs-on: ubuntu-latest - - permissions: - pull-requests: write - contents: write - - if: ${{ github.actor == 'dependabot[bot]' }} - needs: dependabot_approve - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v1.1.1 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --squash "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + name: generated-project + path: ../test-output + retention-days: 1 + + + + # create_and_test_project: + # name: Create and test Django project + # runs-on: ubuntu-latest + # env: + # DATABASE_URL: "psql://postgres:postgres@localhost/postgres" + # DJANGO_SECRET_KEY: "!!!! Change me !!!!" + + # steps: + # - uses: actions/checkout@v3 + # with: + # ref: ${{ github.event.pull_request.head.sha }} + + # - name: Install and configure Poetry + # run: | + # pipx install poetry==1.3.2 + # poetry config virtualenvs.create true + # poetry config virtualenvs.in-project false + # poetry config installer.parallel true + + # - name: Install Python + # uses: actions/setup-python@v4 + # id: setup_python + # with: + # python-version-file: ".python-version" + # cache: "poetry" + + # - name: Install Hydra dependencies + # run: | + # poetry env use ${{ steps.setup_python.outputs.python-version }} + # poetry install --no-interaction --no-root + + # - name: Instantiate project using the values in cookiecutter.json + # run: copier copy . ../test-output --trust --defaults + + # - name: Install Node + # uses: actions/setup-node@v3 + # with: + # node-version: lts/* + # cache: "npm" + # cache-dependency-path: "**/package-lock.json" + + # - name: Install + build NPM + # working-directory: ./sampleapp + # run: | + # npm ci + # npm run build + + # - name: Install Sample App dependencies + # working-directory: ./sampleapp + # run: | + # poetry env use ${{ steps.setup_python.outputs.python-version }} + # poetry install --no-interaction --no-root + # poetry run playwright install chromium + + # - name: Run tests + # working-directory: ./sampleapp + # run: poetry run coverage run --source='.' -m pytest + + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_PASSWORD: postgres + + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # - 5432:5432 + + # dependabot_approve: + # name: Approve Dependabot prs + # runs-on: ubuntu-latest + + # permissions: + # pull-requests: write + + # if: ${{ github.actor == 'dependabot[bot]' }} + # needs: create_and_test_project + # steps: + # - name: Dependabot metadata + # id: metadata + # uses: dependabot/fetch-metadata@v1.1.1 + # with: + # github-token: "${{ secrets.GITHUB_TOKEN }}" + + # - name: Approve a PR + # run: gh pr review --approve "$PR_URL" + # env: + # PR_URL: ${{github.event.pull_request.html_url}} + # GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + # dependabot_merge: + # name: Auto Merge Dependabot prs + # runs-on: ubuntu-latest + + # permissions: + # pull-requests: write + # contents: write + + # if: ${{ github.actor == 'dependabot[bot]' }} + # needs: dependabot_approve + # steps: + # - name: Dependabot metadata + # id: metadata + # uses: dependabot/fetch-metadata@v1.1.1 + # with: + # github-token: "${{ secrets.GITHUB_TOKEN }}" + + # - name: Enable auto-merge for Dependabot PRs + # run: gh pr merge --auto --squash "$PR_URL" + # env: + # PR_URL: ${{github.event.pull_request.html_url}} + # GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..22a39771 --- /dev/null +++ b/mise.toml @@ -0,0 +1,5 @@ +[tools] +uv = "0.5.9" + +[settings] +status.show_env = true diff --git a/template/.github/workflows/fly-deploy.yml b/template/.github/workflows/fly-deploy.yml deleted file mode 100644 index 09c3a8b2..00000000 --- a/template/.github/workflows/fly-deploy.yml +++ /dev/null @@ -1,18 +0,0 @@ -# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ - -name: Fly Deploy -on: - push: - branches: - - master -jobs: - deploy: - name: Deploy app - runs-on: ubuntu-latest - concurrency: deploy-group # optional: ensure only one action runs at a time - steps: - - uses: actions/checkout@v4 - - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}