name: Tests on: workflow_dispatch: pull_request: paths-ignore: - "docs/**" - "*.md" - ".gitignore" - "coverage.svg" - "concept/**" branches: [ master ] push: paths-ignore: - "docs/**" - "*.md" - ".gitignore" - "coverage.svg" - "concept/**" branches: [ master ] env: STAGE: GH_TEST PIPENV_VENV_IN_PROJECT: enabled EMAIL_DOMAIN: actions.com EMAIL_ADMIN_DOMAIN: admin.actions.com LDAP_DOMAIN: ACTIONSLDAP LDAP_BASE_CONTEXT: dc=actions,dc=com LDAP_ADMIN_USER: ACTIONSLDAP\admin jobs: run_tests: name: Run Django Tests runs-on: ubuntu-latest services: db: image: postgres:12.3-alpine env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: github_actions ports: - 5432:5432 options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Checkout uses: actions/checkout@v3 - run: mkdir .venv - name: Cache Dependencies uses: actions/cache@v3 id: cache-dependencies with: path: ./.venv key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }} restore-keys: | ${{ runner.os }}-pipenv - name: Install Dependecies uses: VaultVulp/action-pipenv@v2.0.1 with: command: sync --dev - name: Run tests uses: VaultVulp/action-pipenv@v2.0.1 with: command: run coverage run - name: Generate XML uses: VaultVulp/action-pipenv@v2.0.1 with: command: run coverage xml - name: Generate Badge uses: VaultVulp/action-pipenv@v2.0.1 with: command: run genbadge coverage -i coverage.xml -o coverage.svg - name: Verify Changed files if: github.ref == 'refs/heads/master' uses: tj-actions/verify-changed-files@v17 id: changed_files with: files: coverage.svg - name: Commit files if: steps.changed_files.outputs.files_changed == 'true' run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add coverage.svg git commit -m "Updated coverage.svg" - name: Push changes if: steps.changed_files.outputs.files_changed == 'true' && github.ref == 'refs/heads/master' uses: ad-m/github-push-action@master with: github_token: ${{ secrets.github_token }} branch: ${{ github.ref }}