Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/actions/detect-changes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Detect Changes
description: Determines whether code-related files (not docs-only) have changed in a PR
outputs:
RUN_CHECKS:
description: 'true if code files changed, false if only docs/*.md changed'
value: ${{ steps.detect.outputs.RUN_CHECKS }}
runs:
using: composite
steps:
- name: Check for code changes
id: detect
uses: actions/github-script@v7
with:
script: |
if (!context.payload.pull_request) {
core.setOutput('RUN_CHECKS', 'true');
return;
}

const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});

const skipRunPatterns = [/^docs\//, /\.md$/];

const shouldRun = files.some((file) => {
const filename = file.filename;
return !skipRunPatterns.some((pattern) => pattern.test(filename));
});

if (!shouldRun) {
core.info('⏭️ Skip checks: only docs & md files changed');
} else {
core.info('✅ Running checks: code-related files changed');
}

core.setOutput('RUN_CHECKS', shouldRun ? 'true' : 'false');
16 changes: 13 additions & 3 deletions .github/workflows/breaking-changes-detection-bot.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
on:
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- '**.md'
- 'docs/**'
name: API extractor
jobs:
detect_changes:
name: API extractor - Detect changes
runs-on: ubuntu-latest
outputs:
RUN_CHECKS: ${{ steps.detect_code_changes.outputs.RUN_CHECKS }}
steps:
- uses: actions/checkout@v6
- name: Detect code changes
id: detect_code_changes
uses: ./.github/actions/detect-changes

breakingChangeDetectionBot:
needs: [detect_changes]
name: Breaking change detection bot
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CHECKS == 'true' }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/cache-builded-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ on:
- develop-*
- 'epic/**'
- release/*
paths-ignore:
- '**.md'
- 'docs/**'
name: Cache libs (dist)
jobs:
detect_changes:
name: Cache libs - Detect changes
runs-on: ubuntu-latest
outputs:
RUN_CHECKS: ${{ steps.detect_code_changes.outputs.RUN_CHECKS }}
steps:
- uses: actions/checkout@v6
- name: Detect code changes
id: detect_code_changes
uses: ./.github/actions/detect-changes

cacheBuildedLibs:
needs: [detect_changes]
name: Builded libs
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CHECKS == 'true' }}
steps:
- uses: actions/checkout@master
- name: Cache builded libs
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/cache-node-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,29 @@ on:
- develop-*
- 'epic/**'
- release/*
paths-ignore:
- '**.md'
- 'docs/**'
name: Cache node modules

env:
NODE_VERSION: '20'
CONTINUUM_REGISTRY_TOKEN: ${{ secrets.CONTINUUM_REGISTRY_TOKEN }}

jobs:
detect_changes:
name: Cache node modules - Detect changes
runs-on: ubuntu-latest
outputs:
RUN_CHECKS: ${{ steps.detect_code_changes.outputs.RUN_CHECKS }}
steps:
- uses: actions/checkout@v6
- name: Detect code changes
id: detect_code_changes
uses: ./.github/actions/detect-changes

cacheNodeModules:
needs: [detect_changes]
name: Cache node_modules
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CHECKS == 'true' }}
steps:
- uses: actions/checkout@v6
- name: Setup node
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/ci-continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
- develop-*
- release/*
- epic/**
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch:
# empty as it is used only to manually trigger the workflow

Expand All @@ -23,9 +20,22 @@ concurrency:

name: Continuous Integration
jobs:
detect_changes:
name: CI - Detect changes
runs-on: ubuntu-latest
outputs:
RUN_CI_CHECKS: ${{ steps.detect_code_changes.outputs.RUN_CHECKS }}
steps:
- uses: actions/checkout@v6
- name: Detect code changes
id: detect_code_changes
uses: ./.github/actions/detect-changes

unit_tests:
needs: [detect_changes]
name: CI - Unit tests
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CI_CHECKS == 'true' }}
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -50,6 +60,7 @@ jobs:
run: |
ci-scripts/unit-tests.sh
sonarqube_scan:
needs: [detect_changes]
name: CI - SonarQube Scan
runs-on: ubuntu-latest
steps:
Expand All @@ -66,10 +77,12 @@ jobs:
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonar.tools.sap
if: github.event_name == 'pull_request'
if: ${{ github.event_name == 'pull_request' && needs.detect_changes.outputs.RUN_CI_CHECKS == 'true' }}
linting:
needs: [detect_changes]
name: CI - Validations and static code checks
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CI_CHECKS == 'true' }}
steps:
- uses: actions/checkout@v6
- name: Setup node
Expand All @@ -92,8 +105,10 @@ jobs:
run: |
ci-scripts/validate-lint.sh
check_peer_dependencies:
needs: [detect_changes]
name: CI - Check peerDependencies
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CI_CHECKS == 'true' }}
steps:
- uses: actions/checkout@v6
with:
Expand Down
30 changes: 19 additions & 11 deletions .github/workflows/ci-merge-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
- develop
- develop-*
- release/*
paths-ignore:
- '**.md'
- 'docs/**'

workflow_dispatch:
# empty as it is used only to manually trigger the workflow
Expand All @@ -25,6 +22,17 @@ concurrency:

name: Merge Checks
jobs:
detect_changes:
name: MC - Detect changes
runs-on: ubuntu-latest
outputs:
RUN_E2E_BY_CHANGES: ${{ steps.detect_code_changes.outputs.RUN_CHECKS }}
steps:
- uses: actions/checkout@v6
- name: Detect code changes
id: detect_code_changes
uses: ./.github/actions/detect-changes

no_retries:
name: MC - Prevent retries
# E2Es can't be retried. Moreover, in some retry cases, they don't run
Expand Down Expand Up @@ -134,13 +142,13 @@ jobs:
dist/storefrontapp
key: spartacus-app-${{ matrix.cache_key }}-${{ matrix.build_type }}-${{ github.event.pull_request.head.sha || github.run_id }}
b2c_e2e_tests:
needs: [no_retries, validate_e2e_execution, build_apps]
needs: [detect_changes, no_retries, validate_e2e_execution, build_apps]
name: MC - E2E B2C core
runs-on: ubuntu-latest
strategy:
matrix:
containers: [1, 2, 3, 4, 5]
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' && needs.detect_changes.outputs.RUN_E2E_BY_CHANGES == 'true' }}
steps:
- uses: actions/checkout@v6
- name: E2E Test Setup
Expand All @@ -156,10 +164,10 @@ jobs:
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
run: ci-scripts/e2e-cypress.sh --skip-build
b2c_ssr_e2e_tests:
needs: [no_retries, validate_e2e_execution, build_apps]
needs: [detect_changes, no_retries, validate_e2e_execution, build_apps]
name: MC - E2E SSR core (B2C)
runs-on: ubuntu-latest
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' && needs.detect_changes.outputs.RUN_E2E_BY_CHANGES == 'true' }}
steps:
- uses: actions/checkout@v6
- name: E2E Test Setup
Expand All @@ -175,13 +183,13 @@ jobs:
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
run: ci-scripts/e2e-cypress.sh --skip-build --ssr
b2b_e2e_tests:
needs: [no_retries, validate_e2e_execution, build_apps]
needs: [detect_changes, no_retries, validate_e2e_execution, build_apps]
name: MC - E2E B2B core
runs-on: ubuntu-latest
strategy:
matrix:
containers: [1, 2, 3, 4]
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' && needs.detect_changes.outputs.RUN_E2E_BY_CHANGES == 'true' }}
steps:
- uses: actions/checkout@v6
- name: E2E Test Setup
Expand All @@ -197,13 +205,13 @@ jobs:
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
run: ci-scripts/e2e-cypress.sh -s b2b --skip-build
a11y_e2e_tests:
needs: [no_retries, validate_e2e_execution, build_apps]
needs: [detect_changes, no_retries, validate_e2e_execution, build_apps]
name: MC - E2E A11Y
runs-on: ubuntu-latest
strategy:
matrix:
containers: [1, 2, 3]
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' && needs.detect_changes.outputs.RUN_E2E_BY_CHANGES == 'true' }}
steps:
- uses: actions/checkout@v6
- name: E2E Test Setup
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
- develop
- develop-*
- release/*
paths-ignore:
- "**.md"
- "docs/**"

workflow_dispatch:
# empty as it is used only to manually trigger the workflow.
Expand All @@ -23,16 +20,31 @@ concurrency:

name: Spartacus build pipeline
jobs:
detect_changes:
name: CI - Detect changes
runs-on: ubuntu-latest
outputs:
RUN_CHECKS: ${{ steps.detect_code_changes.outputs.RUN_CHECKS }}
steps:
- uses: actions/checkout@v6
- name: Detect code changes
id: detect_code_changes
uses: ./.github/actions/detect-changes

no_retries:
needs: [detect_changes]
name: Verify re-run of all jobs
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CHECKS == 'true' }}
steps:
- uses: actions/checkout@v6
- name: Prevent retries
uses: ./.github/actions/prevent-retries
validate_e2e_execution:
needs: [detect_changes]
name: Validate pull_request files
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.RUN_CHECKS == 'true' }}
outputs:
SHOULD_RUN_E2E: ${{ steps.save-e2e-output-result.outputs.SHOULD_RUN_E2E }}
steps:
Expand Down
36 changes: 30 additions & 6 deletions .github/workflows/config-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,51 @@ on:
pull_request:
types: [opened, synchronize, reopened]

paths-ignore:
- '**.md'
- 'docs/**'

name: Config check
jobs:
configCheck:
name: Dependencies and tsconfig files
runs-on: ubuntu-latest
steps:
- name: Detect whether config check should run
id: detect_changes
uses: actions/github-script@v7
with:
script: |
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});

const shouldRun = files.some((file) => {
const filename = file.filename;
return !filename.startsWith('docs/') && !filename.endsWith('.md');
});

core.setOutput('run_config_check', shouldRun ? 'true' : 'false');

- name: Skip config check for docs-only changes
if: ${{ steps.detect_changes.outputs.run_config_check != 'true' }}
run: echo 'Skipping config check because PR changes only markdown/docs files.'

- name: Cancel Previous Runs
if: ${{ steps.detect_changes.outputs.run_config_check == 'true' }}
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@master
- uses: actions/setup-node@v4
- if: ${{ steps.detect_changes.outputs.run_config_check == 'true' }}
uses: actions/checkout@master
- if: ${{ steps.detect_changes.outputs.run_config_check == 'true' }}
uses: actions/setup-node@v4
with:
node-version: '20'
- name: NPM
if: ${{ steps.detect_changes.outputs.run_config_check == 'true' }}
run: npm i
- name: Check configurations
if: ${{ steps.detect_changes.outputs.run_config_check == 'true' }}
run: npm run config:check
env:
FORCE_COLOR: 2 # Support colors from chalk
Loading
Loading