Skip to content

[CI Energy Waste]: Optimize CI workflow by consolidating redundant jobs #62011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
232 changes: 123 additions & 109 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -144,9 +118,36 @@ jobs:
restore-keys: |
${{ 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

Expand All @@ -163,7 +164,7 @@ jobs:
- name: Validate the browser can import TypeScript
run: npx hereby test-browser-integration

typecheck:
build-and-validate:
runs-on: ubuntu-latest

steps:
Expand All @@ -174,8 +175,102 @@ 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

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

Expand Down Expand Up @@ -257,84 +352,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