Skip to content

fix: parameterize schema and publication name in postgres-cdc-demo init SQL #1

fix: parameterize schema and publication name in postgres-cdc-demo init SQL

fix: parameterize schema and publication name in postgres-cdc-demo init SQL #1

Workflow file for this run

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Flow CI
on:
pull_request:
types: [opened, reopened, synchronize]
paths:
- 'flows/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
flow-diff:
runs-on: ubuntu-latest
name: Flow Diff
steps:
- name: Checkout PR Code
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
path: submitted-changes
- name: Get Changed Flow Files
id: files
run: |
cd submitted-changes
files=$(git diff --name-only $(git merge-base HEAD origin/${{ github.event.pull_request.base.ref }}) HEAD | grep 'flows/.*\.json$' || true)
if [ -z "$files" ]; then
echo "flowA=" >> $GITHUB_OUTPUT
echo "flowB=" >> $GITHUB_OUTPUT
echo "has_flows=false" >> $GITHUB_OUTPUT
else
bare=$(echo "$files" | tr '\n' ',' | sed 's/,$//')
flowA=$(echo "$bare" | sed 's|[^,]\+|original-code/&|g')
flowB=$(echo "$bare" | sed 's|[^,]\+|submitted-changes/&|g')
echo "flowA=$flowA" >> $GITHUB_OUTPUT
echo "flowB=$flowB" >> $GITHUB_OUTPUT
echo "has_flows=true" >> $GITHUB_OUTPUT
fi
- name: Checkout Original Code
if: steps.files.outputs.has_flows == 'true'
uses: actions/checkout@v6
with:
fetch-depth: 2
path: original-code
- name: Reset to Base
if: steps.files.outputs.has_flows == 'true'
run: cd original-code && git checkout HEAD^
- name: Snowflake Flow Diff
if: steps.files.outputs.has_flows == 'true'
uses: Snowflake-Labs/snowflake-flow-diff@v0
id: flowdiff
with:
flowA: ${{ steps.files.outputs.flowA }}
flowB: ${{ steps.files.outputs.flowB }}
checkstyle: true
checkstyle-rules: submitted-changes/.github/checkstyle/flow-checkstyle-rules.yaml
flow-tests:
runs-on: ubuntu-latest
name: Flow Validation Tests
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install Dependencies
run: pip install -r flows/requirements.txt
- name: Detect Changed Flow Buckets
id: buckets
run: |
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
BUCKETS=()
for file in $CHANGED_FILES; do
if [[ "$file" == flows/*/tests/*.py || "$file" == flows/*/*.json ]]; then
bucket=$(echo "$file" | cut -d'/' -f2)
BUCKETS+=("$bucket")
fi
done
UNIQUE_BUCKETS=($(printf '%s\n' "${BUCKETS[@]}" | sort -u))
if [ ${#UNIQUE_BUCKETS[@]} -eq 0 ]; then
echo "has_tests=false" >> $GITHUB_OUTPUT
else
PATHS=""
for bucket in "${UNIQUE_BUCKETS[@]}"; do
if [ -d "flows/$bucket/tests" ]; then
PATHS="$PATHS flows/$bucket/tests"
fi
done
echo "test_paths=$PATHS" >> $GITHUB_OUTPUT
echo "has_tests=true" >> $GITHUB_OUTPUT
fi
- name: Run Flow Validation Tests
if: steps.buckets.outputs.has_tests == 'true'
run: pytest ${{ steps.buckets.outputs.test_paths }} -v
deploy-hint:
runs-on: ubuntu-latest
name: Post Deploy Instructions
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Check for test YAML configs
id: check
run: |
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
HAS_CONFIG=false
CONFIGS=""
for file in $CHANGED_FILES; do
if [[ "$file" == flows/*/*.json ]]; then
bucket=$(echo "$file" | cut -d'/' -f2)
flow_base=$(basename "$file" .json)
test_name=$(echo "$flow_base" | tr '-' '_')
yaml_path="flows/$bucket/tests/test_${test_name}.yaml"
if [ -f "$yaml_path" ]; then
HAS_CONFIG=true
CONFIGS="$CONFIGS $yaml_path"
fi
fi
done
echo "has_config=$HAS_CONFIG" >> "$GITHUB_OUTPUT"
echo "configs=$CONFIGS" >> "$GITHUB_OUTPUT"
- name: Comment deploy instructions
if: steps.check.outputs.has_config == 'true'
uses: actions/github-script@v9
with:
script: |
const marker = '<!-- flow-deploy-hint -->';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c =>
c.user.type === 'Bot' && c.body.includes(marker)
);
if (existing) return;
let body = marker + '\n';
body += '### :rocket: Flow Deploy Available\n\n';
body += 'This PR modifies flow definitions that have a CI test configuration. ';
body += 'A maintainer (`admin` or `maintain` permission) can deploy and test the flow ';
body += 'on an ephemeral Snowflake runtime by commenting:\n\n';
body += '> **`deploy this flow`** or **`deploy the flow`**\n\n';
body += 'This will:\n';
body += '1. Create a dedicated ephemeral runtime\n';
body += '2. Deploy the changed flow(s)\n';
body += '3. Run validation tests\n';
body += '4. Tear down the runtime and report results\n\n';
body += 'To keep the runtime alive for debugging, add `do not clean` to the comment.';
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});