-
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
Changes from all commits
a727647
dc0bf5d
cbeb95b
1ef34a2
efd25e6
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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # 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 | ||
|
|
||
| # Show what this pipeline deploys in the runs list. run-name can only read the github and inputs | ||
| # contexts, not env, so the application and statement names are repeated here; keep them in sync | ||
| # with APPLICATION_NAME / STATEMENT_NAME below. | ||
| run-name: "Deploy marketplace-analytics / vendors-per-brand" | ||
|
|
||
| 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 | ||
| # --sql.current-catalog / --sql.current-database select the target environment and Kafka | ||
| # cluster (they are ordinary configuration options, like the connection settings). | ||
| # --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 -cp target/flink-table-api-java-examples-1.0.jar io.confluent.flink.examples.table.Example_08_IntegrationAndDeployment | ||
| --statement-name "$STATEMENT_NAME" | ||
| --application-name "$APPLICATION_NAME" | ||
| --sql.current-catalog "$TARGET_CATALOG" | ||
| --sql.current-database "$TARGET_DATABASE" | ||
|
Member
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. We have not documented these config options as far as I'm aware of.
Member
Author
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. It's going to be a fun experiment, because I suspect this will allow me to use/pass all values that are listed in https://docs.confluent.io/cloud/current/flink/reference/statements/set.html#table-options
Member
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. Your suspicion is correct. |
||
| --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 -cp target/flink-table-api-java-examples-1.0.jar io.confluent.flink.examples.table.Example_08_IntegrationAndDeployment | ||
| list | ||
| --application-name "$APPLICATION_NAME" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # 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 application name defaults to the one deploy.yml uses; override it per run. | ||
| name: Manage Flink Statements | ||
|
|
||
| # Name each run after the action and target so the runs list is distinguishable at a glance | ||
| # (e.g. "stop on marketplace-analytics / vendors-per-brand"). The statement-name part is only | ||
| # added when set, so "list" (which takes no statement) shows no dangling separator. Hyphenated | ||
| # inputs use bracket syntax because a dot would be parsed as subtraction. | ||
| run-name: "${{ inputs.action }} on ${{ inputs['application-name'] }}${{ inputs['statement-name'] != '' && format(' / {0}', inputs['statement-name']) || '' }}" | ||
|
|
||
| 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, e.g. vendors-per-brand (leave empty for list to show all)' | ||
| required: false | ||
|
|
||
| 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 -cp target/flink-table-api-java-examples-1.0.jar io.confluent.flink.examples.table.Example_08_IntegrationAndDeployment "${args[@]}" |
| 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 |
| 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 | ||
Uh oh!
There was an error while loading. Please reload this page.