Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore(ci): share Go and web setup through composite actions
boojackdcf08b5911a4
diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.ymlnew file mode 100644index 000000000..7ef241c8d--- /dev/null+++ b/.github/actions/setup-go/action.yml@@ -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.sumdiff --git a/.github/actions/setup-web/action.yml b/.github/actions/setup-web/action.ymlnew file mode 100644index 000000000..24b25bd95--- /dev/null+++ b/.github/actions/setup-web/action.yml@@ -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/[email protected]+ 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-lockfilediff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.ymlindex 53e59290c..ff2fb0f60 100644--- a/.github/workflows/backend-tests.yml+++ b/.github/workflows/backend-tests.yml@@ -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 codeuses: 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 tidyrun: |- go mod tidy -go=${{ env.GO_VERSION }}+ go mod tidygit diff --exit-code- name: Verify go fix@@ -58,13 +52,9 @@ jobs:steps:- name: Checkout codeuses: 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 testsrun: |diff --git a/.github/workflows/build-canary-image.yml b/.github/workflows/build-canary-image.ymlindex 108d7fb39..8bbf4ddfb 100644--- a/.github/workflows/build-canary-image.yml+++ b/.github/workflows/build-canary-image.yml@@ -17,26 +17,9 @@ jobs:steps:- uses: actions/checkout@v6- - uses: pnpm/[email protected]- 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 buildrun: pnpm releaseworking-directory: webdiff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.ymlindex d616c6224..4d302e07e 100644--- a/.github/workflows/frontend-tests.yml+++ b/.github/workflows/frontend-tests.yml@@ -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 codeuses: actions/checkout@v6- - name: Setup pnpm- uses: pnpm/[email protected]- 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 lintworking-directory: web@@ -55,21 +40,8 @@ jobs:- name: Checkout codeuses: actions/checkout@v6- - name: Setup pnpm- uses: pnpm/[email protected]- 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 frontendworking-directory: webdiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 8919650db..66a055083 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -16,9 +16,6 @@ permissions:contents: readenv:- GO_VERSION: "1.27.2"- NODE_VERSION: "24"- PNPM_VERSION: "11.0.1"ARTIFACT_RETENTION_DAYS: 60ARTIFACT_PREFIX: memos@@ -73,33 +70,8 @@ jobs:- name: Checkout codeuses: actions/checkout@v6- - name: Setup pnpm- uses: pnpm/[email protected]- 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 assetsworking-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 artifactsuses: actions/download-artifact@v4diff --git a/.github/workflows/upgrade-smoke.yml b/.github/workflows/upgrade-smoke.ymlindex 5e41e2f72..9ec68df3f 100644--- a/.github/workflows/upgrade-smoke.yml+++ b/.github/workflows/upgrade-smoke.yml@@ -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 installerrun: 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/[email protected]- 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 testrun: ./scripts/release_smoke_test.shdiff --git a/AGENTS.md b/AGENTS.mdindex da12b67a7..ae12e6ad1 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -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.