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

tests: udpate the github workflow to run tests suggested by spread-filter tool #14519

Open
wants to merge 2 commits into
base: master
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
5 changes: 0 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
# - https://github.com/actions/labeler/issues/112
# - https://github.com/actions/labeler/issues/104

# Add 'Run nested -auto-' label to either any change on nested lib or nested test
Run nested -auto-:
- tests/lib/nested.sh
- tests/nested/**/*

# Add 'Needs Documentation -auto-' label to indicate a change needs changes in the docs
Needs Documentation -auto-:
- cmd/snap/**/*"
Expand Down
34 changes: 21 additions & 13 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,6 @@ jobs:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.group }}-${{ steps.get-previous-attempt.outputs.previous_attempt }}"


- name: Prepare test results env and vars
id: prepare-test-results-env
run: |
Expand All @@ -775,7 +774,12 @@ jobs:

# Make sure the test results dirs are created
# This step has to be after the cache is restored
mkdir -p "$TEST_RESULTS_DIR"
mkdir -p "$TEST_RESULTS_DIR"

- name: Prepare nested env vars
if: contains(github.event.pull_request.labels.*.name, 'Run nested') && startsWith(matrix.group, 'nested-')
run: |
echo "RUN_NESTED=true" >> "$GITHUB_ENV"

- name: Get changed files
id: changed-files
Expand Down Expand Up @@ -810,20 +814,24 @@ jobs:
if [ -n "$FAILED_TESTS" ]; then
RUN_TESTS="$FAILED_TESTS"
else
CHANGES_PARAM=""
for CHANGE in $CHANGED_FILES; do
CHANGES_PARAM="$CHANGES_PARAM -c $CHANGE"
done
for SYSTEM in ${{ matrix.systems }}; do
for TESTS in ${{ matrix.tests }}; do
RUN_TESTS="$RUN_TESTS ${{ matrix.backend }}:$SYSTEM:$TESTS"
done
CHANGES_PARAM=""
for CHANGE in $CHANGED_FILES; do
CHANGES_PARAM="$CHANGES_PARAM -c $CHANGE"
done
SUGGESTED_TESTS="$SUGGESTED_TESTS $(./tests/lib/external/snapd-testing-tools/utils/spread-filter -r ./tests/lib/spread/rules/${{ matrix.rules }}.yaml -p "${{ matrix.backend }}:$SYSTEM" $CHANGES_PARAM)"
# Configure parameters to run tests based on current changes
# The tests are just filtered when the change is a PR
# When 'Run Nested' label is added in a pr, all the nested tests have to be executed
if [ -z "${{ github.event.number }}" ] || [ "$RUN_NESTED" = 'true' ]; then
for TESTS in ${{ matrix.tests }}; do
RUN_TESTS="$RUN_TESTS ${{ matrix.backend }}:$SYSTEM:$TESTS"
done
else
RUN_TESTS="$RUN_TESTS $(./tests/lib/external/snapd-testing-tools/utils/spread-filter -r ./tests/lib/spread/rules/${{ matrix.rules }}.yaml -p "${{ matrix.backend }}:$SYSTEM" $CHANGES_PARAM)"
fi
done
fi
echo RUN_TESTS="$RUN_TESTS" >> $GITHUB_ENV
echo "Suggested tests by spread-filter tool"
echo "$SUGGESTED_TESTS"

- name: Setup grafana parameters
if: "!contains(github.event.pull_request.labels.*.name, 'Skip spread')"
Expand Down Expand Up @@ -867,7 +875,7 @@ jobs:
done

- name: Run spread tests
if: "!contains(github.event.pull_request.labels.*.name, 'Skip spread') && ( !startsWith(matrix.group, 'nested-') || contains(github.event.pull_request.labels.*.name, 'Run nested') )"
if: "!contains(github.event.pull_request.labels.*.name, 'Skip spread')"
env:
SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }}
run: |
Expand Down
10 changes: 8 additions & 2 deletions tests/lib/spread/rules/nested.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ rules:
- tests/nested/.*
to: [$SELF]

rest:
from: [.*]
nestedlib:
from:
- tests/lib/nested.sh
to: [tests/nested/]

assertions:
from:
- tests/lib/assertions/.*
to: [tests/nested/]
Loading