Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ci: only conditionally run python tests #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 changed python files... Exiting with FAILURE code"
exit 1
fi
echo "No python changes... Exiting with SUCCESS code"
exit 0