From 58ebc67389af6192519bae84f431614480b9c4e3 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 12 Feb 2021 19:05:45 -0500 Subject: [PATCH] Parallelize PR build workflow --- .github/workflows/build_pull_request.yml | 47 ++++++++++++- settings.gradle.kts | 86 +++++++++++++++++------- 2 files changed, 105 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index eb68ff377..edddd3a3b 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -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 \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 5621f86bd..3678d0c2b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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) }