-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: add format commands #31831
Changes from all commits
a4994f4
ccddd26
96643f1
efa0786
76458dc
58845d3
435f44d
55baf8f
8bfe2aa
a9b7365
27043ae
c53310a
b07da00
03a14c9
714d201
29087ea
fb43cfb
323139d
f624fa3
24297df
58b28af
a4e1efb
b1e479b
d89f7f3
6855ba3
7ca02fc
8fb3ba6
861d94b
584cfdf
d0db409
6df5f58
6449446
a331daf
e9b029f
184ca78
fc40339
c99bee3
9612d56
c93c3db
e7d4cea
7425563
5e08526
887f7ce
e815cd6
e05ad0a
285cefd
86d358b
b04fa71
116442c
9ead19c
44c5064
f929b9d
dce7dc1
8e87400
7ad4f1b
86cd43f
5d78648
4151726
488bd35
b08db8a
de086cd
fc5a391
e59f646
c21302e
80bf800
d3aa826
7bd0ab4
f625e25
d78aa46
3fb30ba
ff8cf9a
ced122b
c2fe2b9
faddea3
9ac7cc0
b11b8db
fc5e677
2074bad
f712879
d27082c
c00f03d
c9da69f
58eca7a
903b04c
bd09adf
7a6e5c3
73fb20c
ab94ab5
930b053
39ae844
d79f056
ee16e72
3276d48
7fc97aa
3126efb
ac977ca
ad30f84
7b126dd
9f4467d
435e55b
2ea4c44
aa5ced4
769b792
8774791
31514ed
60505e9
ba6ce1a
8a8c2ec
29343bc
bfc44fc
90cc182
3d57d94
ca9a668
c9c11ca
be9bb2e
afe5cea
22b19f3
5067c3d
a9cb03d
8327acd
de813e5
67de99d
b05f0b7
dff2d49
7772cf3
3f2ab69
34cb674
07b2c6d
e7b2b78
ee74dbf
f0b502d
49b44a1
720ec47
bda56e5
a6a1d37
76f83ea
0bcf0fc
c48e9c9
749ffab
139f809
84ff3b5
02ca702
89f1b2c
8385bcf
969d23f
84fd85a
9c34b9d
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 |
---|---|---|
|
@@ -103,8 +103,7 @@ jobs: | |
with: | ||
read-only: ${{ github.ref != 'refs/heads/master' }} | ||
# TODO: be able to remove the skipSlowTests property | ||
# TODO: remove the format task ASAP | ||
arguments: --scan --no-daemon --no-watch-fs format check -DskipSlowTests=true | ||
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. 👍 |
||
arguments: --scan --no-daemon --no-watch-fs check -DskipSlowTests=true | ||
|
||
# In case of self-hosted EC2 errors, remove this block. | ||
stop-check-runner: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
|
||
import time | ||
from typing import Any, Optional | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
from typing import Union | ||
|
||
import dpath.util | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,9 @@ At this point you can run `airbyte-ci` commands. | |
- [`connectors bump_version` command](#connectors-bump_version) | ||
- [`connectors upgrade_base_image` command](#connectors-upgrade_base_image) | ||
- [`connectors migrate_to_base_image` command](#connectors-migrate_to_base_image) | ||
- [`format` command subgroup](#format-subgroup) | ||
* [`format check` command](#format-check-command) | ||
* [`format fix` command](#format-fix-command) | ||
Comment on lines
+104
to
+105
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 actually a command technically, but, for readme's sake... 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. The DX is the best the way it is IMO, but conceptually, we're not actually "chaining" anything in the subcommands, we're just running multiple |
||
- [`metadata` command subgroup](#metadata-command-subgroup) | ||
- [`metadata validate` command](#metadata-validate-command) | ||
* [Example](#example) | ||
|
@@ -205,7 +208,6 @@ flowchart TD | |
entrypoint[[For each selected connector]] | ||
subgraph static ["Static code analysis"] | ||
qa[Run QA checks] | ||
fmt[Run code format checks] | ||
sem["Check version follows semantic versionning"] | ||
incr["Check version is incremented"] | ||
metadata_validation["Run metadata validation on metadata.yaml"] | ||
|
@@ -369,6 +371,29 @@ Migrate source-openweather to use the base image: `airbyte-ci connectors --name= | |
| --------------------- | ----------------------------------------------------------- | | ||
| `PULL_REQUEST_NUMBER` | The GitHub pull request number, used in the changelog entry | | ||
|
||
### <a id="format-subgroup"></a>`format` command subgroup | ||
|
||
Available commands: | ||
* `airbyte-ci format check all` | ||
* `airbyte-ci format fix all` | ||
|
||
### Examples | ||
- Check for formatting errors in the repository: `airbyte-ci format check all` | ||
- Fix formatting for only python files: `airbyte-ci format fix python` | ||
|
||
### <a id="format-check-command"></a>`format check all` command | ||
|
||
This command runs formatting checks, but does not format the code in place. It will exit 1 as soon as a failure is encountered. To fix errors, use `airbyte-ci format fix all`. | ||
|
||
Running `airbyte-ci format check` will run checks on all different types of code. Run `airbyte-ci format check --help` for subcommands to check formatting for only certain types of files. | ||
|
||
### <a id="format-fix-command"></a>`format fix all` command | ||
|
||
This command runs formatting checks and reformats any code that would be reformatted, so it's recommended to stage changes you might have before running this command. | ||
|
||
Running `airbyte-ci format fix all` will format all of the different types of code. Run `airbyte-ci format fix --help` for subcommands to format only certain types of files. | ||
|
||
|
||
### <a id="metadata-validate-command-subgroup"></a>`metadata` command subgroup | ||
|
||
Available commands: | ||
|
@@ -408,7 +433,8 @@ This command runs the Python tests for a airbyte-ci poetry package. | |
## Changelog | ||
| Version | PR | Description | | ||
| ------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | ||
| 2.5.9 | [#32427](https://github.com/airbytehq/airbyte/pull/32427) | Re-enable caching for source-postgres | | ||
| 2.6.0 | [#31831](https://github.com/airbytehq/airbyte/pull/31831) | Add `airbyte-ci format` commands, remove connector-specific formatting check | | ||
| 2.5.9 | [#32427](https://github.com/airbytehq/airbyte/pull/32427) | Re-enable caching for source-postgres | | ||
| 2.5.8 | [#32402](https://github.com/airbytehq/airbyte/pull/32402) | Set Dagger Cloud token for airbyters only | | ||
| 2.5.7 | [#31628](https://github.com/airbytehq/airbyte/pull/31628) | Add ClickPipelineContext class | | ||
| 2.5.6 | [#32139](https://github.com/airbytehq/airbyte/pull/32139) | Test coverage report on Python connector UnitTest. | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
from typing import List | ||
|
||
import dagger | ||
from pipelines.helpers.utils import sh_dash_c | ||
|
||
|
||
def run_check( | ||
container: dagger.Container, | ||
check_commands: List[str], | ||
) -> dagger.Container: | ||
"""Checks whether the repository is formatted correctly. | ||
Args: | ||
container: (dagger.Container): The container to run the formatting check in | ||
check_commands (List[str]): The list of commands to run to check the formatting | ||
""" | ||
return container.with_exec(sh_dash_c(check_commands), skip_entrypoint=True) | ||
|
||
|
||
async def run_format( | ||
container: dagger.Container, | ||
format_commands: List[str], | ||
) -> dagger.Container: | ||
"""Formats the repository. | ||
Args: | ||
container: (dagger.Container): The container to run the formatter in | ||
format_commands (List[str]): The list of commands to run to format the repository | ||
""" | ||
format_container = container.with_exec(sh_dash_c(format_commands), skip_entrypoint=True) | ||
return await format_container.directory("/src").export(".") | ||
|
||
|
||
def mount_repo_for_formatting( | ||
dagger_client: dagger.Client, | ||
container: dagger.Container, | ||
include: List[str], | ||
) -> dagger.Container: | ||
"""Mounts the relevant parts of the repository: the code to format and the formatting config | ||
Args: | ||
container: (dagger.Container): The container to mount the repository in | ||
include (List[str]): The list of files to include in the container | ||
""" | ||
container = container.with_mounted_directory( | ||
"/src", | ||
dagger_client.host().directory( | ||
".", | ||
include=include, | ||
), | ||
).with_workdir("/src") | ||
|
||
return container |
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.
If we're not comfortable with this I think we should remove the
changed-files
action call and make the airbyte-ci command run on all PRs.The format command would perform a no-op according the
modified_files
list and report a success status if only markdown files are modified.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.
Just saw this!
@alafanechere I dont think Run on all is the right approach.
If we do that means time to merge a doc only change is unessesarily longer as GHA spin up + Runner spin up + Dagger spin up + format run all add up to > 5mins
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.
Sure. But In any case a
GHA spin up + Runner spin up
is still required as thechanged-file
action will run on our self hosted runner.