Skip to content

Commit

Permalink
ci: only conditionally run python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Jan 18, 2021
1 parent 44bfcc8 commit 7d8cc92
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,35 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Check if python changes are present
id: check
env:
GITHUB_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
continue-on-error: true
run: ./scripts/ci_skip_python.sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
if: steps.check.outcome == 'failure'
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: steps.check.outcome == 'failure'
run: |
python -m pip install -r requirements.txt
- name: Lint with black
if: steps.check.outcome == 'failure'
run: |
black --check --target-version py38 setup.py pyhtzee tests
- name: Lint with flake8
if: steps.check.outcome == 'failure'
run: |
flake8 . --count --show-source --statistics
- name: Lint with mypy
if: steps.check.outcome == 'failure'
run: |
mypy --ignore-missing-imports .
- name: Test with pytest
if: steps.check.outcome == 'failure'
run: |
pytest tests/*.py
1 change: 1 addition & 0 deletions pyhtzee/scoring.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# asdf
"""
Scoring functions for lists with five dice. All functions (except upper sectino bonus)
are given a a list of ints representing the number of dots on the face. If the list of
Expand Down
17 changes: 17 additions & 0 deletions scripts/ci_skip_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
URL="https://api.github.com/repos/${GITHUB_REPO}/pulls/${PR_NUMBER}/files"
FILES=$(curl -s -X GET -G $URL | jq -r '.[] | .filename')

cat<<EOF
CHANGED FILES:
$FILES
EOF

echo ${FILES}
if [[ "${FILES}" =~ (pyhtzee\/.*\.py|setup\.py) ]]; then
echo "Detected python files... Exiting with FAILURE code"
exit 1
fi
echo "No python changes... Exiting with SUCCESS code"
exit 0

0 comments on commit 7d8cc92

Please sign in to comment.