diff --git a/.github/labeler.yml b/.github/labeler.yml index a08c77bdbd5..de544b4917f 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -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/**/*" diff --git a/.github/workflows/spread-tests.yaml b/.github/workflows/spread-tests.yaml index dcd2866b119..5ef10482337 100644 --- a/.github/workflows/spread-tests.yaml +++ b/.github/workflows/spread-tests.yaml @@ -67,7 +67,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 @@ -103,19 +108,19 @@ jobs: RUN_TESTS="$FAILED_TESTS" else for SYSTEM in ${{ inputs.systems }}; do - for TESTS in ${{ inputs.tasks }}; do - RUN_TESTS="$RUN_TESTS ${{ inputs.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/${{ inputs.rules }}.yaml -p "${{ inputs.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')" @@ -159,7 +164,7 @@ jobs: done - name: Run spread tests - if: "!contains(github.event.pull_request.labels.*.name, 'Skip spread') && ( !startsWith(inputs.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: | diff --git a/tests/lib/spread/rules/nested.yaml b/tests/lib/spread/rules/nested.yaml index a4341187eef..71d463fbb70 100644 --- a/tests/lib/spread/rules/nested.yaml +++ b/tests/lib/spread/rules/nested.yaml @@ -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/]