Skip to content

Commit

Permalink
CI: only tests plugins on a PR if they were changed
Browse files Browse the repository at this point in the history
  • Loading branch information
daywalker90 committed Jun 5, 2024
1 parent fd4ea9b commit ac5adee
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,27 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Get changed files
id: get_changed_files
if: ${{ github.event_name == 'pull_request' }}
uses: tj-actions/changed-files@v44
with:
files: '**/*'

- name: Set plugin_dirs
id: set_plugin_dirs
if: ${{ github.event_name == 'pull_request' }}
run: |
changed_files=$(echo "${{ steps.get_changed_files.outputs.all_changed_files }}" | tr ',' '\n')
plugin_dirs=""
for file in $changed_files; do
dir=$(dirname "$file" | cut -d'/' -f1)
if [[ "$dir" != "." && "${dir:0:1}" != "." && ! " ${plugin_dirs[@]} " =~ " ${dir} " ]]; then
plugin_dirs="${plugin_dirs} ${dir}"
fi
done
echo "plugin_dirs=${plugin_dirs}" >> "$GITHUB_OUTPUT"
- name: Run pytest tests
id: pytest_tests
run: |
Expand All @@ -95,7 +116,11 @@ jobs:
pip3 install --upgrade pip
pip3 install --user -U virtualenv pip > /dev/null
plugin_dirs=''
if [[ "${{ github.event_name }}" == 'pull_request' ]]; then
plugin_dirs="${{ steps.set_plugin_dirs.outputs.plugin_dirs }}"
else
plugin_dirs=""
fi
# Run the tests: In the case of a 'pull_request' event only the plugins in `plugin_dirs`
# are going to be tested; otherwise ('push' event) we test all plugins.
Expand All @@ -106,7 +131,12 @@ jobs:
update_badges='--update-badges'
fi
python3 .ci/test.py main ${{ matrix.python-version }} $update_badges $(echo "$plugin_dirs")
if [[ -z "$plugin_dirs" ]]; then
# Test all plugins if no specific plugins were changed
python3 .ci/test.py main ${{ matrix.python-version }} $update_badges
else
python3 .ci/test.py main ${{ matrix.python-version }} $update_badges $(echo "$plugin_dirs")
fi
gather:
# A dummy task that depends on the full matrix of tests, and signals completion.
Expand Down

0 comments on commit ac5adee

Please sign in to comment.