-
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.
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,63 @@ | ||
| # 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 on push. | ||
| # | ||
| # The workflow deploys the table program of Example_08_IntegrationAndDeployment: | ||
| # | ||
| # 1. Local unit tests run on the open source Flink engine (no credentials needed). | ||
| # 2. Integration tests run against Confluent Cloud. They fail fast if any of the | ||
| # secrets below are missing, so a misconfigured pipeline cannot skip its | ||
| # verification step and still deploy. | ||
| # 3. The deploy step runs the program's main() method, which submits the statement | ||
| # under a deterministic name. Re-running the workflow with unchanged code is | ||
| # idempotent: the plugin detects that an identical statement already exists. | ||
| # | ||
| # If the pipeline code changed, the conflicting statement currently has to be deleted | ||
| # first via the manage.yml workflow. Upcoming plugin versions simplify this with | ||
| # application name prefixes and an on-conflict replace option, removing the manual step. | ||
| # | ||
| # For staging-to-production promotion, run the same job against different GitHub | ||
| # environments so that each environment provides its own secrets and protection rules. | ||
| # | ||
| # Required secrets (see the README section "Via Environment Variables"): | ||
| # CLOUD_PROVIDER, CLOUD_REGION, FLINK_API_KEY, FLINK_API_SECRET, | ||
| # ORG_ID, ENV_ID, COMPUTE_POOL_ID, TARGET_CATALOG, TARGET_DATABASE | ||
| name: Deploy Table API Program | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| # In a real project, deploy when changes are merged: | ||
| # push: | ||
| # branches: [main] | ||
|
|
||
| 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 }} | ||
|
|
||
| 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 | ||
| run: > | ||
| java -cp target/flink-table-api-java-examples-1.0.jar | ||
| io.confluent.flink.examples.table.Example_08_IntegrationAndDeployment | ||
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,77 @@ | ||
| # 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. | ||
| # | ||
| # Deployment and lifecycle management are separate concerns: removing or changing code | ||
| # does not imply that a running statement should be stopped or deleted. This workflow | ||
| # makes lifecycle operations explicit. It is triggered manually from the GitHub Actions | ||
| # UI and runs Example_12_StatementLifecycle with the chosen action. | ||
| # | ||
| # Example usage (use the exact statement name as printed by the deploy step; the | ||
| # plugin may append a suffix such as '-api' to configured names, which upcoming | ||
| # plugin versions remove): | ||
| # - Check a deployment: action=status, statement-name=vendors-per-brand-api | ||
| # - Stop a statement: action=stop, statement-name=vendors-per-brand-api | ||
| # - Resume after a stop: action=resume, statement-name=vendors-per-brand-api | ||
| # - Permanently remove: action=delete, statement-name=vendors-per-brand-api | ||
| # | ||
| # Upcoming plugin versions add an application name concept that groups all statements | ||
| # of a program under a common prefix and allows listing them, so that statements no | ||
| # longer need to be addressed one by one. | ||
| # | ||
| # Required secrets (see the README section "Via Environment Variables"): | ||
| # CLOUD_PROVIDER, CLOUD_REGION, FLINK_API_KEY, FLINK_API_SECRET, | ||
| # ORG_ID, ENV_ID, COMPUTE_POOL_ID | ||
| name: Manage Flink Statements | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| action: | ||
| description: 'Action to perform' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - status | ||
|
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.
|
||
| - stop | ||
| - resume | ||
| - delete | ||
| statement-name: | ||
| description: 'Full statement name as printed by the deploy step (e.g. vendors-per-brand-api)' | ||
| required: true | ||
|
|
||
| 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 and quoted instead of interpolated into the | ||
| # script, so that free-text input cannot inject shell commands. | ||
| env: | ||
| ACTION: ${{ inputs.action }} | ||
| STATEMENT_NAME: ${{ inputs.statement-name }} | ||
| run: > | ||
| java -cp target/flink-table-api-java-examples-1.0.jar | ||
| io.confluent.flink.examples.table.Example_12_StatementLifecycle | ||
| "$ACTION" "$STATEMENT_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,27 @@ | ||
| # Continuous integration for this repository. | ||
| # | ||
| # Runs entirely without Confluent Cloud connectivity: code format check (Spotless), | ||
| # compilation, local unit tests on the open source Flink engine, 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
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.
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.
Could we use the
--waitoption here? Otherwise the deployment will always report with exit code 0 and not reflect the real outcome of this operation