From f3a7cb6ed126a5701a86ac53c09a380e0d36226c Mon Sep 17 00:00:00 2001 From: souhailaS Date: Mon, 7 Jul 2025 19:18:25 +0200 Subject: [PATCH 1/2] Optimize CI workflow by consolidating redundant jobs - Merged lint, knip, and format into quality-checks job - Merged typecheck, misc, and self-check into build-and-validate job - Reduced from 12 to 8 jobs while preserving all functionality - Eliminated 12 redundant setup steps (checkout + node setup + npm ci) Jobs consolidated: - quality-checks: lint + knip + format (saved 6 steps) - build-and-validate: typecheck + misc + self-check (saved 6 steps) Total savings: 12 step executions per CI run --- .github/workflows/ci.yml | 178 +++++++++++++++------------------------ 1 file changed, 69 insertions(+), 109 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21b21ed824f1f..2e21aeb08216f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,33 +101,7 @@ jobs: disable_search: true files: ./coverage/codecov.json - lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 'lts/*' - - run: npm ci - - - name: Linter - run: npm run lint - - knip: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 'lts/*' - - run: npm ci - - - name: Unused exports - run: npm run knip - - format: + quality-checks: runs-on: ubuntu-latest steps: @@ -144,6 +118,12 @@ jobs: restore-keys: | ${{ runner.os }}-dprint- + - name: Linter + run: npm run lint + + - name: Unused exports + run: npm run knip + - name: Check formatting run: npx dprint check @@ -163,7 +143,7 @@ jobs: - name: Validate the browser can import TypeScript run: npx hereby test-browser-integration - typecheck: + build-and-validate: runs-on: ubuntu-latest steps: @@ -176,6 +156,67 @@ jobs: - name: Build src run: npx hereby build-src + - name: Build scripts + run: npx hereby scripts + + - name: ESLint tests + run: npx hereby run-eslint-rules-tests + + - name: Build tsc + run: npx hereby tsc + + - name: Clean + run: npx hereby clean-src + + - name: Self build + run: npx hereby build-src --built + + baselines: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 'lts/*' + - run: npm ci + + - name: Remove all baselines + run: rm -rf tests/baselines/reference + + - name: Run tests + run: npm test &> /dev/null || exit 0 + + - name: Accept baselines + run: | + npx hereby baseline-accept + git add tests/baselines/reference + + - name: Check baselines + id: check-baselines + run: | + function print_diff() { + if ! git diff --staged --exit-code --quiet --diff-filter=$1; then + echo "$2:" + git diff --staged --name-only --diff-filter=$1 + fi + } + + if ! git diff --staged --exit-code --quiet; then + print_diff ACR "Missing baselines" + print_diff MTUXB "Modified baselines" + print_diff D "Unused baselines" + git diff --staged > fix_baselines.patch + exit 1 + fi + + - name: Upload baseline diff artifact + if: ${{ failure() && steps.check-baselines.conclusion == 'failure' }} + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: fix_baselines.patch + path: fix_baselines.patch + smoke: runs-on: ubuntu-latest @@ -257,84 +298,3 @@ jobs: - run: | echo "See $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID for more info." node ./pr/scripts/checkPackageSize.mjs ./base ./pr >> $GITHUB_STEP_SUMMARY - - misc: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 'lts/*' - - run: npm ci - - - name: Build scripts - run: npx hereby scripts - - - name: ESLint tests - run: npx hereby run-eslint-rules-tests - - self-check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 'lts/*' - - run: npm ci - - - name: Build tsc - run: npx hereby tsc - - - name: Clean - run: npx hereby clean-src - - - name: Self build - run: npx hereby build-src --built - - baselines: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 'lts/*' - - run: npm ci - - - name: Remove all baselines - run: rm -rf tests/baselines/reference - - - name: Run tests - run: npm test &> /dev/null || exit 0 - - - name: Accept baselines - run: | - npx hereby baseline-accept - git add tests/baselines/reference - - - name: Check baselines - id: check-baselines - run: | - function print_diff() { - if ! git diff --staged --exit-code --quiet --diff-filter=$1; then - echo "$2:" - git diff --staged --name-only --diff-filter=$1 - fi - } - - if ! git diff --staged --exit-code --quiet; then - print_diff ACR "Missing baselines" - print_diff MTUXB "Modified baselines" - print_diff D "Unused baselines" - git diff --staged > fix_baselines.patch - exit 1 - fi - - - name: Upload baseline diff artifact - if: ${{ failure() && steps.check-baselines.conclusion == 'failure' }} - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: fix_baselines.patch - path: fix_baselines.patch From 9f8164c4212ea5bca55d4341310007d5320710d3 Mon Sep 17 00:00:00 2001 From: souhailaS Date: Mon, 7 Jul 2025 19:59:43 +0200 Subject: [PATCH 2/2] Improve CI failure reporting with continue-on-error - Added continue-on-error to quality-checks and build-and-validate jobs - All checks now run even if one fails, providing complete feedback - Added failure reporting with specific commands to run locally This addresses the concern about separate failure reporting while keeping the optimization benefits of job consolidation. --- .github/workflows/ci.yml | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e21aeb08216f..0691a23d012dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,14 +119,35 @@ jobs: ${{ runner.os }}-dprint- - name: Linter + id: lint + continue-on-error: true run: npm run lint - name: Unused exports + id: knip + continue-on-error: true run: npm run knip - name: Check formatting + id: format + continue-on-error: true run: npx dprint check + - name: Report failures + if: steps.lint.outcome == 'failure' || steps.knip.outcome == 'failure' || steps.format.outcome == 'failure' + run: | + echo "Quality check failures detected:" + if [ "${{ steps.lint.outcome }}" == "failure" ]; then + echo "Linting failed - run 'npm run lint' to see issues" + fi + if [ "${{ steps.knip.outcome }}" == "failure" ]; then + echo "Unused exports detected - run 'npm run knip' to see issues" + fi + if [ "${{ steps.format.outcome }}" == "failure" ]; then + echo "Formatting issues found - run 'npx dprint check' to see issues" + fi + exit 1 + browser-integration: runs-on: ubuntu-latest @@ -154,23 +175,56 @@ jobs: - run: npm ci - name: Build src + id: build-src + continue-on-error: true run: npx hereby build-src - name: Build scripts + id: build-scripts + continue-on-error: true run: npx hereby scripts - name: ESLint tests + id: eslint-tests + continue-on-error: true run: npx hereby run-eslint-rules-tests - name: Build tsc + id: build-tsc + continue-on-error: true run: npx hereby tsc - name: Clean + if: steps.build-tsc.outcome == 'success' run: npx hereby clean-src - name: Self build + id: self-build + continue-on-error: true + if: steps.build-tsc.outcome == 'success' run: npx hereby build-src --built + - name: Report failures + if: steps.build-src.outcome == 'failure' || steps.build-scripts.outcome == 'failure' || steps.eslint-tests.outcome == 'failure' || steps.build-tsc.outcome == 'failure' || steps.self-build.outcome == 'failure' + run: | + echo "Build validation failures detected:" + if [ "${{ steps.build-src.outcome }}" == "failure" ]; then + echo "Source build failed - run 'npx hereby build-src'" + fi + if [ "${{ steps.build-scripts.outcome }}" == "failure" ]; then + echo "Scripts build failed - run 'npx hereby scripts'" + fi + if [ "${{ steps.eslint-tests.outcome }}" == "failure" ]; then + echo "ESLint rule tests failed - run 'npx hereby run-eslint-rules-tests'" + fi + if [ "${{ steps.build-tsc.outcome }}" == "failure" ]; then + echo "TSC build failed - run 'npx hereby tsc'" + fi + if [ "${{ steps.self-build.outcome }}" == "failure" ]; then + echo "Self build failed - run 'npx hereby build-src --built'" + fi + exit 1 + baselines: runs-on: ubuntu-latest