diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cdaad326e..9f604c628 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,52 +124,6 @@ jobs: name: test-reports path: '**/build/reports/tests/' - build_templates: - name: Build templates - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Change Gradle wrapper permissions - run: chmod +x ./gradlew - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Build debug templates - run: ./gradlew :templates-impl:testDebug --continue - env: - ANDROIDIDE_TEST: true - ANDROIDIDE_TEMPLATES_BUILD: true - IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} - IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} - IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} - IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} - IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} - IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} - - name: Upload test reports - if: ${{ always() }} - uses: actions/upload-artifact@v3 - with: - name: templates-test-reports - path: 'templates-impl/build/reports/tests/' - - name: Upload template APKs - if: ${{ always() }} - uses: actions/upload-artifact@v3 - with: - name: templates-apks - path: 'build/templates/' - test_tooling_api: name: Test Tooling API implementation runs-on: ubuntu-latest @@ -213,8 +167,8 @@ jobs: publish: name: Publish release runs-on: ubuntu-latest - needs: [ build_apk, build_templates, unit_test_debug, test_tooling_api ] - if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.build_apk.result == 'success' && needs.build_templates.result == 'success' && needs.unit_test_debug.result == 'success' && needs.test_tooling_api.result == 'success' }} + needs: [ build_apk, unit_test_debug, test_tooling_api ] + if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.build_apk.result == 'success' && needs.unit_test_debug.result == 'success' && needs.test_tooling_api.result == 'success' }} steps: - name: Checkout uses: actions/checkout@v3 diff --git a/templates-impl/src/test/java/com/itsaky/androidide/templates/utils.kt b/templates-impl/src/test/java/com/itsaky/androidide/templates/utils.kt index f85da9d4a..7f3a8e94c 100644 --- a/templates-impl/src/test/java/com/itsaky/androidide/templates/utils.kt +++ b/templates-impl/src/test/java/com/itsaky/androidide/templates/utils.kt @@ -38,10 +38,6 @@ val testProjectsDir: File by lazy { FileProvider.currentDir().resolve("build/templateTest").toFile() } -val isBuildTemplates by lazy { - System.getenv("ANDROIDIDE_TEMPLATES_BUILD").toBoolean() -} - fun mockPrefManager(configure: PreferenceManager.() -> Unit = {}) { mockkStatic(::prefManager) @@ -126,7 +122,7 @@ private fun generateTemplateProject(name: String, template: Template mockTemplateDatas(useKts = false) template.setupRootProjectParams(name = projectName, packageName = packageName, language = language) - template.executeRecipe(projectName) + template.executeRecipe() unmockTemplateDatas() } @@ -136,7 +132,7 @@ private fun generateTemplateProject(name: String, template: Template mockTemplateDatas(useKts = true) template.setupRootProjectParams(name = projectName, packageName = "${packageName}.kts", language = language) - template.executeRecipe(projectName) + template.executeRecipe() unmockTemplateDatas() } } @@ -170,42 +166,8 @@ fun Template.setupRootProjectParams(name: String = "TestTemplate", (param as EnumParameter).value = minSdk } -fun Template.executeRecipe(projectName: String) { +fun Template.executeRecipe() { TestRecipeExecutor().apply(recipe) - - if (isBuildTemplates) { - val projectDir = File(testProjectsDir, projectName) - if (!projectDir.isDirectory) { - return - } - - var name = "gradlew" - if (isWindows()) { - name += ".bat" - } - - val gradlew = File(projectDir, name) - - // Start the build process - val process = wrapperProcess(gradlew, "assembleDebug") - check( - process.waitFor() == 0) { "Failed to build template project '$projectName' at location '$projectDir'" } - - // if the build process is successful, copy the apk to a common location - val apk = File(projectDir, "app/build/outputs/apk/debug/app-debug.apk") - val dest = FileProvider.projectRoot() - .resolve("build/templates/$projectName.apk") - .toFile() - if (dest.exists()) { - dest.delete() - } - - dest.parentFile!!.mkdirs() - apk.copyTo(dest) - - // Stop the daemon - wrapperProcess(gradlew, "--stop").waitFor() - } } fun Collection>.assertParameterTypes(