Merge branch 'main' of github.com:staticfox/sirendb #83
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: CI | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.12.1' | |
architecture: 'x64' | |
- name: Update pip, wheel, and setuptools | |
run: pip install -U pip wheel setuptools | |
- name: Setup the virtual environment | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
- name: Install dependencies | |
run: pip install -e .[dev] | |
- name: Run flake8 | |
run: flake8 src tests | |
- name: Run tests | |
run: | | |
dbversion=$(createdb --version) | |
pgversion=$(python -c "import re; print(re.compile(r'createdb \(\S+\ ([^\.]+)').match('${dbversion}').groups()[0])") | |
export PATH=/usr/lib/postgresql/$pgversion/bin:$PATH | |
which pg_ctl | |
which createdb | |
which pg_config | |
coverage run -m pytest | |
coverage report -m | |
- name: Update Coverage Badge | |
# GitHub actions: default branch variable | |
# https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
uses: tj-actions/coverage-badge-py@v2 | |
- name: Verify Changed files | |
uses: tj-actions/verify-changed-files@v16 | |
id: verify-changed-files | |
with: | |
files: coverage.svg | |
- name: Commit files | |
if: steps.verify-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.verify-changed-files.outputs.files_changed == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.github_token }} | |
branch: ${{ github.ref }} |