From 5f3246e127ac83e4057af64681efe11915a73e5b Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Mon, 5 Jan 2026 15:31:16 +0100 Subject: [PATCH 1/3] Enhance CI workflow for QR code SDK by adding conditional job execution. Introduced a check to determine if relevant files have changed before running build and quality checks, improving efficiency for dev branch deployments. --- .github/workflows/qrcode-sdk-ci.yml | 47 ++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/.github/workflows/qrcode-sdk-ci.yml b/.github/workflows/qrcode-sdk-ci.yml index 10202c07e..22b16fcb0 100644 --- a/.github/workflows/qrcode-sdk-ci.yml +++ b/.github/workflows/qrcode-sdk-ci.yml @@ -14,15 +14,43 @@ on: - dev - staging - main - paths: - - "sdk/qrcode/**" - - "common/**" - - ".github/workflows/qrcode-sdk-ci.yml" - - ".github/actions/**" jobs: + check_changes: + runs-on: ubuntu-slim + outputs: + should_run: ${{ steps.filter.outputs.should_run }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Check if should run + id: filter + run: | + set -e + if [[ "${{ github.base_ref }}" == "main" ]] || [[ "${{ github.base_ref }}" == "staging" ]]; then + echo "should_run=true" >> $GITHUB_OUTPUT + echo "Running for ${{ github.base_ref }} - no path filter" + else + # For dev branch, check if relevant files changed + CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) || { + echo "Error: Failed to diff against base branch" + exit 1 + } + if echo "$CHANGED_FILES" | grep -qE "^(sdk/qrcode/|common/|\.github/workflows/qrcode-sdk-ci\.yml|\.github/actions/)"; then + echo "should_run=true" >> $GITHUB_OUTPUT + echo "Running for dev - relevant files changed" + else + echo "should_run=false" >> $GITHUB_OUTPUT + echo "Skipping for dev - no relevant files changed" + fi + fi + # Build dependencies once and cache for other jobs build: + needs: check_changes + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -83,7 +111,8 @@ jobs: # Quality checks job quality-checks: runs-on: ubuntu-latest - needs: build + needs: [check_changes, build] + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' steps: - uses: actions/checkout@v6 - name: Read and sanitize Node.js version @@ -151,7 +180,8 @@ jobs: # Build verification job build-verification: runs-on: ubuntu-latest - needs: build + needs: [check_changes, build] + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' steps: - uses: actions/checkout@v6 - name: Read and sanitize Node.js version @@ -213,7 +243,8 @@ jobs: # Integration test job integration-test: runs-on: ubuntu-latest - needs: build + needs: [check_changes, build] + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' steps: - uses: actions/checkout@v6 - name: Read and sanitize Node.js version From 7cba76f02fa6ffde212f9475800facd284098a3d Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Mon, 5 Jan 2026 15:33:33 +0100 Subject: [PATCH 2/3] Enhance CI workflow by adding a conditional check for relevant file changes before executing jobs. This update improves efficiency for pull requests on the dev branch while maintaining execution for main and staging branches. --- .github/workflows/core-sdk-ci.yml | 51 ++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/.github/workflows/core-sdk-ci.yml b/.github/workflows/core-sdk-ci.yml index 5d9166588..0834c6426 100644 --- a/.github/workflows/core-sdk-ci.yml +++ b/.github/workflows/core-sdk-ci.yml @@ -2,14 +2,46 @@ name: Core SDK CI on: pull_request: - paths: - - "sdk/core/**" - - "common/**" - - ".github/workflows/core-sdk-ci.yml" - - ".github/actions/**" + branches: + - dev + - staging + - main jobs: + check_changes: + runs-on: ubuntu-slim + outputs: + should_run: ${{ steps.filter.outputs.should_run }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Check if should run + id: filter + run: | + set -e + if [[ "${{ github.base_ref }}" == "main" ]] || [[ "${{ github.base_ref }}" == "staging" ]]; then + echo "should_run=true" >> $GITHUB_OUTPUT + echo "Running for ${{ github.base_ref }} - no path filter" + else + # For dev branch, check if relevant files changed + CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) || { + echo "Error: Failed to diff against base branch" + exit 1 + } + if echo "$CHANGED_FILES" | grep -qE "^(sdk/core/|common/|\.github/workflows/core-sdk-ci\.yml|\.github/actions/)"; then + echo "should_run=true" >> $GITHUB_OUTPUT + echo "Running for dev - relevant files changed" + else + echo "should_run=false" >> $GITHUB_OUTPUT + echo "Skipping for dev - no relevant files changed" + fi + fi + build: + needs: check_changes + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -34,7 +66,8 @@ jobs: lint: runs-on: ubuntu-latest - needs: build + needs: [check_changes, build] + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' permissions: contents: read steps: @@ -63,7 +96,8 @@ jobs: types: runs-on: ubuntu-latest - needs: build + needs: [check_changes, build] + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' permissions: contents: read steps: @@ -92,7 +126,8 @@ jobs: test: runs-on: ubuntu-latest - needs: build + needs: [check_changes, build] + if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true' permissions: contents: read steps: From ec68519322e6848123ce5941631c695434ee1812 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Thu, 15 Jan 2026 09:21:58 +0100 Subject: [PATCH 3/3] Enhance CI workflows: fetch base branch for accurate file comparison --- .github/workflows/circuits.yml | 2 ++ .github/workflows/contracts.yml | 2 ++ .github/workflows/core-sdk-ci.yml | 2 ++ .github/workflows/qrcode-sdk-ci.yml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/.github/workflows/circuits.yml b/.github/workflows/circuits.yml index 021753870..7f34ced8a 100644 --- a/.github/workflows/circuits.yml +++ b/.github/workflows/circuits.yml @@ -24,6 +24,8 @@ jobs: echo "Running for ${{ github.base_ref }} - no path filter" else # For dev branch, check if circuits files changed + # Fetch the base branch to ensure it's available for comparison + git fetch origin ${{ github.base_ref }} --depth=1 CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) || { echo "Error: Failed to diff against base branch" exit 1 diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 2c41d18a8..86dbf375a 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -29,6 +29,8 @@ jobs: echo "Running for ${{ github.base_ref }} - no path filter" else # For dev branch, check if contracts or common files changed + # Fetch the base branch to ensure it's available for comparison + git fetch origin ${{ github.base_ref }} --depth=1 CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) || { echo "Error: Failed to diff against base branch" exit 1 diff --git a/.github/workflows/core-sdk-ci.yml b/.github/workflows/core-sdk-ci.yml index 0834c6426..180bc0e95 100644 --- a/.github/workflows/core-sdk-ci.yml +++ b/.github/workflows/core-sdk-ci.yml @@ -26,6 +26,8 @@ jobs: echo "Running for ${{ github.base_ref }} - no path filter" else # For dev branch, check if relevant files changed + # Fetch the base branch to ensure it's available for comparison + git fetch origin ${{ github.base_ref }} --depth=1 CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) || { echo "Error: Failed to diff against base branch" exit 1 diff --git a/.github/workflows/qrcode-sdk-ci.yml b/.github/workflows/qrcode-sdk-ci.yml index 22b16fcb0..1d5353af5 100644 --- a/.github/workflows/qrcode-sdk-ci.yml +++ b/.github/workflows/qrcode-sdk-ci.yml @@ -34,6 +34,8 @@ jobs: echo "Running for ${{ github.base_ref }} - no path filter" else # For dev branch, check if relevant files changed + # Fetch the base branch to ensure it's available for comparison + git fetch origin ${{ github.base_ref }} --depth=1 CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) || { echo "Error: Failed to diff against base branch" exit 1