Skip to content
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

🚀 Launch Java CDK v0.1.0 #30383

Merged
merged 120 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
ffeae03
gradle: improve airbyte-docker performance
Sep 11, 2023
54ebe61
gradle: don't blanket-create 'generate'
Sep 11, 2023
43bf3ac
gradle: airbyte-docker infers dependencies
Sep 11, 2023
bf2c399
gradle: remove all airbyteDocker.outputs dependencies
Sep 11, 2023
01e1f2b
airbyte-ci: remove gradle file patching hacks
Sep 11, 2023
6842402
airbyte-ci: bump version and update changelog
Sep 11, 2023
d7ef40b
import migration script from prior branch `java-cdk-010-c`
aaronsteers Sep 11, 2023
75d7c34
commit java-cdk build.gradle from other branch
aaronsteers Sep 11, 2023
ae9ec3a
commit java cdk plugin (wip) from other branch
aaronsteers Sep 11, 2023
6838180
docs: document manual steps
aaronsteers Sep 11, 2023
be8e02a
import settings.gradle from other branch (manual conflict resolution)
aaronsteers Sep 11, 2023
eed850e
chore: add cdk gradle plugin to connectors (cherry-picked, typo manua…
aaronsteers Sep 11, 2023
ceedc27
chore: cleanup stale gradle refs in connectors (cherry-picked, confli…
aaronsteers Aug 23, 2023
1424b5f
chore: additional build.gradle fixes (cherry-picked, manual conflict …
aaronsteers Aug 23, 2023
1b93f25
chore: newer cherry-pick refs for next time
aaronsteers Sep 11, 2023
5a791a7
update migration script to exclude `base-normalization`
aaronsteers Sep 11, 2023
3833b5c
fix: merge incorrectly duplicated build.gradle in java-cdk
aaronsteers Sep 11, 2023
8fcd761
improved remnant handling in migration script
aaronsteers Sep 12, 2023
c5308bd
minor updates on migration script
aaronsteers Sep 12, 2023
bed3154
wip: migrating shell script to python
aaronsteers Sep 12, 2023
b43cf1c
migration script: file moves and package declaration regex working
aaronsteers Sep 12, 2023
91a97e8
working: python migration script (regex still todo)
aaronsteers Sep 12, 2023
6cc4893
fix: path to db_models.yml
aaronsteers Sep 12, 2023
e663021
fix migration script bug re: relative dirs
aaronsteers Sep 12, 2023
98c0147
🎉 success: test (cdk assemble) passing
aaronsteers Sep 12, 2023
941ff67
fix missing standardtest package in regex
aaronsteers Sep 12, 2023
6b40e5f
fix lombok processing for test fixtures
aaronsteers Sep 12, 2023
dae177f
🎉 cdk tests running (11 failed)
aaronsteers Sep 13, 2023
03da4b3
add missing lang2 library for tests
aaronsteers Sep 13, 2023
10a85b0
working compile for source-postgres (with workaround for Dockerfile)
aaronsteers Sep 13, 2023
108ba73
migration script: classify projects into feature-based submodules
aaronsteers Sep 13, 2023
2300174
organize build.gradle dependencies
aaronsteers Sep 13, 2023
89e4f66
chore: update script to only run passing test
aaronsteers Sep 13, 2023
56c3928
refactor: cdk core and feature modules
aaronsteers Sep 13, 2023
f792eba
Merge 'origin/master' into java-cdk-010-d (manual conflict resolution)
aaronsteers Sep 13, 2023
fbda6bb
add perftest handling
aaronsteers Sep 13, 2023
317d54b
re-remove stale refs
aaronsteers Sep 13, 2023
c601475
multiple connectors building successfully
aaronsteers Sep 13, 2023
1bea570
cdk version bump to 0.1.0
aaronsteers Sep 13, 2023
2dabe45
bigquery and gcs destination tests passing
aaronsteers Sep 13, 2023
58b77a0
drop old shell script
aaronsteers Sep 13, 2023
6150550
chore: add back publishSnapshotIfNeeded for gradle cdk
aaronsteers Sep 14, 2023
6da2084
Merge branch 'master' into java-cdk-010-d
aaronsteers Sep 15, 2023
c048edd
add generic java devcontainer config
aaronsteers Sep 15, 2023
edce8f1
remove db-lib from inclusion (jooq is fragile)
aaronsteers Sep 15, 2023
91dffa2
declare db-lib as published part of api
aaronsteers Sep 15, 2023
afea84e
chore: force stable jooq version (fixes postgres tests)
aaronsteers Sep 19, 2023
e2b58bf
re-add db-lib, cleanup gradle plugin, cleanup postgres build.gradle
aaronsteers Sep 19, 2023
b06694c
merge 'origin/master' into java-cdk-010-d (manual conflict resolution)
aaronsteers Sep 19, 2023
20f5e7c
update testcontainer refs
aaronsteers Sep 19, 2023
0d6351d
more cleanup on build.gradle files
aaronsteers Sep 19, 2023
7b19c8c
working: multi-module cdk 'publish' and 'publishToLocalMaven'
aaronsteers Sep 21, 2023
6836340
merge from master (manual conflict resolution)
aaronsteers Sep 22, 2023
2919b8f
modify script to exclude typing-deduping projects
aaronsteers Sep 22, 2023
90bdac0
add shell script to recreate derived branch
aaronsteers Sep 22, 2023
2e797bc
add back typing-deduping to root settings.gradle includes
aaronsteers Sep 22, 2023
efbc87c
remove ref to AirbyteConnectorAcceptanceTestPlugin
aaronsteers Sep 22, 2023
6da0b91
cleanup destination-bigquery dependencies
aaronsteers Sep 22, 2023
614d487
update java-connector plugin refs
aaronsteers Sep 22, 2023
027dad1
remember to exclude typing_deduping in regex replace
aaronsteers Sep 22, 2023
5b70c8f
Merge remote-tracking branch 'origin/master' into java-cdk-010-d # Pl…
aaronsteers Sep 22, 2023
d714279
fix typing-deduping builds
aaronsteers Sep 22, 2023
08d2ca2
don't automatically merge from master in script
aaronsteers Sep 22, 2023
1ceae42
move destination-snowflake to cdk
aaronsteers Sep 22, 2023
a78abfd
workaround for circular ref b/w cdk and typing_deduping
aaronsteers Sep 22, 2023
8376e7f
update expected version in cdk version check unit tests
aaronsteers Sep 22, 2023
65ca037
bring back base and java-base project in settings.gradle
aaronsteers Sep 22, 2023
606b6b0
update migration script to restore base-java dockerfile definition
aaronsteers Sep 22, 2023
f1a5e9c
update cdk version test comparison
aaronsteers Sep 23, 2023
59b7676
add back missing ssh package 'net.i2p.crypto:eddsa'
aaronsteers Sep 23, 2023
c779bea
merge in missing dependencies from base-java
aaronsteers Sep 23, 2023
0ceaccf
add base-java-s3 dependencies
aaronsteers Sep 24, 2023
114cf02
merge other projects into db-sources feature
aaronsteers Sep 24, 2023
c9d1ad0
note commits that will need to be cherry-picked
aaronsteers Sep 24, 2023
3e8a1bd
setup branch tracking during force push
aaronsteers Sep 24, 2023
7bb29ad
fast-fail for tests in migration script
aaronsteers Sep 24, 2023
9631741
update tests
aaronsteers Sep 24, 2023
69adaaf
docs: update cdk readme
aaronsteers Sep 25, 2023
04346a8
docs: minor readability improvement
aaronsteers Sep 25, 2023
46c2758
rename: useCdkProjectRef->useLocalCdk
aaronsteers Sep 25, 2023
a9e9186
delete devcontainer config
aaronsteers Sep 25, 2023
8c4e21c
docs: cleanup readme
aaronsteers Sep 25, 2023
b8d1371
add note about migration scripts being deleted in future
aaronsteers Sep 25, 2023
6720689
delete stale migration script comments re: action items
aaronsteers Sep 25, 2023
ea89999
delete commented-out build.gradle 'scraps' from other projects
aaronsteers Sep 25, 2023
72686a1
docs: revert auto-format change on toc
aaronsteers Sep 25, 2023
5080c5b
merge 'origin/master' into java-cdk-010-d
aaronsteers Sep 25, 2023
e1ee8fe
chore: add `airbyteJavaConnector` config to all Java connectors
aaronsteers Sep 25, 2023
c03f599
fix: use new cdk version path
aaronsteers Sep 25, 2023
e3e54b3
qol: automated check and disable for useLocalCdk setting
aaronsteers Sep 25, 2023
f7bc705
refactor: move `assertCdkVersionNotPublished` to gradle
aaronsteers Sep 25, 2023
90c7825
declare recursive tasks dependencies lazily
aaronsteers Sep 25, 2023
d4eea8d
fix: typo in comma
aaronsteers Sep 25, 2023
151150d
remove cdk ref from destination-harness
aaronsteers Sep 25, 2023
1945a5b
add devcontainer config
aaronsteers Sep 26, 2023
bad533c
fix: undeclared dependency between 'airbyte-json-validation` and `air…
aaronsteers Sep 26, 2023
7dfdc97
dev container: add python support for airbyte-ci
aaronsteers Sep 26, 2023
d8cfbff
add cdk project parsing in airbyte-ci
aaronsteers Sep 26, 2023
330841f
temporary workaround: fix version lookup in slash command
aaronsteers Sep 25, 2023
a02dead
Merge remote-tracking branch 'origin/master' into java-cdk-010-d
aaronsteers Sep 26, 2023
4c80ee6
Merge in 'Full Fileset' PR (#30445) to the primary Java CDK 0.1.0 PR
aaronsteers Sep 26, 2023
6014bf3
Merge remote-tracking branch 'origin/master' into java-cdk-010-d
aaronsteers Sep 26, 2023
a4cca1b
Automated Commit - Formatting Changes
aaronsteers Sep 26, 2023
e4d7ca3
fix: recursive task invocation
aaronsteers Sep 26, 2023
ec49de8
cleanup publish paths, add 'io.airbyte.cdk' groupId
aaronsteers Sep 27, 2023
e9aa719
toggle all java connectors to `useLocalCdk = false`
aaronsteers Sep 27, 2023
3cede47
java build improvements...
aaronsteers Sep 27, 2023
8fe5149
fix: properly parse cdk dependencies in airbyte-ci
aaronsteers Sep 27, 2023
e32f64d
Merge remote-tracking branch 'origin/master' into java-cdk-010-d
aaronsteers Sep 27, 2023
5b65e5e
toggle source-postgres to pinned cdk ref
aaronsteers Sep 27, 2023
975d910
rename io.airbyte.cdk.test.utils to io.airbyte.cdk.testutils
aaronsteers Sep 27, 2023
a306e5f
streamline cdk cache cleanup with 'clean'
aaronsteers Sep 27, 2023
04d0bac
fix: misc missing dependencies
aaronsteers Sep 27, 2023
07cce05
fix: s3 imports moved to cdk
aaronsteers Sep 27, 2023
88bf87f
fix: s3 storage provider ref
aaronsteers Sep 27, 2023
7bd7983
Merge remote-tracking branch 'origin/master' into java-cdk-010-d
aaronsteers Sep 27, 2023
a5c0c25
Automated Commit - Formatting Changes
aaronsteers Sep 27, 2023
16397e0
fix: more missing dependencies
aaronsteers Sep 27, 2023
8751e1e
Merge branch 'java-cdk-010-d' of https://github.com/airbytehq/airbyte…
aaronsteers Sep 27, 2023
5042bb6
update cdk changlog date
aaronsteers Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 90 additions & 40 deletions airbyte-cdk/java/airbyte-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,114 @@

This page will walk through the process of developing with the Java CDK.

## Building the CDK
- [Developing with the Java CDK](#developing-with-the-java-cdk)
- [Intro to the Java CDK](#intro-to-the-java-cdk)
- [What is included in the Java CDK?](#what-is-included-in-the-java-cdk)
- [How is the CDK published?](#how-is-the-cdk-published)
- [Using the Java CDK](#using-the-java-cdk)
- [Building the CDK](#building-the-cdk)
- [Bumping the CDK version](#bumping-the-cdk-version)
- [Publishing the CDK](#publishing-the-cdk)
- [Developing Connectors with the Java CDK](#developing-connectors-with-the-java-cdk)
- [Referencing the CDK from Java connectors](#referencing-the-cdk-from-java-connectors)
- [Developing a connector alongside the CDK](#developing-a-connector-alongside-the-cdk)
- [Developing a connector against a pinned CDK version](#developing-a-connector-against-a-pinned-cdk-version)
- [Common Debugging Tips](#common-debugging-tips)
- [Changelog](#changelog)
- [Java CDK](#java-cdk)

## Intro to the Java CDK

### What is included in the Java CDK?

The java CDK is comprised of separate modules:

- `core` - Shared classes for building connectors of all types.
- `db-sources-feature` - Shared classes for building DB sources.
- `db-destinations-feature` - Shared classes for building DB destinations.

Each CDK submodule may contain these elements:

- `src/main` - (Required.) The classes that will ship with the connector, providing capabilities to the connectors.
- `src/test` - (Required.) These are unit tests that run as part of every build of the CDK. They help ensure that CDK `main` code is in a healthy state.
- `src/test-integration` - (Optional.) Integration tests which provide a more extensive test of the code in `src/main`. These are not by the `build` command but are executed as part of the `integrationTest` or `integrationTestJava` Gradle tasks.
- `src/testFixtures` - (Optional.) These shared classes are exported for connectors for use in the connectors' own test implementations. Connectors will have access to these classes within their unit and integration tests, but the classes will not be shipped with connectors when they are published.

### How is the CDK published?

The CDK is published as a set of jar files sharing a version number. Every submodule generates one runtime jar for the main classes. If the submodule contains test fixtures, a second jar will be published with the test fixtures classes.

Note: Connectors do not have to manage which jars they should depend on, as this is handled automatically by the `airbyte-java-connector` plugin. See example below.

## Using the Java CDK

### Building the CDK

To build and test the Java CDK, execute the following:

```sh
./gradlew :airbyte-cdk:java:airbyte-cdk:build
```

## Bumping the declared CDK version
### Bumping the CDK version

You will need to bump this version manually whenever you are making changes to code inside the CDK.

While under development, the next version number for the CDK is tracked in the file: `airbyte-cdk/java/airbyte-cdk/src/main/resources/version.properties`.
While under development, the next version number for the CDK is tracked in the file: `airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties`.

If the CDK is not being modified, this file will contain the most recently published version number.

## Publishing the CDK to Local Maven
### Publishing the CDK

_⚠️ These steps should only be performed after all testing and approvals are in place on the PR. ⚠️_

The CDK can be published with a GitHub Workflow and a slash command which can be run by Airbyte personnel.

To invoke via slash command (recommended), use the following syntax in a comment on the PR that contains your changes:

```bash
/publish-java-cdk # Run with the defaults (dry-run=false, force=false)
/publish-java-cdk dry-run=true # Run in dry-run mode (no-op)
/publish-java-cdk force=true # Force-publish if needing to replace an already published version
```

Note:

If your connector pins to a work-in-progress `-SNAPSHOT` version of the CDK (e.g. `0.0.1-SNAPSHOT` or `0.2.0-SNAPSHOT`), Gradle will notice this and automatically run the task to build and publish it to your MavenLocal repository before running the connector's own build and test tasks.
- Remember to **document your changes** in the Changelog section below.
- After you publish the CDK, remember to toggle `useLocalCdk` back to `false` in all connectors.
- Unless you specify `force=true`, the pipeline should fail if the version you are trying to publish already exists.
- By running the publish with `dry-run=true`, you can confirm the process is working as expected, without actually publishing the changes.
- In dry-run mode, you can also view and download the jars that are generated. To do so, navigate to the job status in GitHub Actions and navigate to the 'artifacts' section.
- You can also invoke manually in the GitHub Web UI. To do so: go to `Actions` tab, select the `Publish Java CDK` workflow, and click `Run workflow`.
- You can view and administer published CDK versions here: https://admin.cloudrepo.io/repository/airbyte-public-jars/io/airbyte/airbyte-cdk
- The public endpoint for published CDK versions is here: https://airbyte.mycloudrepo.io/public/repositories/airbyte-public-jars/io/airbyte/airbyte-cdk/

## Referencing the CDK from Java connectors
## Developing Connectors with the Java CDK

### Referencing the CDK from Java connectors

You can reference the CDK in your connector's `build.gradle` file:

```groovy
dependencies {
implementation 'io.airbyte:airbyte-cdk:0.0.1-SNAPSHOT'
plugins {
id 'application'
id 'airbyte-docker'
id 'airbyte-java-connector'
}

airbyteJavaConnector {
cdkVersionRequired = '0.1.0' // The CDK version to pin to.
features = ['db-destinations'] // An array of CDK features to depend on.
useLocalCdk = false // Use 'true' to use a live reference to the
// local cdk project.
}

airbyteJavaConnector.addCdkDependencies()
```

Replace `0.0.1-SNAPSHOT` with the version you are working with. If you're actively developing the CDK and want to use the latest version locally, use the `-SNAPSHOT` suffix to reference a bumped version number. (See below for version bump instructions.)
Replace `0.1.0` with the CDK version you are working with. If you're actively developing the CDK and want to use the latest version locally, use the `useLocalCdk` flag to use the live CDK code during builds and tests.

## Developing a connector alongside the CDK
### Developing a connector alongside the CDK

You can iterate on changes in the CDK local and test them in the connector without needing to publish the CDK changes publicly.

Expand All @@ -45,48 +120,22 @@ When modifying the CDK and a connector in the same PR or branch, please use the
1. Build and test your connector as usual. Gradle will automatically build the snapshot version of the CDK, and it will use this version when building and testing your connector.
1. As you make additional changes to the CDK, Gradle will automatically rebuild and republish the CDK locally in order to incorporate the latest changes.

## Developing a connector against a pinned CDK version
### Developing a connector against a pinned CDK version

You can always pin your connector to a prior stable version of the CDK, which may not match what is the latest version in the `airbyte` repo. For instance, your connector can be pinned to `0.1.1` while the latest version may be `0.2.0`.

Maven and Gradle will automatically reference the correct (pinned) version of the CDK for your connector, and you can use your local IDE to browse the prior version of the codebase that corresponds to that version.

<!--
TODO: More detailed instructions needed.

Add screenshots and additional details for IntelliJ IDEA and/or VS Code.
-->

## Publish and release

_⚠️ These steps should only be performed after all testing and approvals are in place on the PR. ⚠️_

1. Remove `-SNAPSHOT` suffix from CDK version.
- e.g. by running `nano airbyte-cdk/java/airbyte-cdk/src/main/resources/
version.properties`.
2. Publish the CDK to Maven ([mycloudrepo](https://airbyte.mycloudrepo.io/public/repositories/airbyte-public-jars/io/airbyte/airbyte-cdk/))
- `./gradlew :airbyte-cdk:java:airbyte-cdk:publish`
- Note: you will need to export the env vars `CLOUDREPO_USER` and `CLOUDREPO_PASSWORD` before publishing.
3. Remove the `-SNAPSHOT` suffix from any connector(s) using the latest version.
- E.g. If modifying `source-mysql`, then remove `-SNAPSHOT` from the CDK `implements` declaration in `airbyte-integrations/connectors/source-mysql/build.gradle`.
4. As per the normal process, modified connector(s) will be automatically published after they are merged to the main branch.

Note:

- This is documented as a manual process, but we will automate it into a CI workflow.
- You can view and administer published CDK versions here: https://admin.cloudrepo.io/repository/airbyte-public-jars/io/airbyte/airbyte-cdk
- The corresponding public endpoint for published CDK versions is here: https://airbyte.mycloudrepo.io/public/repositories/airbyte-public-jars/io/airbyte/airbyte-cdk/

## Debugging
## Common Debugging Tips

MavenLocal debugging steps:

1. Confirm local publish status by running:
`ls -la ~/.m2/repository/io/airbyte/airbyte-cdk\*`
`ls -la ~/.m2/repository/io/airbyte/airbyte-cdk/*`
2. Confirm jar contents by running:
`jar tf ~/.m2/repository/io/airbyte/airbyte-cdk/0.0.2-SNAPSHOT/airbyte-cdk-0.0.2-SNAPSHOT.jar`
3. Remove CDK artifacts from MavenLocal by running:
`rm -rf ~/.m2/repository/io/airbyte/airbyte-cdk\*`
`rm -rf ~/.m2/repository/io/airbyte/airbyte-cdk/*`
4. Rebuid CDK artifacts by running:
`./gradlew :airbyte-cdk:java:airbyte-cdk:build`
or
Expand All @@ -98,5 +147,6 @@ MavenLocal debugging steps:

| Version | Date | Pull Request | Subject |
| :------ | :--------- | :--------------------------------------------------------- | :------------------------------------ |
| 0.1.0 | 2023-08-21 | [\#30445](https://github.com/airbytehq/airbyte/pull/30445) | First launch, including shared classes for all connectors. |
| 0.0.2 | 2023-08-21 | [\#28687](https://github.com/airbytehq/airbyte/pull/28687) | Version bump only (no other changes). |
| 0.0.1 | 2023-08-08 | [\#28687](https://github.com/airbytehq/airbyte/pull/28687) | Initial release for testing. |
25 changes: 25 additions & 0 deletions airbyte-cdk/java/airbyte-cdk/_rebuild_full_fileset_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# This script is used to rebuild the java-cdk-010-d2 branch from scratch.
# TODO: Delete this script once the migration is complete.

# Check with the use to confirm the action
read -p "This script will delete and recreate the java-cdk-010-d2 branch. You should merge in the latest from from master before running this. Are you sure? (y/n) " -n 1 -r

# Switch to the base branch
git checkout java-cdk-010-d
# Make sure the base branch is up-to-date
# git merge origin/master
# Delete and recreate the old branch locally
git branch -D java-cdk-010-d2
git checkout -b java-cdk-010-d2
# Run the migration script
python ./airbyte-cdk/java/airbyte-cdk/_temp_migration_script.py
# Stage the changes and commit
git add .
git commit -m "commit the migration script result"
# Force push to the origin (this PR)
git push -uf origin java-cdk-010-d2

# git cherry-pick c125f14cdce8be61da85ebedffd3c4a576dc1fc5 # delete dead code (incorrectly annotated as override)
# git cherry-pick 89d81ec62fcfa44fff36196e2d34571b46593818 # disable GlobalStateManagerTest.testToState
Loading