Skip to content

Commit

Permalink
🪟🔧 Switch FE unit/build to gradle (#12151)
Browse files Browse the repository at this point in the history
  • Loading branch information
timroes committed Apr 22, 2024
1 parent 8872cf7 commit 6a9c28c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 89 deletions.
3 changes: 0 additions & 3 deletions airbyte-webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ storybook-static/
# Generated by our build-info plugin
/public/buildInfo.json

# Generated at build time
/public/docs

# Generated file to make the CDK version available in the webapp
/src/components/connectorBuilder/cdk.ts

Expand Down
27 changes: 0 additions & 27 deletions airbyte-webapp/build.dockerfile

This file was deleted.

78 changes: 38 additions & 40 deletions airbyte-webapp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ plugins {
alias(libs.plugins.node.gradle)
}

/**
* Utility function to parse a .gitignore file into a list of ignore pattern entries
*/
fun parseIgnoreFile(f: File): List<String> {
val ignores = mutableListOf<String>()
f.forEachLine { line ->
//ignore comments and empty lines
if (!line.startsWith('#') && line.isNotEmpty()) {
ignores.add(line)
}
}
return ignores
}


// Use the node version that's defined in the .nvmrc file
val nodeVersion = file("${projectDir}/.nvmrc").readText().trim()

Expand All @@ -18,17 +33,15 @@ val parsedJson = JsonSlurper().parse(FileReader("${projectDir}/package.json")) a
val engines = parsedJson["engines"] as? Map<*, *> // Safely cast to Map if 'engines' exists
val pnpmVer = engines?.get("pnpm")?.toString()?.trim() // Extract 'pnpm' as String and trim

/*
This array should contain a path to all configs that are common to most build tasks and
might affect them (i.e. if any of those files change we want to rerun most tasks)
*/
val commonConfigs = listOf(
".env",
".env.production",
"package.json",
"pnpm-lock.yaml",
"tsconfig.json",
".prettierrc.js"
/**
* A list of all files outside the webapp folder, that the webapp build depends on, i.e.
* if those change we can't reuse a cached build.
*/
val outsideWebappDependencies = listOf(
"../airbyte-api/src/main/openapi/config.yaml",
"../airbyte-api/src/main/openapi/cloud-config.yaml",
"../airbyte-connector-builder-server/src/main/openapi/openapi.yaml",
"../airbyte-connector-builder-resources/CDK_VERSION",
)

configure<NodeExtension> {
Expand All @@ -51,45 +64,35 @@ val nodeModules = fileTree("node_modules") {
exclude(".cache")
}

/*
fileTree to watch the public dir but exclude the auto generated buildInfo.json. It's content is anyway a
content hash, depending on the other files.
*/
val publicDir = fileTree("public") {
exclude("buildInfo.json")
/**
* All files inside the webapp folder that aren't gitignored
*/
val allFiles = fileTree(".") {
exclude(parseIgnoreFile(file("../.gitignore")))
exclude(parseIgnoreFile(file(".gitignore")))
exclude(parseIgnoreFile(file("./src/core/api/generated/.gitignore")))
exclude(parseIgnoreFile(file("./src/core/api/types/.gitignore")))
}

tasks.register<PnpmTask>("pnpmBuild") {
dependsOn(tasks.named("pnpmInstall"))


environment.put("VERSION", rootProject.ext.get("version") as String)

args = listOf("build")

// The WEBAPP_BUILD_CLOUD_ENV environment variable is an input for this task, since it changes for which env we're building the webapp
inputs.property("cloudEnv", System.getenv("WEBAPP_BUILD_CLOUD_ENV") ?: "")
inputs.files(commonConfigs)
inputs.files(nodeModules)
inputs.files(publicDir)
inputs.file(".eslintrc.js")
inputs.file(".stylelintrc")
inputs.file("orval.config.ts")
inputs.file("vite.config.mts")
inputs.file("index.html")
inputs.dir("scripts")
inputs.dir("src")
inputs.files(allFiles, outsideWebappDependencies)

outputs.dir("build/app")
}

tasks.register<PnpmTask>("test") {
dependsOn(tasks.named("assemble"))

dependsOn(tasks.named("pnpmInstall"))
args = listOf("run", "test:ci")
inputs.files(commonConfigs)
inputs.file("jest.config.ts")
inputs.file("babel.config.js")
inputs.dir("src")
inputs.files(allFiles, outsideWebappDependencies)

/*
The test has no outputs, thus we always treat the outputs up to date
Expand Down Expand Up @@ -151,17 +154,12 @@ tasks.register<PnpmTask>("cloudE2eTest") {
// }
//}


tasks.register<PnpmTask>("buildStorybook") {
dependsOn(tasks.named("pnpmInstall"))

args = listOf("run", "build:storybook")

inputs.files(commonConfigs)
inputs.files(nodeModules)
inputs.files(publicDir)
inputs.dir(".storybook")
inputs.dir("src")
inputs.files(allFiles, outsideWebappDependencies)

outputs.dir("build/storybook")

Expand Down
1 change: 1 addition & 0 deletions airbyte-webapp/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const createApi = (inputSpecFile: string, name: string, apiFn?: ApiFn, excludedP
};
};

// IMPORTANT: Whenever you change/add OpenAPI specs here, make sure to also adjust the outsideWebappDependencies list in build.gradle.kts
export default defineConfig({
api: createApi("../airbyte-api/src/main/openapi/config.yaml", "AirbyteClient", "apiCall", [
// Required to exclude, due to us not being able to convert JSON parameters
Expand Down
18 changes: 0 additions & 18 deletions airbyte-webapp/release.dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion deps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,6 @@ temporal-telemetry = ["temporal-opentracing"]

[plugins]
ksp = { id ="com.google.devtools.ksp", version = "1.9.22-1.0.17"}
node-gradle = { id = "com.github.node-gradle.node", version = "7.0.1" }
node-gradle = { id = "com.github.node-gradle.node", version = "7.0.2" }
nu-studer-jooq = { id = "nu.studer.jooq", version = "9.0" }
de-undercouch-download = { id = "de.undercouch.download", version = "5.5.0" }

0 comments on commit 6a9c28c

Please sign in to comment.