This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-connector-opensearch.git


The following commit(s) were added to refs/heads/main by this push:
     new ee622cc  [FLINK-40711][ci] Do not run weekly if there is no new 
commits since last green run
ee622cc is described below

commit ee622ccecfb9bf81534082bb20b362d9fa46d058
Author: Sergey Nuyanzin <[email protected]>
AuthorDate: Sat Sep 19 09:10:00 2026 +0200

    [FLINK-40711][ci] Do not run weekly if there is no new commits since last 
green run
---
 .github/workflows/weekly-trigger.yml | 137 +++++++++++++++++++++++++++++++++++
 .github/workflows/weekly.yml         |  36 ++++++---
 2 files changed, 164 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/weekly-trigger.yml 
b/.github/workflows/weekly-trigger.yml
new file mode 100644
index 0000000..0302d93
--- /dev/null
+++ b/.github/workflows/weekly-trigger.yml
@@ -0,0 +1,137 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you 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.
+################################################################################
+
+# We need to specify repo related information here since Apache INFRA doesn't 
differentiate
+# between several workflows with the same names while preparing a report for 
GHA usage
+# https://infra-reports.apache.org/#ghactions
+name: Weekly Trigger Flink Connector Opensearch
+on:
+  schedule:
+    - cron: "0 0 * * 0"
+  workflow_dispatch:
+
+permissions: read-all
+
+env:
+  STATE_ARTIFACT: weekly-tested-shas
+  STATE_FILE: state/tested-shas.json
+
+jobs:
+  Trigger:
+    if: github.repository == 'apache/flink-connector-opensearch'
+    permissions:
+      contents: read
+      actions: write
+    concurrency:
+      group: ${{ github.workflow }}
+      cancel-in-progress: true
+    runs-on: ubuntu-latest
+    steps:
+      # The previous trigger run persisted the SHAs it last tested with fixed 
versions.
+      - name: "Resolve previous state run"
+        id: prev
+        uses: actions/github-script@v9
+        with:
+          script: |
+            const { data } = await github.rest.actions.listWorkflowRuns({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              workflow_id: 'weekly-trigger.yml',
+              status: 'success',
+              per_page: 1,
+            });
+            core.setOutput('run_id', data.workflow_runs[0]?.id?.toString() ?? 
'');
+
+      # Best effort: missing/expired artifact just means we fall back to 
running fixed versions.
+      - name: "Download previous tested SHAs"
+        if: steps.prev.outputs.run_id != ''
+        continue-on-error: true
+        uses: actions/download-artifact@v8
+        with:
+          name: ${{ env.STATE_ARTIFACT }}
+          run-id: ${{ steps.prev.outputs.run_id }}
+          github-token: ${{ github.token }}
+          path: state
+
+      - name: "Decide and trigger weekly"
+        uses: actions/github-script@v9
+        with:
+          script: |
+            const fs = require('fs');
+            // Branches exercised by the weekly matrix. Keep in sync with 
weekly.yml.
+            const branches = ['main', 'v1.2'];
+
+            // Default to running fixed versions; only skip when we positively 
confirm nothing changed and last was green.
+            let runFixed = true;
+            let reason = 'defaulting to full run';
+            const current = {};
+
+            try {
+              // Exact SHAs tested with fixed versions last time (empty on 
first run or expired artifact).
+              let previous = {};
+              try { previous = 
JSON.parse(fs.readFileSync(process.env.STATE_FILE, 'utf8')); } catch (e) {}
+
+              // Current HEAD SHA of each watched branch; a lookup failure is 
treated as "changed" (safe direction).
+              const changed = [];
+              for (const b of branches) {
+                try {
+                  const { data } = await github.rest.repos.getBranch({ owner: 
context.repo.owner, repo: context.repo.repo, branch: b });
+                  current[b] = data.commit.sha;
+                  if (previous[b] !== current[b]) changed.push(b);
+                } catch (e) {
+                  core.warning(`Could not resolve HEAD of ${b}: ${e.message}; 
assuming it changed.`);
+                  changed.push(b);
+                }
+              }
+
+              // Last weekly conclusion, so a non-green run retries fixed 
versions even without new commits.
+              const { data: runs } = await 
github.rest.actions.listWorkflowRuns({ owner: context.repo.owner, repo: 
context.repo.repo, workflow_id: 'weekly.yml', per_page: 1 });
+              const lastWeekly = runs.workflow_runs[0];
+
+              const manual = context.eventName === 'workflow_dispatch';
+              const notGreen = !lastWeekly || lastWeekly.conclusion !== 
'success';
+              runFixed = manual || notGreen || changed.length > 0;
+              reason = manual ? 'manual dispatch'
+                : notGreen ? `last weekly concluded '${lastWeekly?.conclusion 
?? 'none'}'`
+                : changed.length ? `new commits on ${changed.join(', ')}`
+                : 'no new commits and last weekly was green';
+            } catch (e) {
+              core.warning(`Failed to compute fixed-version decision: 
${e.message}; running fixed versions.`);
+            }
+            core.info(`Weekly dispatch (fixed versions: ${runFixed}): 
${reason}.`);
+
+            // Snapshots must always run, so this dispatch happens regardless 
of the decision above.
+            await github.rest.actions.createWorkflowDispatch({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              workflow_id: 'weekly.yml',
+              ref: context.ref.replace('refs/heads/', ''),
+              inputs: { run_fixed_versions: String(runFixed) },
+            });
+
+            // Fixed versions run whenever a SHA changed, so the resolved 
HEADs are the new baseline (unresolved branches are re-checked next run).
+            fs.mkdirSync('state', { recursive: true });
+            fs.writeFileSync(process.env.STATE_FILE, JSON.stringify(current));
+
+      # Persist the baseline for the next scheduled run.
+      - name: "Upload tested SHAs"
+        uses: actions/upload-artifact@v7
+        with:
+          name: ${{ env.STATE_ARTIFACT }}
+          path: ${{ env.STATE_FILE }}
+          retention-days: 90
diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml
index 2b02570..05ae3ac 100644
--- a/.github/workflows/weekly.yml
+++ b/.github/workflows/weekly.yml
@@ -20,12 +20,18 @@
 # between several workflows with the same names while preparing a report for 
