-
Notifications
You must be signed in to change notification settings - Fork 7
80 lines (72 loc) · 2.97 KB
/
pull-request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# Pipeline that checks branches that have been pushed to "Main" OR are the source branch in a newly created pull request into "Main"
# Fails the test if there are Python syntax errors or undefined names OR pytest fails
name: Pydicer Pytest and Pylint Validaiton
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9"]
poetry-version: [1.7.1]
# os: [ubuntu-20.04, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install Python modules with poetry
run: |
poetry run pip install --upgrade pip
poetry install
poetry run pip install TotalSegmentator
- name: Lint with Pylint
run: |
poetry run pylint pydicer
- name: MyPy type checking
run: |
# TODO poetry run mypy
echo "Skipping MyPy type checking..."
- name: Conditional Pytest coverage
run: |
if [[ "${{ matrix.python-version }}" == "3.9" ]]; then
echo "Running Pytest with coverage..."
poetry run pip install pytest-cov coverage
# Omit CLI from coverage report since it's not fully developed
poetry run pytest --cov=pydicer --cov-report=xml --cov-config=.coveragerc
poetry run coverage report --fail-under=70 # Fail if coverage is less than 70%
else
echo "Running Pytest without coverage..."
poetry run pytest
fi
# Commit the coverage badge back to repo (only on main branch & for a specific Python version)
- name: Generate and commit coverage badge
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.9'
run: |
poetry run pip install coverage-badge # These only work with python >=3.9
# Generate an SVG coverage badge
# poetry run coverage-badge -o coverage.svg
# # Configure git
# git config user.name "github-actions"
# git config user.email "github-actions@github.com"
# # Pull latest changes to avoid conflicts
# git pull --rebase
# # Stage and commit coverage.svg
# git add coverage.svg
# git commit -m "Update coverage badge" || echo "No changes to commit"
# # Push commit
# git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}