Skip to content

[Email Service] Fix Python email handler, raw MIME thread replies, and Worker routing quickstart #85821

[Email Service] Fix Python email handler, raw MIME thread replies, and Worker routing quickstart

[Email Service] Fix Python email handler, raw MIME thread replies, and Worker routing quickstart #85821

Workflow file for this run

name: CI
on:
pull_request:
branches:
- production
paths-ignore:
- ".flue/**"
- ".github/workflows/flue-ci.yml"
- ".github/workflows/flue-deploy.yml"
# Merge queue runs. Path filters don't apply, so the required checks always
# report. Steps that need a PR are skipped for this event.
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# PR-only: per-file checks are redundant in the merge queue.
typos:
name: Typos
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Check for typos
uses: crate-ci/typos@d43b6c087ac471e2ea7b8af622ff15f05c0c365b # v1.50.1
with:
files: src/content/docs src/content/partials src/content/changelog
config: ./_typos.toml
pre-build:
name: Pre Build
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11.28.2
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Check for CRLF line endings
if: github.event_name == 'pull_request'
run: |
if git grep -Il $'\r'; then
echo "::error::CRLF line endings detected. Configure your editor to use LF line endings (this repo has an .editorconfig file that most editors respect automatically)."
exit 1
fi
- name: Check for invalid file extensions
if: github.event_name == 'pull_request'
run: |
FILES=$(
find src/content \
-type f \
-not -name '*.mdx' \
-not -name '*.md' \
-not -name '*.json' \
-not -name '*.yml' \
-not -name '*.yaml' \
-not -name '*.txt' \
-not -wholename 'src/content/collections/*'
)
if [ -n "$FILES" ]; then
echo "Found files with invalid file extensions:\n\n$FILES"
exit 1
fi
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check Astro and CF Worker
run: pnpm run check
- name: Set up reviewdog
if: github.event_name == 'pull_request'
uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0
with:
reviewdog_version: v0.21.0
- name: Run eslint
if: github.event_name == 'pull_request'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm run lint --format eslint-formatter-checkstyle | \
reviewdog -f=checkstyle -name=eslint -reporter=github-pr-review -fail-level=error -filter-mode=nofilter
- name: Check formatting
if: github.event_name == 'pull_request'
# The codebase is always fully formatted, so checking all
# prettier-scoped files is equivalent to checking only changed files.
run: pnpm run format:check
- name: Validate redirects
run: pnpm exec tsm bin/validate-redirects.ts
- name: Check component docs reference
run: pnpm exec tsx bin/check-component-docs.ts
# Edits to published changelog posts only reach RSS subscribers through a
# frontmatter `updates` entry. WAF rule or action changes without one
# fail; other content edits get a reminder comment and don't fail.
- name: Check changelog updates entries
if: github.event_name == 'pull_request'
# Compare with the production commit this PR was merged onto: the
# merge commit's first parent. `pull_request.base.sha` can be older,
# which would count other PRs' changes as part of this one.
run: |
git fetch --no-tags --depth=2 origin "$GITHUB_SHA"
pnpm exec tsx bin/check-changelog-updates.ts "$GITHUB_SHA^1" --comment "$RUNNER_TEMP/changelog-updates.md"
- name: Comment on changelog updates
if: always() && github.event_name == 'pull_request'
# The token is read-only for PRs from forks, where the step's warnings
# and errors are still shown.
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
body_file="$RUNNER_TEMP/changelog-updates.md"
# Missing when an earlier step failed before the check ran.
[ -f "$body_file" ] || exit 0
existing_id=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --paginate \
--jq '.[] | select(.user.login == "github-actions[bot]") | select(.body | contains("<!-- changelog-updates-check -->")) | .id' | head -n1)
if [ -s "$body_file" ]; then
if [ -n "$existing_id" ]; then
gh api -X PATCH "repos/$REPO/issues/comments/$existing_id" -F body=@"$body_file" > /dev/null
else
gh api -X POST "repos/$REPO/issues/$PR_NUMBER/comments" -F body=@"$body_file" > /dev/null
fi
elif [ -n "$existing_id" ]; then
gh api -X DELETE "repos/$REPO/issues/comments/$existing_id"
fi
- name: Tests
run: pnpm run test:prebuild
build:
name: Build
runs-on: ubuntu-latest
outputs:
succeeded: ${{ steps.build.outputs.succeeded }}
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: ${{ github.event_name != 'merge_group' && 1 || 0 }}
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11.28.2
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Restore Astro cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
node_modules/.astro
key: astro-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.event.pull_request.head.sha || github.sha }}
restore-keys: |
astro-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-
astro-cache-${{ runner.os }}-
- name: Build
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: "--max-old-space-size=8192"
DEPLOYMENT_ENV: ${{ github.event_name == 'merge_group' && 'production' || 'preview' }}
run: |
set -o pipefail
pnpm run build:parallel 2>&1 | tee build.log
echo "succeeded=true" >> "$GITHUB_OUTPUT"
- name: Upload build artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: dist
path: dist
include-hidden-files: true
- name: Tests (Workers)
run: pnpm run test:postbuild
# Lint steps use `!cancelled()` so a lint failure doesn't skip the
# others. The report step is the gate: it prints the findings and fails.
- name: Run Nimbus lint
id: nimbus-lint
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: |
set +e
pnpm exec nimbus-docs lint --format json > "$RUNNER_TEMP/nimbus-lint.json"
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
exit 0
- name: Check internal links
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
env:
LINT_EXIT_CODE: ${{ steps.nimbus-lint.outputs.exit_code }}
run: pnpm exec tsx bin/nimbus-lint-report.ts "$RUNNER_TEMP/nimbus-lint.json"
- name: Upload build log
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: build-log
path: build.log
if-no-files-found: ignore
notify:
name: Notify
needs: [pre-build, build]
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11.28.2
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Post PR CI failure comment
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm exec tsx bin/post-pr-ci-failure-comment/index.ts
publish-worker-preview:
name: Deploy Worker Preview
needs: build
if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && needs.build.outputs.succeeded == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11.28.2
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 24.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: dist
path: dist
- name: Deploy Worker Preview
id: deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
PREVIEW_NAME=$(pnpm exec tsx bin/print-worker-preview-name.ts "$PR_HEAD_REF")
OUTPUT_FILE="$RUNNER_TEMP/wrangler-preview.ndjson"
WRANGLER_OUTPUT_FILE_PATH="$OUTPUT_FILE" \
pnpm exec wrangler preview --config wrangler.preview.json \
--name "$PREVIEW_NAME" --tag "${PR_HEAD_SHA:0:8}" --message "$PR_HEAD_SHA"
# Use the URLs wrangler reports instead of building them by hand.
PREVIEW_URL=$(jq -r 'select(.type == "preview") | .preview_urls[0] // empty' "$OUTPUT_FILE" | tail -n 1)
DEPLOYMENT_URL=$(jq -r 'select(.type == "preview") | .deployment_urls[0] // empty' "$OUTPUT_FILE" | tail -n 1)
[ -n "$PREVIEW_URL" ] || { echo "::error::No Preview URL in wrangler output"; exit 1; }
echo "preview_url=${PREVIEW_URL}" >> "$GITHUB_OUTPUT"
echo "deployment_url=${DEPLOYMENT_URL}" >> "$GITHUB_OUTPUT"
- name: Post Worker Preview URL on PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKER_PREVIEW_URL: ${{ steps.deploy.outputs.preview_url }}
WORKER_PREVIEW_DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment_url }}
run: pnpm exec tsx bin/post-preview-url-comment/worker-preview.ts
continue-on-error: true