Add PR triggers

This commit is contained in:
daz 2024-04-10 14:34:40 -06:00
parent 1de476c015
commit 1ddf62bd9e
No known key found for this signature in database
4 changed files with 59 additions and 8 deletions

View File

@ -2,6 +2,7 @@ name: CI-check-and-unit-test
on:
push:
pull_request:
permissions:
contents: read

View File

@ -9,6 +9,9 @@ on:
- 'release/**'
paths:
- 'dist/**'
pull_request:
paths:
- 'dist/**'
permissions:
contents: read

View File

@ -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:

View File

@ -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