2024-01-12 12:11:42 -05:00
|
|
|
name: Test dependency graph
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
cache-key-prefix:
|
|
|
|
type: string
|
|
|
|
runner-os:
|
|
|
|
type: string
|
2024-01-25 21:59:53 -05:00
|
|
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
2024-01-12 12:11:42 -05:00
|
|
|
|
|
|
|
env:
|
|
|
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: dependency-graph-${{ inputs.cache-key-prefix }}
|
|
|
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
|
|
|
|
|
|
|
jobs:
|
2024-01-12 14:30:54 -05:00
|
|
|
unsupported-gradle-version-warning:
|
2024-01-12 12:11:42 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Gradle for dependency-graph generate
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
gradle-version: 7.0.1
|
|
|
|
dependency-graph: generate
|
2024-01-12 14:30:54 -05:00
|
|
|
dependency-graph-continue-on-failure: true
|
2024-01-12 12:11:42 -05:00
|
|
|
- name: Run with unsupported Gradle version
|
|
|
|
working-directory: .github/workflow-samples/groovy-dsl
|
|
|
|
run: |
|
2024-01-12 14:30:54 -05:00
|
|
|
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"
|
2024-01-12 12:11:42 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-01-12 14:30:54 -05:00
|
|
|
unsupported-gradle-version-failure:
|
2024-01-12 12:11:42 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Gradle for dependency-graph generate
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
gradle-version: 7.0.1
|
|
|
|
dependency-graph: generate
|
2024-01-12 14:30:54 -05:00
|
|
|
dependency-graph-continue-on-failure: false
|
2024-01-12 12:11:42 -05:00
|
|
|
- name: Run with unsupported Gradle version
|
|
|
|
working-directory: .github/workflow-samples/groovy-dsl
|
|
|
|
run: |
|
2024-01-12 14:30:54 -05:00
|
|
|
if gradle help; then
|
|
|
|
echo "Expected build to fail with Gradle 7.0.1"
|
2024-01-12 12:11:42 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-01-12 14:30:54 -05:00
|
|
|
insufficient-permissions-warning:
|
2024-01-12 12:11:42 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Gradle for dependency-graph generate
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
dependency-graph: generate-and-submit
|
2024-01-12 14:30:54 -05:00
|
|
|
dependency-graph-continue-on-failure: true
|
2024-01-12 12:11:42 -05:00
|
|
|
- name: Run with insufficient permissions
|
|
|
|
working-directory: .github/workflow-samples/groovy-dsl
|
|
|
|
run: ./gradlew help
|
2024-01-12 14:30:54 -05:00
|
|
|
# This test is primarily for demonstration: it's unclear how to check for warnings emitted in the post-action
|
2024-01-12 12:11:42 -05:00
|
|
|
|
2024-01-12 14:30:54 -05:00
|
|
|
SHOULD_FAIL-insufficient-permissions-failure:
|
2024-01-12 12:11:42 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
2024-01-12 14:30:54 -05:00
|
|
|
continue-on-error: true
|
2024-01-12 12:11:42 -05:00
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Gradle for dependency-graph generate
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
dependency-graph: generate-and-submit
|
2024-01-12 14:30:54 -05:00
|
|
|
dependency-graph-continue-on-failure: false
|
2024-01-12 12:11:42 -05:00
|
|
|
- name: Run with insufficient permissions
|
|
|
|
working-directory: .github/workflow-samples/groovy-dsl
|
|
|
|
run: ./gradlew help
|
2024-01-12 14:30:54 -05:00
|
|
|
# This test is primarily for demonstration: it's unclear how to check for a failure in the post-action
|