Skip to content
Open
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
38 changes: 31 additions & 7 deletions .github/workflows/build-content-and-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
paths:
- '**/*.rs'
- '**/Cargo.lock'
- '**/Cargo.toml'
- '.github/workflows/build-content-and-diff.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
Expand All @@ -12,7 +15,7 @@ concurrency:
permissions: {} # No GITHUB_TOKEN permissions, as we only use it to increase API limit.

env:
BUILD_MAIN: ${{ github.workspace }}/build-main
BUILD_BASE: ${{ github.workspace }}/build-base
BUILD_PR: ${{ github.workspace }}/build-pr
CONTENT_ROOT: ${{ github.workspace }}/content/files
DIFF: ${{ github.workspace }}/diff.html
Expand All @@ -33,11 +36,32 @@ jobs:
path: content
persist-credentials: false

- name: Checkout mdn/rari (main branch)
- name: Determine baseline ref for comparison
id: baseline
env:
HEAD_REF: ${{ github.head_ref || github.ref_name }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
if [[ "$HEAD_REF" == release-please--* ]]; then
# Extract previous version from PR body (format: compare/v0.2.1...v0.2.2)
PREV_VERSION=$(echo "$PR_BODY" | grep -o 'compare/v[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1 | sed 's|compare/||')
if [[ -n "$PREV_VERSION" ]]; then
echo "ref=$PREV_VERSION" >> $GITHUB_OUTPUT
echo "Building release-please PR against previous release: $PREV_VERSION"
else
echo "ref=main" >> $GITHUB_OUTPUT
echo "Could not extract previous version, falling back to main"
fi
else
echo "ref=main" >> $GITHUB_OUTPUT
echo "Building regular PR against main branch"
fi

- name: Checkout mdn/rari (baseline)
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
ref: main
path: rari-main
ref: ${{ steps.baseline.outputs.ref }}
path: rari-base
persist-credentials: false

- name: Checkout mdn/rari (PR)
Expand All @@ -53,9 +77,9 @@ jobs:
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: Build with main branch
working-directory: rari-main
working-directory: rari-base
env:
BUILD_OUT_ROOT: ${{ env.BUILD_MAIN }}
BUILD_OUT_ROOT: ${{ env.BUILD_BASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo run --release build

Expand All @@ -68,7 +92,7 @@ jobs:

- name: Generate diff report
working-directory: rari-pr
run: cargo run -p diff-test diff --html --value --out "$DIFF" --verbose "$BUILD_MAIN" "$BUILD_PR"
run: cargo run -p diff-test diff --html --value --out "$DIFF" --verbose "$BUILD_BASE" "$BUILD_PR"

- name: Upload diff report
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
Expand Down
Loading