Skip to content

Commit

Permalink
Dynamic CI jobs for examples (#2677)
Browse files Browse the repository at this point in the history
  • Loading branch information
rnorth committed May 16, 2020
1 parent 1eef935 commit 8c7c769
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 50 deletions.
@@ -1,4 +1,4 @@
name: in-container
name: CI-Docker-Wormhole

on:
pull_request: {}
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/ci-examples.yml
@@ -0,0 +1,73 @@
name: CI-Examples

on:
pull_request: {}
push: { branches: [ master ] }

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
find_gradle_jobs:
runs-on: ubuntu-18.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '1.8'
- name: Cache Gradle Home files
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-home-testmatrix-examples-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-home-testmatrix-examples-
${{ runner.os }}-gradle-home-
- id: set-matrix
working-directory: ./examples/
env:
# Since we override the tests executor,
# we should not push empty results to the cache
READ_ONLY_REMOTE_GRADLE_CACHE: true
run: |
TASKS=$(./gradlew --no-daemon --parallel -q testMatrix)
echo $TASKS
echo "::set-output name=matrix::{\"gradle_args\":$TASKS}"
check:
needs: find_gradle_jobs
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.find_gradle_jobs.outputs.matrix) }}
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '1.8'
- name: Cache Gradle Home files
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-home-examples-${{matrix.gradle_args}}_check-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-home-examples-${{matrix.gradle_args}}_check-
${{ runner.os }}-gradle-home-examples-${{matrix.gradle_args}}_check-
${{ runner.os }}-gradle-home-examples-
- name: Clear existing docker image cache
run: docker image prune -af
- name: Build and test Examples with Gradle (${{matrix.gradle_args}})
working-directory: ./examples/
run: |
./gradlew --no-daemon --continue --scan --info ${{matrix.gradle_args}}
- name: Aggregate Examples test reports with ciMate
if: always()
env:
CIMATE_PROJECT_ID: 2348n4vl
CIMATE_CI_KEY: "Examples / ${{ runner.os }} / ${{matrix.gradle_args}}"
run: |
wget -q https://get.cimate.io/release/linux/cimate
chmod +x cimate
./cimate "**/TEST-*.xml"
27 changes: 0 additions & 27 deletions .github/workflows/ci.yml
Expand Up @@ -69,30 +69,3 @@ jobs:
wget -q https://get.cimate.io/release/linux/cimate
chmod +x cimate
./cimate "**/TEST-*.xml"
examples:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '1.8'
- name: Cache Gradle Home files
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-home-examples-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-home-examples-
- name: Build and test Examples with Gradle
working-directory: ./examples/
run: |
./gradlew --no-daemon --scan --info check
- name: Aggregate test reports with ciMate
if: always()
env:
CIMATE_PROJECT_ID: 2348n4vl
CIMATE_CI_KEY: examples
run: |
wget -q https://get.cimate.io/release/linux/cimate
chmod +x cimate
./cimate "**/TEST-*.xml"
5 changes: 5 additions & 0 deletions examples/build.gradle
@@ -1 +1,6 @@
// empty build.gradle for dependabot
apply from: "$rootDir/../gradle/ci-support.gradle"

subprojects {
apply plugin:"java"
}
36 changes: 36 additions & 0 deletions examples/settings.gradle
@@ -1,3 +1,18 @@
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.ch.myniva.gradle:s3-build-cache:0.10.0"
classpath "com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.2.1"
}
}

apply plugin: 'ch.myniva.s3-build-cache'
apply plugin: 'com.gradle.enterprise'

rootProject.name = 'testcontainers-examples'

includeBuild '..'
Expand All @@ -15,3 +30,24 @@ include 'spring-boot'
include 'cucumber'
include 'spring-boot-kotlin-redis'
include 'spock'

ext.isMasterBuild = false ||
(System.getenv("GITHUB_REF") == "refs/heads/master") ||
(System.getenv("BUILD_SOURCEBRANCHNAME") == "master")

buildCache {
local {
enabled = !isMasterBuild
}

remote(ch.myniva.gradle.caching.s3.AwsS3BuildCache) {
endpoint = 'fra1.digitaloceanspaces.com'
region = 'fra1'
bucket = 'testcontainers'
path = 'cache'
push = isMasterBuild && !System.getenv("READ_ONLY_REMOTE_GRADLE_CACHE")
headers = [
'x-amz-acl': 'public-read'
]
}
}
6 changes: 3 additions & 3 deletions gradle/ci-support.gradle
Expand Up @@ -28,9 +28,9 @@ gradle.taskGraph.whenReady {
subproject.tasks.withType(Test).all {
testExecuter([execute: { spec, processor -> }, stopNow:{}] as org.gradle.api.internal.tasks.testing.TestExecuter)
}
subproject.tasks.findByName("shadowJar").enabled = false
subproject.tasks.findByName("javadoc").enabled = false
subproject.tasks.findByName("delombok").enabled = false
subproject.tasks.findByName("shadowJar")?.enabled = false
subproject.tasks.findByName("javadoc")?.enabled = false
subproject.tasks.findByName("delombok")?.enabled = false
subproject.tasks.findByName("japicmp")?.enabled = false
}
}
Expand Down
38 changes: 19 additions & 19 deletions settings.gradle
Expand Up @@ -13,6 +13,25 @@ buildscript {
apply plugin: 'ch.myniva.s3-build-cache'
apply plugin: 'com.gradle.enterprise'

rootProject.name = 'testcontainers-java'

include "bom"

include "testcontainers"
project(':testcontainers').projectDir = "$rootDir/core" as File

file('modules').eachDir { dir ->
include dir.name
project(":${dir.name}").projectDir = dir
}

include ':docs:examples:junit4:generic'
include ':docs:examples:junit4:redis'
include ':docs:examples:junit5:redis'
include ':docs:examples:spock:redis'

include 'test-support'

ext.isMasterBuild = false ||
(System.getenv("GITHUB_REF") == "refs/heads/master") ||
(System.getenv("BUILD_SOURCEBRANCHNAME") == "master")
Expand All @@ -34,25 +53,6 @@ buildCache {
}
}

rootProject.name = 'testcontainers-java'

include "bom"

include "testcontainers"
project(':testcontainers').projectDir = "$rootDir/core" as File

file('modules').eachDir { dir ->
include dir.name
project(":${dir.name}").projectDir = dir
}

include ':docs:examples:junit4:generic'
include ':docs:examples:junit4:redis'
include ':docs:examples:junit5:redis'
include ':docs:examples:spock:redis'

include 'test-support'

gradleEnterprise {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
Expand Down

0 comments on commit 8c7c769

Please sign in to comment.