Skip to content
Draft
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
68 changes: 67 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,67 @@ jobs:
- name: Test
run: make test/race SKIP_SUBMODULES=./riverproui

# A release commit's riverproui requires a riverui version that's published
# only once the commit is tagged. Package it from this commit into a module
# proxy for the River Pro UI job. Packaging runs npm, so this job has no
# secrets.
riverui_candidate:
name: Package riverui candidate
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
unpublished: ${{ steps.check.outputs.unpublished }}
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v7
with:
cache: false
go-version-file: packager/go.mod

# The script makes the same check. It's repeated here so that ordinary
# commits skip Node.js.
- name: Check for an unpublished riverui requirement
id: check
run: |
version="$(awk '$1 == "riverqueue.com/riverui" { print $2 }' riverproui/go.mod)"
GOPROXY=direct GOSUMDB=off go list -m "riverqueue.com/riverui@$version" || echo "unpublished=true" >> "$GITHUB_OUTPUT"

- name: Install Node.js
if: steps.check.outputs.unpublished == 'true'
uses: actions/setup-node@v7
with:
check-latest: true
node-version: "24"

- name: Package riverui
if: steps.check.outputs.unpublished == 'true'
run: ./packager/build-candidate-proxy.sh "$RUNNER_TEMP/candidate-proxy"

- name: Upload riverui candidate
if: steps.check.outputs.unpublished == 'true'
uses: actions/upload-artifact@v7
with:
if-no-files-found: error
name: riverui-candidate
path: ${{ runner.temp }}/candidate-proxy

# 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
needs: riverui_candidate
# Run even if the candidate job failed. A skipped job would satisfy this
# required check; without the candidate, a release commit fails below.
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
timeout-minutes: 5
env:
Expand Down Expand Up @@ -120,9 +176,19 @@ jobs:
go-version: "1.26"
save-build-cache: "false"

- name: Download riverui candidate
if: needs.riverui_candidate.outputs.unpublished == 'true'
uses: actions/download-artifact@v8
with:
name: riverui-candidate
path: ${{ runner.temp }}/candidate-proxy

# The download verifies the candidate against riverproui's go.sum before
# any of its code builds, so a go.sum that doesn't match this commit's
# riverui fails here. Later steps use the downloaded modules.
- name: Install River Pro UI dependencies
working-directory: ./riverproui
run: go mod download
run: GOPROXY="file://$RUNNER_TEMP/candidate-proxy,$GOPROXY" go mod download

- name: Install River Pro CLI
run: go install riverqueue.com/riverpro/cmd/riverpro@latest
Expand Down
78 changes: 73 additions & 5 deletions .github/workflows/docker-riverproui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,68 @@ env:
ECR_REGION: us-east-2

jobs:
# A release commit's riverproui requires a riverui version that's published
# only once the commit is tagged. Package it from this commit into a module
# proxy for the image build, which passes it to Dockerfile.pro. Packaging
# runs npm, so this job has no secrets.
riverui-candidate:
name: Package riverui candidate
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
unpublished: ${{ steps.check.outputs.unpublished }}
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v7.0.1
with:
persist-credentials: false
ref: ${{ inputs.ref || github.ref }}

- name: Setup Go
uses: actions/setup-go@v7
with:
cache: false
go-version-file: packager/go.mod

# The script makes the same check. It's repeated here so that ordinary
# commits skip Node.js.
- name: Check for an unpublished riverui requirement
id: check
run: |
version="$(awk '$1 == "riverqueue.com/riverui" { print $2 }' riverproui/go.mod)"
GOPROXY=direct GOSUMDB=off go list -m "riverqueue.com/riverui@$version" || echo "unpublished=true" >> "$GITHUB_OUTPUT"

- name: Install Node.js
if: steps.check.outputs.unpublished == 'true'
uses: actions/setup-node@v7
with:
check-latest: true
node-version: "24"

- name: Package riverui
if: steps.check.outputs.unpublished == 'true'
run: ./packager/build-candidate-proxy.sh "$RUNNER_TEMP/candidate-proxy"

- name: Upload riverui candidate
if: steps.check.outputs.unpublished == 'true'
uses: actions/upload-artifact@v7
with:
if-no-files-found: error
name: riverui-candidate
path: ${{ runner.temp }}/candidate-proxy

build-riverproui:
name: "Build image: riverproui (${{ matrix.docker_platform }})"
needs: riverui-candidate
runs-on: ${{ matrix.runner }}
# Skip this job when manually dispatched with verify_only=true
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.verify_only) }}
# Skip this job when manually dispatched with verify_only=true. Otherwise
# run even if the candidate job failed: a skipped job would leave this
# required check unreported, and without the candidate, a release commit
# fails in the image build.
if: ${{ !cancelled() && !(github.event_name == 'workflow_dispatch' && inputs.verify_only) }}
env:
ECR_ACCOUNT_ID: ${{ secrets.ECR_CACHE_AWS_ACCOUNT_ID }}
ECR_ROLE_ARN: ${{ secrets.ECR_CACHE_ROLE_ARN }}
Expand All @@ -58,6 +115,13 @@ jobs:
with:
ref: ${{ inputs.ref || github.ref }}

