Django States Tests #88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Django States Tests | |
on: | |
push: | |
schedule: | |
- cron: '0 1 * * 5' | |
jobs: | |
cancel: | |
name: Canceling Outstanding Jobs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: styfle/cancel-workflow-action@0.11.0 | |
with: | |
access_token: ${{ github.token }} | |
outdated: | |
name: Outdated packages | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
cache-dependency-path: | | |
setup.py | |
requirements*.txt | |
- name: Install dependencies | |
run: | | |
python setup.py install | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt --user | |
pip install -r requirements_dev.txt --user | |
- 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@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
cache-dependency-path: | | |
setup.py | |
requirements*.txt | |
- name: Install dependencies | |
run: | | |
python setup.py install | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r requirements_dev.txt | |
- name: Black | |
run: black --check . | |
pre-commit: | |
name: Pre-Commit | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
cache-dependency-path: | | |
setup.py | |
requirements*.txt | |
- name: Install dependencies | |
run: | | |
python setup.py install | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r requirements_dev.txt | |
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@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
cache-dependency-path: | | |
setup.py | |
requirements*.txt | |
- name: Install dependencies | |
run: | | |
python setup.py install | |
pip install bandit | |
- name: Bandit | |
run: bandit -r django_states -x django_states/tests -s B101 -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@v3 | |
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 == '~=4.2.0' }} | |
strategy: | |
max-parallel: 4 | |
matrix: | |
db: [ sqlite, mariadb ] | |
django-version: [ "~=4.2.0" ] | |
python-version: [ "3.10" ] | |
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@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
setup.py | |
requirements*.txt | |
- name: Install dependencies | |
run: | | |
python setup.py install | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r requirements_dev.txt | |
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 }} | |
GOOGLE_MAPS_CLIENT_ID: ${{ secrets.GOOGLE_MAPS_CLIENT_ID }} | |
GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} | |
run: | | |
export PYTHONPATH=`pwd` | |
coverage run demo_app/manage.py test --noinput --settings=demo_app.settings_test django_states.tests | |
- name: "Upload Coverage Results for PY:${{ matrix.python-version }} DB:${{ matrix.db}} DJ:${{ matrix.django-version }}" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-${{ matrix.python-version }}-${{ matrix.db}}-${{ matrix.django-version }} | |
path: .coverage | |
retention-days: 1 | |
- name: Django Check | |
run: | | |
export PYTHONPATH=`pwd` | |
python demo_app/manage.py check | |
coverage: | |
name: Upload Coverage to Codecov | |
needs: [ tests ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: pip install -q coverage | |
- uses: actions/download-artifact@v3 | |
with: | |
path: . | |
- name: Combine Report Coverage | |
run: | | |
coverage combine coverage-*/.coverage | |
coverage report --precision=1 --sort=cover --skip-covered --skip-empty | |
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: [ 'cancel', 'outdated', 'black', 'pre-commit', 'security', 'tests', 'coverage' ] | |
outputs: | |
bumped: ${{ steps.release.outputs.bumped }} | |
bump_version: ${{ steps.release.outputs.bump_version }} | |
bump_sha: ${{ steps.release.outputs.bump_sha }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- 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 | |
TASK_ALWAYS_EAGER: 1 | |
GITHUB_TOKEN: ${{ secrets.ORGANIZATIONAL_REPO_TOKEN }} | |
run: | | |
bumper.py --directory . --exclude=.github,demo_app \ | |
--version_files django_states/__init__.py \ | |
--repo=pivotal-energy-solutions/django-states2 > out.json | |
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 |