Skip to content

Commit

Permalink
5 - neon db branch django tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Asirwad committed Aug 2, 2024
1 parent afe9517 commit d5d26cb
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/4-test-django-database-url.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: 4 - Test Django with Actions Secret Databse url

on:
workflow_dispatch:
push:
branch:
- main
#push:
# branch:
# - main

jobs:
test:
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/5-neon-db-branch-django-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 5 - neon db branch django tests

on:
workflow_dispatch:
push:
branch:
- main

jobs:
test:
runs-on: ubuntu-latest
env:
DJANGO_DEBUG: 0
# DATABASE_URL: ${{ secrets.NEON_DATABASE_URL }}
NEON_API_KEY: ${{ secrets.NEON_API_KEY }}
# DJANGO_SECRET_KEY: not-good
NEON_GH_BRANCH: "gh-delete"
NEON_PROD_BRANCH: "main"
NEON_PROJECT_ID: ${{ }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup NodeJs
uses: actions/setup-node@v4
with:
node-version: '20.11'
- name: Install Neon CLI
run: |
npm install -g neonctl
- name: Delete previous branch
continue-on-error: true
run: |
neonctl branches delete "${{ env.NEON_GH_BRANCH }}" --project-id "${{ env.NEON_PROJECT_ID }}"
- name: Create new github actions branch
run: |
neonctl branches create --name "${{ env.NEON_GH_BRANCH }}" --parent "${{ env.NEON_PROD_BRANCH }}" --project-id "${{ env.NEON_PROJECT_ID }}"
- name: Database URL Env Val for new Github Actions branch
run: |
MY_NEON_CONN_STRING=$(neonctl connection-string --branch "${{ env.NEON_GH_BRANCH }}" --project-id "${{ env.NEON_PROJECT_ID }}")
echo "DATABASE_URL=$MY_NEON_CONN_STRING" >> $GITHUB_ENV
- name: Setup Django Secret key
run: |
MY_GEN_KEY=$(openssl rand -base64 32)
echo "DJANGO_SECRET_KEY=$MY_GEN_KEY" >> $GITHUB_ENV
- name: Show DATABASE_URL
run: |
echo ${{ env.DATABASE_URL }}
- name: Install Requirements
run: |
python -m pip install pip --upgrade
python -m pip install -r requirements.txt
- name: Django Tests
working-directory: ./src
run: |
python manage.py test

0 comments on commit d5d26cb

Please sign in to comment.