- name: Download riverui candidate
if: needs.riverui-candidate.outputs.unpublished == 'true'
uses: actions/download-artifact@v8
with:
name: riverui-candidate
path: ${{ runner.temp }}/candidate-proxy

- name: Build metadata
id: build_metadata
run: |
Expand Down Expand Up @@ -100,6 +164,7 @@ jobs:
with:
context: .
file: Dockerfile.pro
build-contexts: ${{ needs.riverui-candidate.outputs.unpublished == 'true' && format('candidate-proxy={0}/candidate-proxy', runner.temp) || '' }}
build-args: |
BUILD_VERSION=${{ steps.build_metadata.outputs.version }}
BUILD_REVISION=${{ steps.build_metadata.outputs.revision }}
Expand Down Expand Up @@ -134,8 +199,10 @@ jobs:
runs-on: ubuntu-latest
needs:
- build-riverproui
# Skip this job when manually dispatched with verify_only=true
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.verify_only) }}
# Skip this job when manually dispatched with verify_only=true. A failed
# candidate job would otherwise skip this job even after the image builds
# pass, so check the image builds' result directly.
if: ${{ !cancelled() && needs.build-riverproui.result == 'success' && !(github.event_name == 'workflow_dispatch' && inputs.verify_only) }}
permissions:
contents: read
id-token: write
Expand Down Expand Up @@ -374,7 +441,8 @@ jobs:
# Only run on release tag events (refs/tags/riverproui/vX.Y.Z),
# or when manually forced via workflow_dispatch: force_prefetch=true.
# For workflow_dispatch, inputs.ref should be in the form 'riverproui/vX.Y.Z'.
if: startsWith(github.ref, 'refs/tags/riverproui/v') || (github.event_name == 'workflow_dispatch' && (startsWith(inputs.ref, 'riverproui/v') || inputs.force_prefetch))
# As above, this depends on the merge job's result, not the candidate job's.
if: ${{ !cancelled() && needs.merge-riverproui.result == 'success' && (startsWith(github.ref, 'refs/tags/riverproui/v') || (github.event_name == 'workflow_dispatch' && (startsWith(inputs.ref, 'riverproui/v') || inputs.force_prefetch))) }}
permissions:
contents: read
steps:
Expand Down
10 changes: 8 additions & 2 deletions Dockerfile.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# syntax=docker/dockerfile:1

# A release commit's riverproui requires a riverui version that's published
# only once the commit is tagged. CI packages it with
# packager/build-candidate-proxy.sh and passes it in place of this empty stage.
FROM scratch AS candidate-proxy

FROM node:24.21.0-alpine@sha256:ebfe2f90462722a7a4de65e91990e97fe0d401c70e0e762c5b53302f905ec1c1 AS build-ui
WORKDIR /app
COPY .npmrc package.json package-lock.json ./
Expand All @@ -22,8 +27,9 @@ RUN go mod download
# Download riverproui module dependencies with secret
COPY riverproui/go.mod riverproui/go.sum ./riverproui/
WORKDIR /go/src/riverui/riverproui
RUN --mount=type=secret,id=riverpro_credential,dst=/etc/secrets/riverpro_credential \
sh -c 'GOPROXY=https://proxy.golang.org,https://u:$(cat /etc/secrets/riverpro_credential)@riverqueue.com/goproxy,direct \
RUN --mount=type=bind,from=candidate-proxy,target=/candidate-proxy \
--mount=type=secret,id=riverpro_credential,dst=/etc/secrets/riverpro_credential \
sh -c 'GOPROXY=file:///candidate-proxy,https://proxy.golang.org,https://u:$(cat /etc/secrets/riverpro_credential)@riverqueue.com/goproxy,direct \
go mod download'

# Return to main directory and copy Go files without copying the ui dir:
Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ check/modzip: ## Check that released Go module zips include only Go source, modu
go run . -check $(if $(filter true,$(MODZIP_REQUIRE_FRONTEND)),-require-frontend) -dir "$$export_dir"; \
go run . -check -dir "$$export_dir/riverproui"

# Where the release targets package the riverui version that riverproui
# requires, if it isn't published yet. The script explains why.
CANDIDATE_PROXY ?= $(abspath $(or $(TMPDIR),/tmp)/riverui-candidate-proxy)

# riverproui's riverui go.sum lines come from a `go mod tidy` against the
# candidate proxy, after dropping the old ones so that a rerun after a change
# replaces them.
.PHONY: release/prepare
release/prepare: ## Set riverproui's riverui requirement to $VERSION and write its go.sum
@test -n "$(VERSION)" || { echo "VERSION is required, like VERSION=v1.2.3" >&2; exit 1; }
cd riverproui && go mod edit -require=riverqueue.com/riverui@$(VERSION)
cd riverproui && grep -v '^riverqueue\.com/riverui ' go.sum > go.sum.new && mv go.sum.new go.sum
./packager/build-candidate-proxy.sh "$(CANDIDATE_PROXY)" go mod tidy