GHA usage
 # https://infra-reports.apache.org/#ghactions
 name: Weekly Flink Connector Opensearch
+# Scheduling is handled by weekly-trigger.yml: snapshots always run, fixed 
versions only on new commits or a non-green previous run.
 on:
-  schedule:
-    - cron: "0 0 * * 0"
   workflow_dispatch:
+    inputs:
+      run_fixed_versions:
+        description: "Also test against fixed (released) Flink versions"
+        type: choice
+        options: ["true", "false"]
+        default: "true"
 jobs:
-  compile_and_test:
+  # Snapshot Flink versions change upstream regardless of connector commits, 
so they always run.
+  compile_and_test_snapshot:
     if: github.repository_owner == 'apache'
     strategy:
       matrix:
@@ -34,12 +40,24 @@ jobs:
           jdk: '11, 17, 21',
           branch: main
         },
-        {
-          flink: 1.20-SNAPSHOT,
-          jdk: '8, 11, 17, 21',
-          branch: v1.2
-        }, 
-        {
+          {
+            flink: 1.20-SNAPSHOT,
+            jdk: '8, 11, 17, 21',
+            branch: v1.2
+          }]
+    uses: apache/flink-connector-shared-utils/.github/workflows/ci.yml@ci_utils
+    with:
+      flink_version: ${{ matrix.flink_branches.flink }}
+      jdk_version: ${{ matrix.flink_branches.jdk || '8, 11, 17' }}
+      connector_branch: ${{ matrix.flink_branches.branch }}
+      run_dependency_convergence: false
+
+  # Fixed Flink versions only change with connector commits, so they run only 
when requested by the trigger.
+  compile_and_test_fixed:
+    if: ${{ github.repository_owner == 'apache' && inputs.run_fixed_versions 
== 'true' }}
+    strategy:
+      matrix:
+        flink_branches: [ {
           flink: 1.20.5,
           jdk: '8, 11, 17, 21',
           branch: v1.2

Reply via email to