Skip to content

Potential Build Script for CI #9

Potential Build Script for CI

Potential Build Script for CI #9

Workflow file for this run

name: CI - Next.js
on:
push:
branches: [main]
paths:
- 'packages/starter-next-js/**'
- '.github/workflows/ci-next-js.yml'
- 'package.json'
- 'pnpm-lock.yaml'
- 'eslint.config.js'
- 'prettier.config.js'
pull_request:
branches: [main]
paths:
- 'packages/starter-next-js/**'
- '.github/workflows/ci-next-js.yml'
- 'package.json'
- 'pnpm-lock.yaml'
- 'eslint.config.js'
- 'prettier.config.js'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Format check
run: pnpm --filter starter-next-js format:check
- name: Lint
run: pnpm --filter starter-next-js lint
- name: Type check
run: pnpm --filter starter-next-js type-check
- name: Build
run: pnpm build:next
measure:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
# No cache - we want clean measurements
- name: Measure install time
id: install
run: |
START=$(date +%s%N)
pnpm install --frozen-lockfile
END=$(date +%s%N)
ELAPSED=$((($END - $START) / 1000000))
echo "time=$ELAPSED" >> $GITHUB_OUTPUT
echo "Install time: ${ELAPSED}ms"
- name: Measure cold build time
id: cold_build
run: |
START=$(date +%s%N)
pnpm build:next
END=$(date +%s%N)
ELAPSED=$((($END - $START) / 1000000))
echo "time=$ELAPSED" >> $GITHUB_OUTPUT
echo "Cold build time: ${ELAPSED}ms"
- name: Measure warm build time
id: warm_build
run: |
START=$(date +%s%N)
pnpm build:next
END=$(date +%s%N)
ELAPSED=$((($END - $START) / 1000000))
echo "time=$ELAPSED" >> $GITHUB_OUTPUT
echo "Warm build time: ${ELAPSED}ms"
- name: Save CI stats
run: |
mkdir -p packages/starter-next-js
echo '{
"installTimeMs": ${{ steps.install.outputs.time }},
"coldBuildTimeMs": ${{ steps.cold_build.outputs.time }},
"warmBuildTimeMs": ${{ steps.warm_build.outputs.time }},
"timingMeasuredAt": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
"runner": "ubuntu-latest"
}' > packages/starter-next-js/.ci-stats.json
- name: Commit CI stats
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add packages/starter-next-js/.ci-stats.json
if git diff --staged --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Update CI stats for starter-next-js [skip ci]"
# Push to the PR branch or main
if [ "${{ github.event_name }}" = "pull_request" ]; then
git push origin HEAD:${{ github.head_ref }}
else
git push
fi