From 1ddf62bd9e3618e29a2c015f207db9feee3bac85 Mon Sep 17 00:00:00 2001 From: daz Date: Wed, 10 Apr 2024 14:34:40 -0600 Subject: [PATCH] Add PR triggers --- .github/workflows/ci-check-and-unit-test.yml | 1 + .github/workflows/ci-check-no-dist-update.yml | 3 ++ .github/workflows/ci-init-script-check.yml | 11 ++-- .github/workflows/ci-integ-test.yml | 52 +++++++++++++++++-- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-check-and-unit-test.yml b/.github/workflows/ci-check-and-unit-test.yml index 96a7def..3ed6a13 100644 --- a/.github/workflows/ci-check-and-unit-test.yml +++ b/.github/workflows/ci-check-and-unit-test.yml @@ -2,6 +2,7 @@ name: CI-check-and-unit-test on: push: + pull_request: permissions: contents: read diff --git a/.github/workflows/ci-check-no-dist-update.yml b/.github/workflows/ci-check-no-dist-update.yml index 515cb17..2436da2 100644 --- a/.github/workflows/ci-check-no-dist-update.yml +++ b/.github/workflows/ci-check-no-dist-update.yml @@ -9,6 +9,9 @@ on: - 'release/**' paths: - 'dist/**' + pull_request: + paths: + - 'dist/**' permissions: contents: read diff --git a/.github/workflows/ci-init-script-check.yml b/.github/workflows/ci-init-script-check.yml index 454ab0b..bfd4185 100644 --- a/.github/workflows/ci-init-script-check.yml +++ b/.github/workflows/ci-init-script-check.yml @@ -3,9 +3,14 @@ name: CI-init-script-check on: push: paths: - - '.github/workflows/ci-init-script-check.yml' - - 'sources/src/resources/init-scripts/**' - - 'sources/test/init-scripts/**' + - '.github/workflows/ci-init-script-check.yml' + - 'sources/src/resources/init-scripts/**' + - 'sources/test/init-scripts/**' + pull_request: + paths: + - '.github/workflows/ci-init-script-check.yml' + - 'sources/src/resources/init-scripts/**' + - 'sources/test/init-scripts/**' workflow_dispatch: jobs: diff --git a/.github/workflows/ci-integ-test.yml b/.github/workflows/ci-integ-test.yml index 748a4fd..a6ed1b8 100644 --- a/.github/workflows/ci-integ-test.yml +++ b/.github/workflows/ci-integ-test.yml @@ -3,11 +3,13 @@ name: CI-integ-test on: workflow_dispatch: push: + pull_request: jobs: determine-suite: runs-on: ubuntu-latest outputs: + suite: ${{ steps.determine-suite.outputs.suite }} runner-os: ${{ steps.determine-suite.outputs.suite == 'quick' && '["ubuntu-latest"]' || '["ubuntu-latest", "windows-latest", "macos-latest"]' }} cache-key-prefix: ${{ steps.determine-suite.outputs.suite == 'quick' && '0' || github.run_number }} steps: @@ -27,21 +29,61 @@ jobs: # Always run quick suite for dependabot PRs if [ "${{ github.actor }}" == "dependabot[bot]" ]; then - echo "Dependabot: suite=quick" + echo "Dependabot PR: suite=quick" echo "suite=quick" >> "$GITHUB_OUTPUT" exit 0 fi - # Run full suite for PRs + # Run quick suite for pushes with no associated PR if [ "${{ steps.PR.outputs.pr_found }}" == "false" ]; then - echo "PR not found: suite=quick" + echo "Push with no associated PR: suite=quick" echo "suite=quick" >> "$GITHUB_OUTPUT" else - echo "PR found: suite=full" - echo "suite=full" >> "$GITHUB_OUTPUT" + # When there's an associated PR, run full suite for pull_request trigger. Skip tests for push trigger. + if [ "${{ github.event_name }}" == "pull_request" ]; then + echo "Pull request trigger: suite=full" + echo "suite=full" >> "$GITHUB_OUTPUT" + else + echo "Push with associated PR: suite=skip" + echo "suite=skip" >> "$GITHUB_OUTPUT" + fi fi + - name: Duplicate in script + uses: actions/github-script@v7 + with: + env: + PR_FOUND: ${{ steps.PR.outputs.pr_found }} + script: | + // Always run quick suite if we are not in the core `gradle/actions` repository + // This reduces the load for developers working on forks + if (github.repo.repo !== 'gradle/actions') { + console.log('Not in core repository: suite=quick') + return 'quick' + } + + // Always run quick suite for dependabot PRs + if (github.actor === 'dependabot[bot]') { + console.log('Dependabot PR: suite=quick') + return 'quick' + } + + // Run quick suite for pushes with no associated PR + if (process.env.PR_FOUND === 'false') { + console.log('Push with no associated PR: suite=quick') + return 'quick' + } else { + // When there's an associated PR, run full suite for pull_request trigger. Skip tests for push trigger. + if (github.context.eventName === 'pull_request') { + console.log('Pull request trigger: suite=full') + return 'full' + } else { + console.log('Push with associated PR: suite=skip') + return 'skip' + } + } build-distribution: + if: ${{ needs.determine-suite.outputs.suite != 'skip' }} runs-on: ubuntu-latest steps: - name: Checkout sources