Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 19 additions & 2 deletions .github/actions/setup-go-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ inputs:
go-version-file:
description: Repository-relative go.mod or go.work file
required: false
save-build-cache:
description: >-
String flag ("true" or "false"): save the build cache after the job. A
job with River Pro modules on disk must only restore.
default: "true"
required: false
save-module-cache:
description: >-
String flag ("true" or "false"): allow a full-suite job to save module
Expand Down Expand Up @@ -57,8 +63,8 @@ runs:
GO_VERSION: ${{ steps.go.outputs.go-version }}
SOURCE_HASH: ${{ hashFiles('**/*.go', '**/*.sql', '**/testdata/**', 'public/**', 'Makefile', '.golangci.yaml', '.github/actions/setup-go-ci/**', '.github/workflows/*') }}
run: |
module_cache_prefix="go-mod-v1-${RUNNER_OS}-${RUNNER_ARCH}"
build_cache_prefix="go-build-v1-${RUNNER_OS}-${RUNNER_ARCH}-${ImageOS:-$RUNNER_OS}-${GO_VERSION}-${BUILD_CACHE_SCOPE}"
module_cache_prefix="go-mod-v2-${RUNNER_OS}-${RUNNER_ARCH}"
build_cache_prefix="go-build-v2-${RUNNER_OS}-${RUNNER_ARCH}-${ImageOS:-$RUNNER_OS}-${GO_VERSION}-${BUILD_CACHE_SCOPE}"

{
echo "RIVERUI_GO_BUILD_CACHE=$(go env GOCACHE)"
Expand Down Expand Up @@ -101,10 +107,21 @@ runs:
# Source hashes let changed jobs save their newly compiled artifacts rather
# than repeatedly rebuilding against an immutable dependency-only archive.
- name: Restore and save build cache
if: inputs.save-build-cache == 'true'
uses: actions/cache@v6
with:
path: ${{ env.RIVERUI_GO_BUILD_CACHE }}
key: ${{ steps.cache-config.outputs.build-prefix }}-${{ steps.cache-config.outputs.dependency-hash }}-${{ steps.cache-config.outputs.source-hash }}
restore-keys: |
${{ steps.cache-config.outputs.build-prefix }}-${{ steps.cache-config.outputs.dependency-hash }}-
${{ steps.cache-config.outputs.build-prefix }}-

- name: Restore build cache
if: inputs.save-build-cache != 'true'
uses: actions/cache/restore@v6
with:
path: ${{ env.RIVERUI_GO_BUILD_CACHE }}
key: ${{ steps.cache-config.outputs.build-prefix }}-${{ steps.cache-config.outputs.dependency-hash }}-${{ steps.cache-config.outputs.source-hash }}
restore-keys: |
${{ steps.cache-config.outputs.build-prefix }}-${{ steps.cache-config.outputs.dependency-hash }}-
${{ steps.cache-config.outputs.build-prefix }}-
91 changes: 77 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,74 @@ jobs:
- name: Install dependencies
run: go mod download

- name: Install River Pro UI dependencies
# This job saves caches, so it must never download River Pro modules.
# River Pro UI is tested in the River Pro UI job, which only restores.
- name: Install River CLI
run: go install github.com/riverqueue/river/cmd/river@$(go list -m -f '{{.Version}}' github.com/riverqueue/river)

- name: Create test DB
run: createdb river_test
env:
PGHOST: 127.0.0.1
PGUSER: postgres
PGPASSWORD: postgres

- name: Migrate test DB
run: river migrate-up --database-url "$TEST_DATABASE_URL" --line main

# ensure that there is a file in `dist` to prevent a lint error about
# it during CI when there is nothing there:
- name: touch file in dist
run: make fake_assets

- name: Test
run: make test/race SKIP_SUBMODULES=./riverproui

# Downloads River Pro modules with the River Pro credential, so it only
# restores caches. Saving would put River Pro modules into caches shared
# with other workflow runs.
riverproui:
name: River Pro UI build, test, and lint
runs-on: ubuntu-latest
timeout-minutes: 5
env:
GOLANGCI_LINT_VERSION: v2.13.1
GONOSUMDB: riverqueue.com/riverpro
GOPROXY: https://proxy.golang.org,https://u:${{ secrets.RIVERPRO_GO_MOD_CREDENTIAL }}@riverqueue.com/goproxy,direct
permissions:
contents: read

services:
postgres:
image: postgres:18
env:
GONOSUMDB: riverqueue.com/riverpro
GOPROXY: https://proxy.golang.org,https://u:${{ secrets.RIVERPRO_GO_MOD_CREDENTIAL }}@riverqueue.com/goproxy,direct
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout repository
uses: actions/checkout@v7

# Restore the build cache of the Go 1.26 and PostgreSQL 18 test job for
# warm open source dependencies, without saving it.
- name: Setup Go
uses: ./.github/actions/setup-go-ci
with:
build-cache-scope: postgres-18-race
go-version: "1.26"
save-build-cache: "false"

- name: Install River Pro UI dependencies
working-directory: ./riverproui
run: go mod download

- name: Install River Pro CLI
env:
GONOSUMDB: riverqueue.com/riverpro
GOPROXY: https://proxy.golang.org,https://u:${{ secrets.RIVERPRO_GO_MOD_CREDENTIAL }}@riverqueue.com/goproxy,direct
run: go install riverqueue.com/riverpro/cmd/riverpro@latest

- name: Create test DB
Expand All @@ -82,20 +139,26 @@ jobs:
riverpro migrate-up --database-url "$TEST_DATABASE_URL" --line main
riverpro migrate-up --database-url "$TEST_DATABASE_URL" --line pro

# ensure that there is a file in `dist` to prevent a lint error about
# it during CI when there is nothing there:
- name: touch file in dist
run: make fake_assets

- name: Test
run: make test/race
working-directory: ./riverproui
run: go test ./... -race -timeout 2m

- name: Install golangci-lint
uses: golangci/golangci-lint-action@v9
with:
install-only: true
skip-save-cache: true
version: ${{ env.GOLANGCI_LINT_VERSION }}

- name: Lint
working-directory: ./riverproui
run: golangci-lint run --fix

golangci:
name: Go lint
runs-on: ubuntu-latest
env:
GOLANGCI_LINT_VERSION: v2.13.1
GOPROXY: https://proxy.golang.org,https://u:${{ secrets.RIVERPRO_GO_MOD_CREDENTIAL }}@riverqueue.com/goproxy,direct
permissions:
contents: read
# allow read access to pull request. Use with `only-new-issues` option.
Expand Down Expand Up @@ -130,7 +193,7 @@ jobs:
version: ${{ env.GOLANGCI_LINT_VERSION }}

- name: Run lint
run: make lint
run: make lint SKIP_SUBMODULES=./riverproui

- name: Check module zips include only packaged files
run: make check/modzip
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ clean:
# consider the current module, so they must run separately for every module.
# Skip nested checkouts (like agent worktrees under `.claude`) and dependencies,
# whose modules would otherwise be linted and tested as if they were this one's.
submodules := $(shell find . \( -name .claude -o -name node_modules \) -prune -o -name 'go\.mod' -exec dirname {} \;)
# CI sets SKIP_SUBMODULES=./riverproui and checks River Pro UI in its own job.
submodules := $(filter-out $(SKIP_SUBMODULES),$(shell find . \( -name .claude -o -name node_modules \) -prune -o -name 'go\.mod' -exec dirname {} \;))

# `git archive` leaves out the untracked frontend build in `dist`. Set
# MODZIP_REQUIRE_FRONTEND=true after a release build (`npm exec vite build --
Expand Down
Loading