Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements to CI workflows #294

Merged
merged 11 commits into from May 29, 2022
16 changes: 16 additions & 0 deletions .github/actions/build-dist/action.yml
@@ -0,0 +1,16 @@
name: 'Build and upload distribution'
# Builds the action distribution an uploads as an artifact for later download
runs:
using: "composite"
steps:
- name: Build distribution
shell: bash
run: |
npm install
npm run all
- name: Upload distribution
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/

12 changes: 12 additions & 0 deletions .github/actions/download-dist/action.yml
@@ -0,0 +1,12 @@
name: 'Download dist'
# Downloads a 'dist' directory artifact that was uploaded in an earlier step
# We control this with an environment variable to allow for easier global configuration.
runs:
using: "composite"
steps:
- name: Download dist
if: ${{ env.DOWNLOAD_DIST == 'true' }}
uses: actions/download-artifact@v2
with:
name: dist
path: dist/
Expand Up @@ -9,7 +9,7 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: codeql

on:
push:
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/ci-full-check.yml
@@ -0,0 +1,66 @@
name: full-check

on:
pull_request:
types:
- assigned
- review_requested
push:
branches:
- main

jobs:
action-inputs:
uses: ./.github/workflows/integ-test-action-inputs.yml
with:
cache-key-prefix: ${{github.run_number}}-

caching-config:
uses: ./.github/workflows/integ-test-action-inputs-caching.yml
with:
cache-key-prefix: ${{github.run_number}}-

execution-with-caching:
uses: ./.github/workflows/integ-test-execution-with-caching.yml
with:
cache-key-prefix: ${{github.run_number}}-

execution:
uses: ./.github/workflows/integ-test-execution.yml
with:
cache-key-prefix: ${{github.run_number}}-

gradle-versions:
uses: ./.github/workflows/integ-test-gradle-versions.yml
with:
cache-key-prefix: ${{github.run_number}}-

restore-configuration-cache:
uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
with:
cache-key-prefix: ${{github.run_number}}-

restore-custom-gradle-home:
uses: ./.github/workflows/integ-test-restore-custom-gradle-home.yml
with:
cache-key-prefix: ${{github.run_number}}-

restore-gradle-home:
uses: ./.github/workflows/integ-test-restore-gradle-home.yml
with:
cache-key-prefix: ${{github.run_number}}-

restore-java-toolchain:
uses: ./.github/workflows/integ-test-restore-java-toolchain.yml
with:
cache-key-prefix: ${{github.run_number}}-

sample-kotlin-dsl:
uses: ./.github/workflows/integ-test-sample-kotlin-dsl.yml
with:
cache-key-prefix: ${{github.run_number}}-

sample-gradle-plugin:
uses: ./.github/workflows/integ-test-sample-gradle-plugin.yml
with:
cache-key-prefix: ${{github.run_number}}-
91 changes: 91 additions & 0 deletions .github/workflows/ci-quick-check.yml
@@ -0,0 +1,91 @@
name: quick-check

on:
push:
branches-ignore: main

jobs:
build-distribution:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Build and upload distribution
uses: ./.github/actions/build-dist

action-inputs:
needs: build-distribution
uses: ./.github/workflows/integ-test-action-inputs.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

caching-config:
needs: build-distribution
uses: ./.github/workflows/integ-test-action-inputs-caching.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

execution-with-caching:
needs: build-distribution
uses: ./.github/workflows/integ-test-execution-with-caching.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

execution:
needs: build-distribution
uses: ./.github/workflows/integ-test-execution.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

gradle-versions:
needs: build-distribution
uses: ./.github/workflows/integ-test-gradle-versions.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

# restore-configuration-cache:
# needs: build-distribution
# uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
# with:
# runner-os: '["ubuntu-latest"]'
# download-dist: true

restore-custom-gradle-home:
needs: build-distribution
uses: ./.github/workflows/integ-test-restore-custom-gradle-home.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

restore-gradle-home:
needs: build-distribution
uses: ./.github/workflows/integ-test-restore-gradle-home.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

restore-java-toolchain:
needs: build-distribution
uses: ./.github/workflows/integ-test-restore-java-toolchain.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

sample-kotlin-dsl:
needs: build-distribution
uses: ./.github/workflows/integ-test-sample-kotlin-dsl.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

sample-gradle-plugin:
needs: build-distribution
uses: ./.github/workflows/integ-test-sample-gradle-plugin.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true
@@ -1,9 +1,13 @@
name: Verify generated outputs
name: verify-outputs

on:
pull_request:
types: [assigned, review_requested]
types:
- assigned
- review_requested
push:
branches:
- main

jobs:
check:
Expand Down
Expand Up @@ -3,9 +3,6 @@ name: Execute failure cases
on:
workflow_dispatch:

env:
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-

jobs:

failing-build:
Expand Down
@@ -1,30 +1,33 @@
name: Test caching configuration
name: Test action inputs that control caching

on:
pull_request:
types: [assigned, review_requested]
push:
paths:
- '.github/**'
- 'dist/**'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
workflow_call:
inputs:
cache-key-prefix:
type: string
runner-os:
type: string
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
download-dist:
type: boolean
default: false

env:
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
DOWNLOAD_DIST: ${{ inputs.download-dist }}
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: action-inputs-caching-${{ inputs.cache-key-prefix }}
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true

jobs:
seed-build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Gradle
uses: ./
with:
Expand All @@ -44,11 +47,13 @@ jobs:
needs: seed-build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Gradle
uses: ./
with:
Expand All @@ -67,11 +72,13 @@ jobs:
cache-disabled:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Gradle
uses: ./
with:
Expand All @@ -93,6 +100,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Create dummy Gradle User Home
run: mkdir -p ~/.gradle/caches
- name: Setup Gradle
Expand All @@ -111,14 +120,16 @@ jobs:
# Test seed the cache with cache-write-only and verify with cache-read-only
seed-build-write-only:
env:
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-write-only-
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{ inputs.cache-key-prefix }}-write-only-
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Gradle
uses: ./
with:
Expand All @@ -129,15 +140,17 @@ jobs:

verify-write-only-build:
env:
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-write-only-
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{ inputs.cache-key-prefix }}-write-only-
needs: seed-build-write-only
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Gradle
uses: ./
with:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/integ-test-action-inputs.yml
@@ -0,0 +1,41 @@
name: Test different action inputs

on:
workflow_call:
inputs:
cache-key-prefix:
type: string
runner-os:
type: string
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
download-dist:
type: boolean
default: false

env:
DOWNLOAD_DIST: ${{ inputs.download-dist }}
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: action-inputs-${{ inputs.cache-key-prefix }}
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true

jobs:
action-inputs:
strategy:
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Invoke with multi-line arguments
uses: ./
with:
build-root-directory: .github/workflow-samples/groovy-dsl
arguments: |
--configuration-cache
--build-cache
-DsystemProperty=FOO
-PgradleProperty=BAR
test
jar