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

CI: only tests plugins on a PR if they were changed #537

Merged
merged 1 commit into from
Jun 5, 2024
Merged
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
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
Loading