mirror of
https://github.com/usememos/memos.git
synced 2026-11-19 10:29:11 +01:00
chore(ci): share Go and web setup through composite actions
Add .github/actions/setup-go (Go version from go.mod) and .github/actions/setup-web (pnpm from web/package.json, Node 24, frozen install), and use them in every workflow that installed the toolchains by hand. Drop the per-workflow version env vars and the redundant pnpm store cache steps that duplicated setup-node's cache.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
name: Setup Go
|
||||
description: Install the Go version declared in go.mod and restore the module and build cache.
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
cache-dependency-path: go.sum
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Setup Web
|
||||
description: Install Node.js and the pnpm version pinned in web/package.json, then install web dependencies.
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.2.0
|
||||
with:
|
||||
package_json_file: web/package.json
|
||||
|
||||
# setup-node's pnpm cache covers the pnpm store, so no separate actions/cache step is needed.
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "24"
|
||||
cache: pnpm
|
||||
cache-dependency-path: web/pnpm-lock.yaml
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
working-directory: web
|
||||
run: pnpm install --frozen-lockfile
|
||||
@@ -10,15 +10,13 @@ on:
|
||||
- "go.sum"
|
||||
- "**.go"
|
||||
- ".golangci.yaml"
|
||||
- ".github/actions/setup-go/**"
|
||||
- ".github/workflows/backend-tests.yml"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.27.2"
|
||||
|
||||
jobs:
|
||||
static-checks:
|
||||
name: Static Checks
|
||||
@@ -26,17 +24,13 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
cache-dependency-path: go.sum
|
||||
uses: ./.github/actions/setup-go
|
||||
|
||||
- name: Verify go.mod is tidy
|
||||
run: |
|
||||
go mod tidy -go=${{ env.GO_VERSION }}
|
||||
go mod tidy
|
||||
git diff --exit-code
|
||||
|
||||
- name: Verify go fix
|
||||
@@ -58,13 +52,9 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
cache-dependency-path: go.sum
|
||||
uses: ./.github/actions/setup-go
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
|
||||
@@ -17,26 +17,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: pnpm/action-setup@v4.2.0
|
||||
with:
|
||||
version: 11.0.1
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "24"
|
||||
cache: pnpm
|
||||
cache-dependency-path: "web/pnpm-lock.yaml"
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
shell: bash
|
||||
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('web/pnpm-lock.yaml') }}
|
||||
restore-keys: ${{ runner.os }}-pnpm-store-
|
||||
- run: pnpm install --frozen-lockfile
|
||||
working-directory: web
|
||||
- name: Setup web
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Run frontend build
|
||||
run: pnpm release
|
||||
working-directory: web
|
||||
|
||||
@@ -7,15 +7,13 @@ on:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "web/**"
|
||||
- ".github/actions/setup-web/**"
|
||||
- ".github/workflows/frontend-tests.yml"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
NODE_VERSION: "24"
|
||||
PNPM_VERSION: "11.0.1"
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
@@ -24,21 +22,8 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.2.0
|
||||
with:
|
||||
version: ${{ env.PNPM_VERSION }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: pnpm
|
||||
cache-dependency-path: web/pnpm-lock.yaml
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: web
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Setup web
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Run lint
|
||||
working-directory: web
|
||||
@@ -55,21 +40,8 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.2.0
|
||||
with:
|
||||
version: ${{ env.PNPM_VERSION }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: pnpm
|
||||
cache-dependency-path: web/pnpm-lock.yaml
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: web
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Setup web
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Build frontend
|
||||
working-directory: web
|
||||
|
||||
@@ -16,9 +16,6 @@ permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.27.2"
|
||||
NODE_VERSION: "24"
|
||||
PNPM_VERSION: "11.0.1"
|
||||
ARTIFACT_RETENTION_DAYS: 60
|
||||
ARTIFACT_PREFIX: memos
|
||||
|
||||
@@ -73,33 +70,8 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.2.0
|
||||
with:
|
||||
version: ${{ env.PNPM_VERSION }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: pnpm
|
||||
cache-dependency-path: web/pnpm-lock.yaml
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
shell: bash
|
||||
run: echo "STORE_PATH=$(pnpm store path)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('web/pnpm-lock.yaml') }}
|
||||
restore-keys: ${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: web
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Setup web
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Build frontend release assets
|
||||
working-directory: web
|
||||
@@ -138,10 +110,7 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
uses: ./.github/actions/setup-go
|
||||
|
||||
- name: Download frontend artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
@@ -28,6 +28,7 @@ on:
|
||||
- "scripts/release_smoke_test.sh"
|
||||
- "scripts/release_version*"
|
||||
- "scripts/install*"
|
||||
- ".github/actions/**"
|
||||
- ".github/workflows/release.yml"
|
||||
- ".github/workflows/upgrade-smoke.yml"
|
||||
|
||||
@@ -38,11 +39,6 @@ concurrency:
|
||||
group: ${{ github.workflow }}-upgrade-smoke-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.27.2"
|
||||
NODE_VERSION: "24"
|
||||
PNPM_VERSION: "11.0.1"
|
||||
|
||||
jobs:
|
||||
migration-upgrade:
|
||||
name: Upgrade from previous stable (${{ matrix.driver }})
|
||||
@@ -56,11 +52,7 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
cache-dependency-path: go.sum
|
||||
uses: ./.github/actions/setup-go
|
||||
|
||||
- name: Test release versioning and installer
|
||||
run: go test -v ./scripts/...
|
||||
@@ -84,21 +76,8 @@ jobs:
|
||||
# tags, so it needs full history and tags.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.2.0
|
||||
with:
|
||||
version: ${{ env.PNPM_VERSION }}
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: pnpm
|
||||
cache-dependency-path: web/pnpm-lock.yaml
|
||||
|
||||
- name: Install frontend dependencies
|
||||
working-directory: web
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Setup web
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Run release smoke test
|
||||
run: ./scripts/release_smoke_test.sh
|
||||
|
||||
@@ -152,7 +152,9 @@ Black-box service tests live in `server/api/test/`, unit tests next to the code.
|
||||
- Docker excludes `.git`; pass `--build-arg VERSION="$(bash scripts/release_version.sh development-version)"` and
|
||||
`--build-arg COMMIT="$(git rev-parse HEAD)"` when building locally (build frontend assets first).
|
||||
|
||||
- Backend CI: Go 1.27.2, `go mod tidy -go=1.27.2`, `go fix -diff ./...`, golangci-lint v2.14.0 (including goimports), test groups
|
||||
- Workflows install toolchains through `.github/actions/setup-go` (Go version from `go.mod`) and `.github/actions/setup-web`
|
||||
(pnpm from `web/package.json`, Node 24, `pnpm install`); change versions there, not per workflow.
|
||||
- Backend CI: Go 1.27.2, `go mod tidy`, `go fix -diff ./...`, golangci-lint v2.14.0 (including goimports), test groups
|
||||
`store`, `server`, `internal`, `other` (`cmd`, `core`, `markdown`, `filter`, `provider`, `proto`).
|
||||
- Frontend CI: Node 24, pnpm 11.0.1, `pnpm lint`, `pnpm test`, `pnpm build`.
|
||||
- Proto CI: `buf lint` and `buf format` check.
|
||||
|
||||
Reference in New Issue
Block a user