diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml new file mode 100644 index 0000000..3c8cdad --- /dev/null +++ b/.github/workflows/test-and-deploy.yml @@ -0,0 +1,83 @@ +name: Test and Deploy + +on: [ push, pull_request ] + +env: + SECRET_KEY: "FAKE_SECRET_KEY" + DATABASE_URL: ${{secrets.DATABASE_URL}} + REDIS_URL: ${{secrets.REDIS_URL}} + AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} + AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} + +jobs: + test: + services: + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + postgres: + image: postgres + env: + POSTGRES_DB: teambio + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12.2 + cache: 'pip' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install coverage + - name: Collect Static + run: | + python manage.py collectstatic --no-input + - name: Run Tests + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/teambio + REDIS_URL: redis://redis:6379 + run: | + coverage run --source='.' manage.py test --no-input + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Install pre-commit + run: pip install pre-commit + - name: Lint with pre-commit + run: | + pre-commit run -a + # deploy: + # runs-on: ubuntu-latest + # needs: [test, lint] + # if: github.ref == 'refs/heads/main' + # steps: + # - name: Deploy App Webhook + # uses: joelwmale/webhook-action@master + # with: + # url: ${{ secrets.RENDER_APP_DEPLOY_HOOK }} + # - name: Deploy Celery Webhook + # uses: joelwmale/webhook-action@master + # with: + # url: ${{ secrets.RENDER_CELERY_DEPLOY_HOOK }}