-
Notifications
You must be signed in to change notification settings - Fork 6
Add examples for local testing and CI/CD lifecycle management #36
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
Open
Martijn Visser (MartijnVisser)
wants to merge
1
commit into
master
Choose a base branch
from
table-api-cuj-examples
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+770
−181
Open
Changes from all commits
Commits
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 hidden or 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,65 @@ | ||
| # EXAMPLE WORKFLOW - copy this file to .github/workflows/ in your own repository. | ||
| # It lives in workflows-examples/ because this examples repository does not deploy to a | ||
| # real Confluent Cloud environment. It tests, deploys Example_08_IntegrationAndDeployment, | ||
| # then lists the result. See the README's CI/CD section for the deployment model and the | ||
| # required secrets. | ||
| name: Deploy Table API Program | ||
|
|
||
| on: | ||
| # Choose the trigger(s) that fit your deployment strategy. This template can be run | ||
| # manually from the GitHub Actions UI; uncomment the others to deploy automatically, | ||
| # for example on a merge to your main branch or on a release tag. | ||
| workflow_dispatch: | ||
| # push: | ||
| # branches: [main] | ||
| # push: | ||
| # tags: ['v*'] | ||
|
|
||
| env: | ||
| CLOUD_PROVIDER: ${{ secrets.CLOUD_PROVIDER }} | ||
| CLOUD_REGION: ${{ secrets.CLOUD_REGION }} | ||
| FLINK_API_KEY: ${{ secrets.FLINK_API_KEY }} | ||
| FLINK_API_SECRET: ${{ secrets.FLINK_API_SECRET }} | ||
| ORG_ID: ${{ secrets.ORG_ID }} | ||
| ENV_ID: ${{ secrets.ENV_ID }} | ||
| COMPUTE_POOL_ID: ${{ secrets.COMPUTE_POOL_ID }} | ||
| TARGET_CATALOG: ${{ secrets.TARGET_CATALOG }} | ||
| TARGET_DATABASE: ${{ secrets.TARGET_DATABASE }} | ||
| # Fixed here because they define what this pipeline deploys (and a push trigger cannot | ||
| # supply inputs); the manage workflow takes them as inputs instead. | ||
| APPLICATION_NAME: marketplace-analytics | ||
| STATEMENT_NAME: vendors-per-brand | ||
|
|
||
| jobs: | ||
| test-and-deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '17' | ||
| cache: maven | ||
|
|
||
| - name: Run local unit tests and integration tests against Confluent Cloud | ||
| run: ./mvnw -B --no-transfer-progress verify | ||
|
|
||
| - name: Deploy to Confluent Cloud | ||
| # --on-conflict replace redeploys a changed pipeline under the same name; it | ||
| # requires --application-name. "Replace" deletes and recreates the statement, so a | ||
| # stateful pipeline restarts from its configured source offsets without resuming | ||
| # prior state (see the README CI/CD section). | ||
| run: > | ||
| java -jar target/flink-table-api-java-examples-1.0.jar | ||
| --statement-name "$STATEMENT_NAME" | ||
| --application-name "$APPLICATION_NAME" | ||
| --on-conflict replace | ||
|
|
||
| - name: Verify the deployed statement | ||
| # Submitting a background statement returns once Confluent Cloud accepts it, so | ||
| # list reports the statement and its phase for visibility in the log. | ||
| run: > | ||
| java -jar target/flink-table-api-java-examples-1.0.jar | ||
| list | ||
| --application-name "$APPLICATION_NAME" | ||
This file contains hidden or 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,71 @@ | ||
| # EXAMPLE WORKFLOW - copy this file to .github/workflows/ in your own repository. | ||
| # It lives in workflows-examples/ because this examples repository does not manage | ||
| # statements in a real Confluent Cloud environment. It runs the deployment JAR with one | ||
| # of the plugin's built-in lifecycle actions (list/describe/resume/stop/delete) chosen by | ||
| # the operator. See the README's CI/CD section for the deployment model and the required | ||
| # secrets. The action defaults below match what deploy.yml uses; override them per run. | ||
| name: Manage Flink Statements | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| action: | ||
| description: 'Action to perform' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - list | ||
| - describe | ||
| - resume | ||
| - stop | ||
| - delete | ||
| application-name: | ||
| description: 'Application the statement belongs to (set at deploy time)' | ||
| required: true | ||
| default: marketplace-analytics | ||
| statement-name: | ||
| description: 'Statement name set at deploy time (leave empty for list to show all)' | ||
| required: false | ||
| default: vendors-per-brand | ||
|
|
||
| env: | ||
| CLOUD_PROVIDER: ${{ secrets.CLOUD_PROVIDER }} | ||
| CLOUD_REGION: ${{ secrets.CLOUD_REGION }} | ||
| FLINK_API_KEY: ${{ secrets.FLINK_API_KEY }} | ||
| FLINK_API_SECRET: ${{ secrets.FLINK_API_SECRET }} | ||
| ORG_ID: ${{ secrets.ORG_ID }} | ||
| ENV_ID: ${{ secrets.ENV_ID }} | ||
| COMPUTE_POOL_ID: ${{ secrets.COMPUTE_POOL_ID }} | ||
|
|
||
| jobs: | ||
| manage: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '17' | ||
| cache: maven | ||
|
|
||
| - name: Build | ||
| run: ./mvnw -B --no-transfer-progress -DskipTests package | ||
|
|
||
| - name: Run lifecycle action | ||
| # Inputs are passed via env, not interpolated into the script, so free-text input | ||
| # cannot inject shell commands. The command is built as an array so each argument | ||
| # stays a single word regardless of its content. | ||
| env: | ||
| ACTION: ${{ inputs.action }} | ||
| APPLICATION_NAME: ${{ inputs.application-name }} | ||
| STATEMENT_NAME: ${{ inputs.statement-name }} | ||
| # --statement-name is added only when set (list then covers all statements). | ||
| # --wait makes stop/resume/delete block until the target phase so the exit code | ||
| # reflects the outcome; list and describe ignore it. | ||
| run: | | ||
| args=("$ACTION" --application-name "$APPLICATION_NAME" --wait) | ||
| if [ -n "$STATEMENT_NAME" ]; then | ||
| args+=(--statement-name "$STATEMENT_NAME") | ||
| fi | ||
| java -jar target/flink-table-api-java-examples-1.0.jar "${args[@]}" |
This file contains hidden or 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,27 @@ | ||
| # Continuous integration for this repository. | ||
| # | ||
| # Runs entirely without Confluent Cloud connectivity: code format check (Spotless), | ||
| # compilation, local unit tests on Apache Flink, and the fat JAR build. | ||
| # Integration tests (*IT) require Confluent Cloud credentials and would fail without | ||
| # them, so this workflow skips them explicitly with -DskipITs. | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '17' | ||
| cache: maven | ||
|
|
||
| - name: Build and test | ||
| run: ./mvnw -B --no-transfer-progress verify -DskipITs |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ target/ | |
| .java-version | ||
| *.DS_Store | ||
| cloud.properties | ||
| dependency-reduced-pom.xml | ||
| dependency-reduced-pom.xml | ||
| *.env | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.