Parallelize PR build workflow

This commit is contained in:
arkon 2021-02-12 19:05:45 -05:00
parent 13c1b882c8
commit 58ebc67389
2 changed files with 105 additions and 28 deletions

View File

@ -14,11 +14,14 @@ jobs:
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
build:
name: Build extension repo
build_multisrc:
name: Build multisrc modules
needs: check_wrapper
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
runs-on: ubuntu-latest
strategy:
matrix:
lang: [all, ar, ca, de, en, es, fr, id, it, ja, ko, pt, ru, th, tr, vi, zh]
steps:
- name: Checkout PR
uses: actions/checkout@v2
@ -35,16 +38,54 @@ jobs:
- name: Generate sources from the multi-source library
uses: eskatos/gradle-command-action@v1
env:
CI_MULTISRC: "true"
with:
arguments: :multisrc:multisrcGenerators
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
- name: Build extensions
- name: Build "${{ matrix.lang }}" extensions
uses: eskatos/gradle-command-action@v1
env:
CI_MULTISRC: "true"
CI_MATRIX_LANG: ${{ matrix.lang }}
with:
arguments: assembleRelease
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
build_individual:
name: Build individual modules
needs: check_wrapper
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
runs-on: ubuntu-latest
strategy:
matrix:
lang: [all, ar, ca, de, en, es, fr, id, it, ja, ko, pt, ru, th, tr, vi, zh]
steps:
- name: Checkout PR
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Copy CI gradle.properties
run: |
mkdir -p ~/.gradle
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
- name: Build "${{ matrix.lang }}" extensions
uses: eskatos/gradle-command-action@v1
env:
CI_MULTISRC: "false"
CI_MATRIX_LANG: ${{ matrix.lang }}
with:
arguments: assembleRelease
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true

View File

@ -10,34 +10,70 @@ project(":duktape-stub").projectDir = File("lib/duktape-stub")
include(":lib-dataimage")
project(":lib-dataimage").projectDir = File("lib/dataimage")
include(":multisrc")
project(":multisrc").projectDir = File("multisrc")
if (System.getenv("CI") == null) {
// Local development
// Loads all extensions
File(rootDir, "src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":individual:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("src/${dir.name}/${subdir.name}")
include(":multisrc")
project(":multisrc").projectDir = File("multisrc")
// Loads all extensions
File(rootDir, "src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":individual:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("src/${dir.name}/${subdir.name}")
}
}
// Loads generated extensions from multisrc
File(rootDir, "generated-src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":theme:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("generated-src/${dir.name}/${subdir.name}")
}
}
/**
* If you're developing locally and only want to work with a single module,
* comment out the parts above and uncomment below.
*/
// val lang = "all"
// val name = "mmrcms"
// include(":${lang}-${name}")
// project(":${lang}-${name}").projectDir = File("src/${lang}/${name}")
} else {
// Running in CI (GitHub Actions)
val isMultisrc = System.getenv("CI_MULTISRC") == "true"
val lang = System.getenv("CI_MATRIX_LANG")
if (isMultisrc) {
include(":multisrc")
project(":multisrc").projectDir = File("multisrc")
// Loads generated extensions from multisrc
File(rootDir, "generated-src").eachDir { dir ->
if (dir.name == lang) {
dir.eachDir { subdir ->
val name = ":theme:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("generated-src/${dir.name}/${subdir.name}")
}
}
}
} else {
// Loads all extensions
File(rootDir, "src").eachDir { dir ->
if (dir.name == lang) {
dir.eachDir { subdir ->
val name = ":individual:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("src/${dir.name}/${subdir.name}")
}
}
}
}
}
// Loads generated extensions from multisrc
File(rootDir, "generated-src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":theme:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("generated-src/${dir.name}/${subdir.name}")
}
}
/**
* If you're developing locally and only want to work with a single module,
* comment out the parts above and uncomment below.
*/
// val lang = "all"
// val name = "mmrcms"
// include(":${lang}-${name}")
// project(":${lang}-${name}").projectDir = File("src/${lang}/${name}")
inline fun File.eachDir(block: (File) -> Unit) {
listFiles()?.filter { it.isDirectory }?.forEach { block(it) }