Skip to content

Commit

Permalink
ci(pytest): get changes for three trigger scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperDramsch committed Jan 15, 2025
1 parent 83aa204 commit ad6dbc1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/python-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ jobs:
- name: Detect changed packages
id: changed-packages
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
if [ "${{ github.event_name }}" == "pull_request" ]; then
# For pull requests, compare with the PR base
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
elif [ "${{ github.event_name }}" == "push" ]; then
# For pushes, compare with the previous commit
git fetch --depth=2 origin ${{ github.ref }}
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
else
# For scheduled runs, check all files
CHANGED_FILES=$(git ls-files '*.py')
fi
echo "training_changed=$(echo "$CHANGED_FILES" | grep -q '^training/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "graphs_changed=$(echo "$CHANGED_FILES" | grep -q '^graphs/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "models_changed=$(echo "$CHANGED_FILES" | grep -q '^models/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit ad6dbc1

Please sign in to comment.