Fold lint into build job to avoid duplicate dependency install
Lint, build, test and deploy / build (push) Successful in 1m39s
Lint, build, test and deploy / test (push) Successful in 5s
Lint, build, test and deploy / deploy (push) Successful in 3s

This commit is contained in:
Leon Xu committed 2026-11-29 14:53:35 -08:00
1 parent c049512b92
commit b0c62de391
2 files changed
+17 -31

No files matched your search

+6 -22
View File
@@ -6,28 +6,9 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
# ------------------------------------------------------------ style checks
# Runs in parallel with build; both must pass before the site is tested.
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint Markdown
run: npx markdownlint-cli2
# ------------------------------------------------------------ build # ------------------------------------------------------------ build
# Produces the static site once and shares it as an artifact so the # Single dependency install serves both the lint check and the build.
# test and deploy stages never rebuild. # Lint failures fail this job, which gates test and deploy.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -45,6 +26,9 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
- name: Lint Markdown
run: npx markdownlint-cli2
- name: Build site - name: Build site
run: hexo generate run: hexo generate
@@ -69,7 +53,7 @@ jobs:
# Validates the built site locally. Never touches production. Deploy # Validates the built site locally. Never touches production. Deploy
# physically cannot run unless this job passes. # physically cannot run unless this job passes.
test: test:
needs: [lint, build] needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Download site artifact - name: Download site artifact
+11 -9
View File
@@ -87,19 +87,21 @@ git commit -m "new post"
git push origin master git push origin master
``` ```
The [deploy workflow](.gitea/workflows/deploy.yml) runs four gated stages: The [deploy workflow](.gitea/workflows/deploy.yml) runs three gated stages:
1. **lint** — checks all Markdown in `source/` and `scaffolds/` with 1. **build** — checks out the repo, sets up Node 22, and runs a single
`markdownlint-cli2` (house style codified in `.markdownlint-cli2.jsonc`) `yarn install --frozen-lockfile` that serves both jobs of this stage:
2. **build** — checks out the repo, sets up Node 22, runs `yarn install first it lints all Markdown in `source/` and `scaffolds/` with
--frozen-lockfile` and `hexo generate`, optimizes every PNG/JPEG in the `markdownlint-cli2` (house style codified in `.markdownlint-cli2.jsonc`;
built output with pngquant/oxipng/jpegoptim (~58% smaller images, originals lint failures fail the stage), then runs `hexo generate` and optimizes
in `source/` untouched), then uploads the site as a workflow artifact every PNG/JPEG in the built output with pngquant/jpegoptim (~56% smaller
3. **test** — validates the built artifact without touching production: images, originals in `source/` untouched). The site is uploaded as a
workflow artifact
2. **test** — validates the built artifact without touching production:
structural checks (index, theme assets, file count) plus a serving smoke structural checks (index, theme assets, file count) plus a serving smoke
test that requests the homepage, a real post page, and the stylesheet test that requests the homepage, a real post page, and the stylesheet
over a local HTTP server over a local HTTP server
4. **deploy** — only runs if lint, build, and test all passed; downloads the 3. **deploy** — only runs if build and test both passed; downloads the
tested artifact, writes an SSH deploy key from the `DEPLOY_KEY` secret, tested artifact, writes an SSH deploy key from the `DEPLOY_KEY` secret,
and `rsync -avz` over SSH (key-based only; the server rejects password and `rsync -avz` over SSH (key-based only; the server rejects password
auth) to `root@69.164.253.99:/www/wwwroot/leonxu260.dev/` auth) to `root@69.164.253.99:/www/wwwroot/leonxu260.dev/`