From 369fcc54d88088e76ce53b85357aeeaaf2da1ec2 Mon Sep 17 00:00:00 2001 From: daz Date: Fri, 12 Jan 2024 10:11:42 -0700 Subject: [PATCH] Add tests for dependency graph failures --- .github/workflows/ci-full-check.yml | 5 + .github/workflows/ci-quick-check.yml | 7 ++ .../integ-test-dependency-graph-failures.yml | 108 ++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 .github/workflows/integ-test-dependency-graph-failures.yml diff --git a/.github/workflows/ci-full-check.yml b/.github/workflows/ci-full-check.yml index 16c9339..2fa2614 100644 --- a/.github/workflows/ci-full-check.yml +++ b/.github/workflows/ci-full-check.yml @@ -36,6 +36,11 @@ jobs: with: cache-key-prefix: ${{github.run_number}}- + dependency-graph-failures: + uses: ./.github/workflows/integ-test-dependency-graph-failures.yml + with: + cache-key-prefix: ${{github.run_number}}- + execution-with-caching: uses: ./.github/workflows/integ-test-execution-with-caching.yml with: diff --git a/.github/workflows/ci-quick-check.yml b/.github/workflows/ci-quick-check.yml index e6ae89b..360041c 100644 --- a/.github/workflows/ci-quick-check.yml +++ b/.github/workflows/ci-quick-check.yml @@ -59,6 +59,13 @@ jobs: runner-os: '["ubuntu-latest"]' download-dist: true + dependency-graph-failures: + needs: build-distribution + uses: ./.github/workflows/integ-test-dependency-graph-failures.yml + with: + runner-os: '["ubuntu-latest"]' + download-dist: true + execution-with-caching: needs: build-distribution uses: ./.github/workflows/integ-test-execution-with-caching.yml diff --git a/.github/workflows/integ-test-dependency-graph-failures.yml b/.github/workflows/integ-test-dependency-graph-failures.yml new file mode 100644 index 0000000..e09e87b --- /dev/null +++ b/.github/workflows/integ-test-dependency-graph-failures.yml @@ -0,0 +1,108 @@ +name: Test dependency graph + +on: + workflow_call: + inputs: + cache-key-prefix: + type: string + runner-os: + type: string + default: '["ubuntu-latest"]' + download-dist: + type: boolean + default: false + +env: + DOWNLOAD_DIST: ${{ inputs.download-dist }} + GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: dependency-graph-${{ inputs.cache-key-prefix }} + GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true + +jobs: + unsupported-gradle-version-failure: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Download distribution if required + uses: ./.github/actions/download-dist + - name: Setup Gradle for dependency-graph generate + uses: ./ + with: + gradle-version: 7.0.1 + dependency-graph: generate + - name: Run with unsupported Gradle version + working-directory: .github/workflow-samples/groovy-dsl + run: | + if gradle help; then + echo "Expected build to fail with Gradle 7.0.1" + exit 1 + fi + + unsupported-gradle-version-warning: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Download distribution if required + uses: ./.github/actions/download-dist + - name: Setup Gradle for dependency-graph generate + uses: ./ + with: + gradle-version: 7.0.1 + dependency-graph: generate + - name: Run with unsupported Gradle version + working-directory: .github/workflow-samples/groovy-dsl + run: | + gradle help + + - name: Run with unsupported Gradle version + working-directory: .github/workflow-samples/groovy-dsl + run: | + if gradle help | grep -q 'warning::Dependency Graph is not supported for Gradle 7.0.1. No dependency snapshot will be generated.'; + then + echo "Got the expected warning" + else + echo "Did not get the expected warning" + exit 1 + fi + + insufficient-permissions-failure: + runs-on: ubuntu-latest + permissions: + contents: read + continue-on-error: true + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Download distribution if required + uses: ./.github/actions/download-dist + - name: Setup Gradle for dependency-graph generate + uses: ./ + with: + dependency-graph: generate-and-submit + - name: Run with insufficient permissions + working-directory: .github/workflow-samples/groovy-dsl + run: ./gradlew help + # TODO unclear how to check for failure in post action + + insufficient-permissions-warning: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Download distribution if required + uses: ./.github/actions/download-dist + - name: Setup Gradle for dependency-graph generate + uses: ./ + with: + dependency-graph: generate-and-submit + - name: Run with insufficient permissions + working-directory: .github/workflow-samples/groovy-dsl + run: ./gradlew help + # TODO unclear how to check for warning in post action