Skip to content

Feature/add-population-frontend #257

Feature/add-population-frontend

Feature/add-population-frontend #257

Workflow file for this run

name: build
on:
pull_request:
types:
- opened
- reopened
- synchronize
paths-ignore:
- "**.md"
env:
REPO_NAME: ${{ github.event.repository.name }}
jobs:
pre-commit:
if: always()
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Install Graphviz
uses: tlylt/install-graphviz@v1
- name: Run black
shell: bash
run: pre-commit run black --all-files
- name: Run flake8
shell: bash
run: pre-commit run flake8 --all-files
- name: Run docformatter
shell: bash
run: pre-commit run docformatter --all-file
- name: Run pydocstyle
shell: bash
run: pre-commit run pydocstyle --all-file
mypy:
if: always()
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Install Graphviz
uses: tlylt/install-graphviz@v1
- name: Run mypy
shell: bash
run: pre-commit run mypy --all-file
build-and-test:
name: "Build and Test Python 3.9"
runs-on: ubuntu-latest
if: always()
strategy:
max-parallel: 5
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: "pip"
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install pytest-github-actions-annotate-failures
- name: Install graphviz
uses: tlylt/install-graphviz@v1
- name: PyTest with code coverage
continue-on-error: true
run: |
pytest --junitxml pytest.xml --cov=. --cov-report=term-missing --cov-report=xml --cov-branch | tee pytest-coverage.txt
- name: Upload Coverage Results txt
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-results-txt
path: ./pytest-coverage.txt
- name: Upload Coverage Results xml
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-results-xml
path: ./coverage.xml
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-py39
path: ./pytest.xml
publish-test-results:
name: "Publish Unit Tests Results"
needs: build-and-test
runs-on: ubuntu-latest
if: always()
timeout-minutes: 20
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
files: artifacts/unit-test-py39/*.xml
- name: Pytest coverage comment in pull-request
uses: MishaKav/pytest-coverage-comment@main
with:
default-branch: main
pytest-coverage-path: artifacts/coverage-results-txt/pytest-coverage.txt
hide-badge: true
hide-report: false
create-new-comment: false
hide-comment: false
report-only-changed-files: true
- name: Get the Coverage
shell: bash
run: |
regex='<coverage.+line-rate="([0-9).[0-9]+)".+>'
line=$(grep -oP $regex artifacts/coverage-results-xml/coverage.xml)
[[ $line =~ $regex ]]
coverage=$( bc <<< ${BASH_REMATCH[1]}*100 )
if (( $(echo "$coverage > 90" |bc -l) )); then
COLOR=green
else
COLOR=red
fi
echo "COVERAGE=${coverage%.*}%" >> $GITHUB_ENV
echo "COLOR=$COLOR" >> $GITHUB_ENV
- name: Create the Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 8446f35dc373966dc971fb9237483cce
filename: coverage.${{ env.REPO_NAME }}.${{ github.event.number }}.json
label: coverage
message: ${{ env.COVERAGE }}
color: ${{ env.COLOR }}
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Current Branch | Main Branch |
- name: Create coverage comment
uses: peter-evans/[email protected]
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Current Branch | Main Branch |
| ------ | ------ |
![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/NoB0/8446f35dc373966dc971fb9237483cce/raw/coverage.${{ env.REPO_NAME }}.${{ github.event.number }}.json) | ![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/NoB0/8446f35dc373966dc971fb9237483cce/raw/coverage.${{ env.REPO_NAME }}.main.json) |
edit-mode: replace