-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
airbyte-ci: format improvements #32999
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ef3cd80
airbyte-ci: format improvements
postamar ac84db3
fix spotless config in maven
postamar a5da8b3
consistent repo mount path
alafanechere 625fd9a
bump version
alafanechere 597d9c8
Update airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/format/co…
postamar 6994895
Update build.gradle
postamar b3afd1b
add commentary
postamar 9474b03
more commentary
postamar f0cd3dc
add groovy gradle support
postamar c9b6792
add clean goal
postamar 22e1bbd
remove spotless from gradle build
postamar 942c3c0
disable gradle formatting config
postamar 59c931c
Update spotless-maven-pom.xml
postamar 4beab78
Revert "remove spotless from gradle build"
postamar 0d7cd91
Merge branch 'master' into postamar/use-maven-in-airbyte-ci-format
postamar e9e675c
Automated Commit - Formatting Changes
postamar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,15 @@ | |
|
||
import dagger | ||
from pipelines.airbyte_ci.format.consts import DEFAULT_FORMAT_IGNORE_LIST | ||
from pipelines.consts import AMAZONCORRETTO_IMAGE, GO_IMAGE, NODE_IMAGE, PYTHON_3_10_IMAGE | ||
from pipelines.consts import GO_IMAGE, MAVEN_IMAGE, NODE_IMAGE, PYTHON_3_10_IMAGE | ||
from pipelines.helpers.utils import sh_dash_c | ||
|
||
|
||
def build_container( | ||
dagger_client: dagger.Client, | ||
base_image: str, | ||
include: List[str], | ||
warmup_include: Optional[List[str]] = None, | ||
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
install_commands: Optional[List[str]] = None, | ||
env_vars: Optional[Dict[str, Any]] = {}, | ||
) -> dagger.Container: | ||
|
@@ -22,6 +23,7 @@ def build_container( | |
ctx (ClickPipelineContext): The context of the pipeline | ||
base_image (str): The base image to use for the container | ||
include (List[str]): The list of files to include in the container | ||
warmup_include (Optional[List[str]]): The list of files to include in the container before installing dependencies | ||
install_commands (Optional[List[str]]): The list of commands to run to install dependencies for the formatter | ||
env_vars (Optional[Dict[str, Any]]): The list of environment variables to set on the container | ||
Returns: | ||
|
@@ -34,6 +36,22 @@ def build_container( | |
for key, value in env_vars.items(): | ||
container = container.with_env_variable(key, value) | ||
|
||
# Set the working directory to the code to format | ||
container = container.with_workdir("/src") | ||
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Mount a subset of the relevant parts of the repository, if requested. | ||
# These should only be files which do not change very often. | ||
# These can then be referenced by the install_commands. | ||
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if warmup_include: | ||
container = container.with_mounted_directory( | ||
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"/src", | ||
dagger_client.host().directory( | ||
".", | ||
include=warmup_include, | ||
exclude=DEFAULT_FORMAT_IGNORE_LIST, | ||
), | ||
) | ||
|
||
# Install any dependencies of the formatter | ||
if install_commands: | ||
container = container.with_exec(sh_dash_c(install_commands), skip_entrypoint=True) | ||
|
@@ -44,39 +62,36 @@ def build_container( | |
"/src", | ||
dagger_client.host().directory( | ||
".", | ||
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
include=include, | ||
include=include + (warmup_include if warmup_include else []), | ||
exclude=DEFAULT_FORMAT_IGNORE_LIST, | ||
), | ||
) | ||
|
||
# Set the working directory to the code to format | ||
container = container.with_workdir("/src") | ||
|
||
return container | ||
|
||
|
||
def format_java_container(dagger_client: dagger.Client) -> dagger.Container: | ||
"""Format java, groovy, and sql code via spotless.""" | ||
"""Format java code via spotless in maven.""" | ||
return build_container( | ||
dagger_client, | ||
base_image=AMAZONCORRETTO_IMAGE, | ||
include=[ | ||
"**/*.java", | ||
"**/*.gradle", | ||
"gradlew", | ||
"gradlew.bat", | ||
"gradle", | ||
"**/deps.toml", | ||
"**/gradle.properties", | ||
"**/version.properties", | ||
base_image=MAVEN_IMAGE, | ||
warmup_include=[ | ||
"spotless-maven-pom.xml", | ||
"tools/gradle/codestyle/java-google-style.xml", | ||
], | ||
install_commands=[ | ||
"yum update -y", | ||
"yum install -y findutils", # gradle requires xargs, which is shipped in findutils. | ||
"yum clean all", | ||
# Run maven before mounting the sources to download all its dependencies. | ||
# Dagger will cache the resulting layer to minimize the downloads. | ||
# The go-offline goal purportedly downloads all dependencies. | ||
# This isn't quite the case, we still need to add spotless goals. | ||
"mvn -f spotless-maven-pom.xml" | ||
" org.apache.maven.plugins:maven-dependency-plugin:3.6.1:go-offline" | ||
" spotless:apply" | ||
" spotless:check", | ||
], | ||
include=[ | ||
"**/*.java", | ||
], | ||
env_vars={"RUN_IN_AIRBYTE_CI": "1"}, | ||
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
|
||
|
@@ -101,11 +116,16 @@ def format_license_container(dagger_client: dagger.Client, license_file: str) -> | |
|
||
def format_python_container(dagger_client: dagger.Client) -> dagger.Container: | ||
"""Format python code via black and isort.""" | ||
|
||
return build_container( | ||
dagger_client, | ||
base_image=PYTHON_3_10_IMAGE, | ||
env_vars={"PIPX_BIN_DIR": "/usr/local/bin"}, | ||
include=["**/*.py", "pyproject.toml", "poetry.lock"], | ||
install_commands=["pip install pipx", "pipx ensurepath", "pipx install poetry"], | ||
warmup_include=["pyproject.toml", "poetry.lock"], | ||
install_commands=[ | ||
"pip install pipx", | ||
"pipx ensurepath", | ||
"pipx install poetry", | ||
"poetry install --no-root", | ||
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 should speed up the python formatting by caching the |
||
], | ||
include=["**/*.py"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.airbyte</groupId> | ||
<artifactId>airbyte-spotless-format-dummy-maven-project</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>airbyte-spotless-format-dummy-maven-project</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>17</java.version> | ||
</properties> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.diffplug.spotless</groupId> | ||
<artifactId>spotless-maven-plugin</artifactId> | ||
<version>2.41.0</version> | ||
<configuration> | ||
<java> | ||
<includes> | ||
<include>**/*.java</include> | ||
</includes> | ||
<importOrder /> | ||
<eclipse> | ||
<version>4.21</version> | ||
<file>tools/gradle/codestyle/java-google-style.xml</file> | ||
</eclipse> | ||
<removeUnusedImports /> | ||
<trimTrailingWhitespace /> | ||
</java> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> | ||
postamar marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was not called anywhere.