-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Gradle build and fix storybook #13719
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ module.exports = { | |
"@storybook/preset-create-react-app", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ I've changed this file to be a |
||
"storybook-addon-mock/register", | ||
], | ||
staticDirs: ["../public"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ Move this from the deprecated CLI flag into the config. |
||
webpackFinal: (config) => { | ||
config.resolve.modules.push(process.cwd() + "/node_modules"); | ||
config.resolve.modules.push(process.cwd() + "/src"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ FROM ${NGINX_IMAGE} as webapp | |
EXPOSE 80 | ||
|
||
COPY bin/build /usr/share/nginx/html | ||
COPY bin/docs /usr/share/nginx/html/docs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ This is no longer needed, since the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed? |
||
COPY bin/nginx/default.conf.template /etc/nginx/templates/default.conf.template |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,78 +5,95 @@ plugins { | |
|
||
def nodeVersion = System.getenv('NODE_VERSION') ?: '16.15.1' | ||
|
||
// 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) | ||
def commonConfigs = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ Extract common configuration, that might affect all tasks to require a rerun out into a variable. |
||
'.env', | ||
'package.json', | ||
'package-lock.json', | ||
'tsconfig.json', | ||
'.prettierrc.js' | ||
] | ||
|
||
node { | ||
download = true | ||
version = nodeVersion | ||
} | ||
|
||
npm_run_build { | ||
inputs.files fileTree('public') | ||
inputs.files fileTree('src') | ||
inputs.file 'package.json' | ||
inputs.file 'package-lock.json' | ||
inputs.files commonConfigs | ||
inputs.file '.eslintrc' | ||
inputs.dir 'public' | ||
inputs.dir 'src' | ||
|
||
// todo (cgardens) - the plugin seems to ignore this value when the copy command is run. ideally the output would be place in build/app. | ||
outputs.dir project.buildDir | ||
outputs.dir 'build/app' | ||
} | ||
|
||
task test(type: NpmTask) { | ||
dependsOn assemble | ||
|
||
args = ['run', 'test', '--', '--watchAll=false', '--silent'] | ||
inputs.files fileTree('src') | ||
inputs.file 'package.json' | ||
inputs.file 'package-lock.json' | ||
inputs.files commonConfigs | ||
inputs.dir 'src' | ||
} | ||
|
||
task licenseCheck(type: NpmTask) { | ||
dependsOn npmInstall | ||
|
||
args = ['run', 'license-check'] | ||
inputs.file 'package.json' | ||
inputs.file 'package-lock.json' | ||
inputs.files commonConfigs | ||
inputs.file 'scripts/license-check.js' | ||
|
||
// The licenseCheck has no outputs, thus we always treat the outpus up to date | ||
// as long as the inputs have not changed | ||
outputs.upToDateWhen { true } | ||
} | ||
|
||
task validateLinks(type: NpmTask) { | ||
dependsOn npmInstall | ||
|
||
args = ['run', 'validate-links'] | ||
inputs.file 'package.json' | ||
inputs.file 'package-lock.json' | ||
|
||
// Since the output of this task depends on availability of URLs | ||
// we never want to treat it as "up-to-date" and always want to run it | ||
outputs.upToDateWhen { false } | ||
} | ||
|
||
// Make sure to always run a license check after we installed dependencies | ||
npmInstall.finalizedBy licenseCheck | ||
// Validate all links after installing dependencies | ||
npmInstall.finalizedBy validateLinks | ||
assemble.dependsOn npm_run_build | ||
build.finalizedBy test | ||
task buildStorybook(type: NpmTask) { | ||
dependsOn npmInstall | ||
args = ['run', 'build:storybook'] | ||
|
||
task copyBuild(type: Copy) { | ||
dependsOn copyDocker | ||
inputs.files commonConfigs | ||
inputs.dir '.storybook' | ||
inputs.dir 'public' | ||
inputs.dir 'src' | ||
|
||
from "${project.projectDir}/build" | ||
into "build/docker/bin/build" | ||
exclude ".docker" | ||
exclude "docker" | ||
outputs.dir 'build/storybook' | ||
} | ||
|
||
task copyBuildOutput(type: Copy) { | ||
dependsOn copyDocker, npm_run_build | ||
|
||
from "${project.projectDir}/build/app" | ||
into 'build/docker/bin/build' | ||
} | ||
|
||
task copyDocs(type: Copy) { | ||
dependsOn copyDocker | ||
dependsOn copyDocker, copyBuildOutput | ||
|
||
from "${project.rootProject.projectDir}/docs/integrations" | ||
into "build/docker/bin/docs/integrations" | ||
//google-ads.md is blocked by Ad Blockers | ||
into "build/docker/bin/build/docs/integrations" | ||
// google-ads.md is blocked by Ad Blockers | ||
rename ('google-ads.md', 'gglad.md') | ||
duplicatesStrategy DuplicatesStrategy.INCLUDE | ||
} | ||
|
||
// Copy images that are used in .md integration documentation docs | ||
task copyAssets(type: Copy) { | ||
dependsOn copyDocker | ||
task copyDocAssets(type: Copy) { | ||
dependsOn copyDocker, copyBuildOutput | ||
|
||
from "${project.rootProject.projectDir}/docs/.gitbook" | ||
into "build/docker/bin/docs/.gitbook" | ||
into "build/docker/bin/build/docs/.gitbook" | ||
duplicatesStrategy DuplicatesStrategy.INCLUDE | ||
} | ||
|
||
|
@@ -87,16 +104,15 @@ task copyNginx(type: Copy) { | |
into "build/docker/bin/nginx" | ||
} | ||
|
||
copyBuild.dependsOn npm_run_build | ||
copyNginx.dependsOn npm_run_build | ||
copyDocs.dependsOn npm_run_build | ||
copyAssets.dependsOn npm_run_build | ||
assemble.dependsOn copyDocs | ||
copyDocker.dependsOn(npm_run_build) | ||
// Those tasks should be run as part of the "check" task | ||
check.dependsOn validateLinks, licenseCheck, test | ||
|
||
build.dependsOn buildStorybook | ||
|
||
Task dockerBuildTask = getDockerBuildTask("webapp", "$project.projectDir", "$rootProject.ext.version", "$rootProject.ext.image_tag") | ||
dockerBuildTask.dependsOn(copyBuild) | ||
dockerBuildTask.dependsOn(copyDocker) | ||
dockerBuildTask.dependsOn(copyBuildOutput) | ||
dockerBuildTask.dependsOn(copyNginx) | ||
dockerBuildTask.dependsOn(copyDocs) | ||
dockerBuildTask.dependsOn(copyAssets) | ||
dockerBuildTask.dependsOn(copyDocAssets) | ||
assemble.dependsOn(dockerBuildTask) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,12 @@ | |
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"build": "BUILD_PATH='./build/app' react-scripts build", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ Move the actual react build output to |
||
"test": "react-scripts test", | ||
"test:coverage": "npm test -- --coverage --watchAll=false", | ||
"format": "prettier --write 'src/**/*.{ts,tsx}'", | ||
"storybook": "start-storybook -p 9009 -s public --quiet", | ||
"storybook": "start-storybook -p 9009 --quiet", | ||
"build:storybook": "build-storybook -o 'build/storybook'", | ||
"lint": "eslint --ext js,ts,tsx src", | ||
"license-check": "node ./scripts/license-check.js", | ||
"generate-client": "orval", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ Updated this to the most recent version, as we already did for the
airbyte-webapp
project.