Skip to content

Django App Metrics Tests #154

Django App Metrics Tests

Django App Metrics Tests #154

Workflow file for this run

# This is used for app metrics.
name: Django App Metrics Tests
on:
push:
schedule:
- cron: '0 1 * * 5'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
outdated:
name: Outdated packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: outdated
run: pip list --outdated --not-required --user | grep . && echo "There are outdated packages" && exit 1 || echo "All packages up to date"
black:
name: Black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: Black
run: black --check .
ruff:
name: Ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: Ruff
run: ruff check
pre-commit:
name: Pre-Commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
pre-commit install
- name: Pre-Commit
run: pre-commit run --all-files --show-diff-on-failure
security:
name: Bandit Security
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
pip install .
pip install .[test]
- name: Bandit
run: bandit -c pyproject.toml -r -f json -o report.json .
- name: Show report
if: ${{ success() || failure() }}
run: cat report.json
- name: "Upload Coverage Results"
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: Bandit Security Report
path: report.json
tests:
name: Python ${{ matrix.python-version }} / ${{ matrix.db }} / Django ${{ matrix.django-version}}
runs-on: ubuntu-latest
# continue-on-error: ${{ matrix.django-version == '~=5.0' }}
strategy:
max-parallel: 4
matrix:
db: [ sqlite, mariadb ]
django-version: [ "~=5.0" ]
python-version: [ "3.12" ]
services:
mariadb:
image: mariadb:latest
env:
MARIADB_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Verify MySQL connection from host
if: matrix.db == 'mariadb'
run: |
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "SHOW DATABASES" 2>&1 > /dev/null
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -V
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
pip install .
pip install .[test]
pip uninstall -y Django
pip install Django${{ matrix.django-version }}
- name: Run ${{ matrix.db }} Django ${{ matrix.django-version }} Tests
env:
PYTHONWARNINGS: once::DeprecationWarning
TASK_ALWAYS_EAGER: 1
DB_TYPE: ${{ matrix.db }}
run: export PYTHONPATH=`pwd` && coverage run
- name: "Upload Coverage Results for PY:${{ matrix.python-version }} DB:${{ matrix.db}} DJ:${{ matrix.django-version }}"
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
if-no-files-found: warn
name: coverage-${{ matrix.python-version }}-${{ matrix.db}}-${{ matrix.django-version }}
path: .coverage
retention-days: 1
- name: Django Check
run: python demo_app/manage.py check
coverage:
name: Upload Coverage to Codecov
needs: [tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install .
pip install .[test]
- uses: actions/download-artifact@v4
with:
path: .
- name: Combine Report Coverage
run: |
coverage combine coverage-*/.coverage
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
directory: .
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
release:
name: Release
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
needs: ['outdated', 'black', 'pre-commit', 'security', 'tests', 'coverage']
permissions: write-all
outputs:
bumped: ${{ steps.release.outputs.bumped }}
bump_version: ${{ steps.release.outputs.bump_version }}
bump_sha: ${{ steps.release.outputs.bump_sha }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install git+https://${{ secrets.ORGANIZATIONAL_REPO_TOKEN }}@github.com/pivotal-energy-solutions/tensor-infrastructure@master#egg=infrastructure
- name: Release
id: release
env:
PYTHONWARNINGS: once::DeprecationWarning
GITHUB_TOKEN: ${{ secrets.ORGANIZATIONAL_REPO_TOKEN }}
run: |
bumper -P
echo "bumped=$(jq '.bumped' out.json)" >> $GITHUB_OUTPUT
echo "bump_version=$(jq '.bump_version' out.json)" >> $GITHUB_OUTPUT
echo "bump_sha=$(jq '.bump_sha' out.json)" >> $GITHUB_OUTPUT