# Run this before pushing release tags. CI makes the same check in two jobs, so
# that the one that builds the frontend has no secrets.
.PHONY: release/verify
release/verify: ## Check riverproui's go.sum by building it against the riverui in this commit
@./packager/build-candidate-proxy.sh "$(CANDIDATE_PROXY)" go build ./...

.PHONY: dev
dev: fake_assets
npm run dev
Expand Down
57 changes: 16 additions & 41 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,63 +79,38 @@ $ npm run build

## Releasing a new version

1. Fetch changes to the repo and any new tags. Export `VERSION` by incrementing the last tag:
The `riverui` module and the `riverproui` submodule release from one commit. In that commit `riverproui`'s `go.mod` requires the `riverui` version being released, and its `go.sum` holds the hash of a `riverui` zip that's published only once the commit is tagged. Module zips are reproducible, so `make release/prepare` builds the frontend and packages `riverui` locally the way the release workflow does, and writes the hash from that zip. CI packages `riverui` again from the pull request's commit and downloads `riverproui`'s dependencies through it, so a `go.sum` that doesn't match fails with a `checksum mismatch`. `make release/verify` makes the same check locally.

Building the frontend needs the Node.js version that `package.json` requires.

1. Fetch changes to the repo and any new tags. Export `VERSION` by incrementing the last tag, and start a branch:

```shell
git checkout master && git pull --rebase
export VERSION=v0.x.y
git checkout -b $USER-$VERSION
```

2. Prepare a PR with the changes, updating `CHANGELOG.md` with any necessary additions at the same time. Have it reviewed and merged.

3. Upon merge, pull down the changes, tag the main riverui module with the new version, and push the new tag:
2. Update `CHANGELOG.md`. Make sure the `replace` directive for `riverui` in `./riverproui/go.mod` is commented out, because it prevents `riverproui` from being `go install`-able. Then set `riverproui`'s `riverui` requirement to `$VERSION` and write its `go.sum`:

```shell
git pull origin master
git tag $VERSION
git push --tags
make release/prepare
```

4. The build will cut a new release and create binaries automatically, but it won't have a good release message. Go the [release list](https://github.com/riverqueue/riverui/releases), find `$VERSION` and change the description to the release content in `CHANGELOG.md` (again, the build will have to finish first).

### Releasing riverproui
The `riverui` zip includes `CHANGELOG.md`, so run this after editing the changelog, and again after any later change to `riverui`'s Go code, frontend, or changelog. Until `$VERSION` is published, `go mod tidy` in `./riverproui` (and `make tidy`) can't find it.

The `riverproui` submodule depends on the top level `riverui` module and in development it is customary to leave a `replace` directive in its `go.mod` so that it can be developed against the live local version. However, this `replace` directive makes it incompatible with `go install ...@latest`.
3. Prepare a PR with the changes. Have it reviewed and merged. If changes to `riverui` merge to `master` after the PR's CI ran, its result is out of date, so wait for CI on `master` before tagging.

As such, we must use a two-phase release for these modules:

1. Release `riverui` with an initial version (i.e. all the steps above).

2. Comment out `replace` directives to riverui `./riverproui/go.mod`. These were probably needed for developing the new feature, but need to be removed because they prevent the module from being `go install`-able.

3. From `./riverproui`, `go get` to upgrade to the main package versions were just released (make sure you're getting `$VERSION` and not thwarted by shenanigans in Go's module proxy):

```shell
cd ./riverproui
go get -u riverqueue.com/riverui@$VERSION
```

4. Run `go mod tidy`:

```shell
go mod tidy
```

5. Start a new branch and commit changes:

``` shell
git checkout -b $USER-$VERSION-pro
```

6. Prepare a PR with the changes. Have it reviewed and merged.

7. Pull the changes back down, add a tag for `riverproui/$VERSION`, and push it to GitHub:
4. Upon merge, pull down the changes, check `riverproui`'s `go.sum` against the merged commit, then tag both modules and push the tags:

```shell
git pull origin master
make release/verify
git tag $VERSION
git tag riverproui/$VERSION -m "release riverproui/$VERSION"
git push --tags
git push origin $VERSION riverproui/$VERSION
```

The main `$VERSION` tag and `riverproui/$VERSION` will point to different commits, and although a little odd, is tolerable.
Run `make release/verify` with no uncommitted changes to tracked files, because it packages them too. If it fails with a `checksum mismatch`, `riverui` changed after `make release/prepare`: don't tag, and rerun `make release/prepare` with the same version in a new PR.

5. The build will cut a new release and create binaries automatically, but it won't have a good release message. Go the [release list](https://github.com/riverqueue/riverui/releases), find `$VERSION` and change the description to the release content in `CHANGELOG.md` (again, the build will have to finish first).
Loading
Loading