Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: yarn to bun #4083

Merged
merged 20 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1a572b7
switch to bun
mastercactapus Sep 23, 2024
881ca27
mark lockfile as binary
mastercactapus Sep 23, 2024
a3bcb70
add target to regen lockfile
mastercactapus Sep 23, 2024
d2c18a3
Merge branch 'master' into yarn-to-bun
mastercactapus Sep 24, 2024
768a632
Ignore lockb files in .labelignore
mastercactapus Sep 24, 2024
52533da
Merge branch 'master' into yarn-to-bun
mastercactapus Sep 25, 2024
81e33cd
Merge branch 'master' into yarn-to-bun
mastercactapus Nov 22, 2024
7d8b8b1
build: update Makefile to use bun for dependency management and code …
mastercactapus Nov 22, 2024
0c4461f
Merge branch 'master' into yarn-to-bun
mastercactapus Nov 22, 2024
de0432b
update lockfile
mastercactapus Nov 22, 2024
ceb9c43
Merge branch 'master' into yarn-to-bun
mastercactapus Feb 27, 2025
ca7705c
update bun
mastercactapus Feb 27, 2025
4308eab
refactor: remove .gitattributes and update lock file naming convention
mastercactapus Feb 27, 2025
0a9f760
Merge branch 'master' into yarn-to-bun
mastercactapus Feb 28, 2025
d15c2e2
feat: add architecture check script and update Makefile to use it
mastercactapus Feb 28, 2025
0e9fd25
feat: add check_arch target to Makefile for architecture validation
mastercactapus Feb 28, 2025
eb87df8
feat: enhance arch-check script with additional warning for Go version
mastercactapus Feb 28, 2025
8661950
chore: update Go version to 1.24 and improve caching in GitHub Action…
mastercactapus Feb 28, 2025
9374936
refactor: remove playwright version check from codecheck script
mastercactapus Feb 28, 2025
5e25ec0
chore: remove unused Makefile target and update dependencies in templ…
mastercactapus Feb 28, 2025
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
18 changes: 8 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/cache@v3
with:
node-version: '22'
cache: 'yarn'
- run: make yarn
- run: 'echo "nodeLinker: node-modules" >>.yarnrc.yml'
- run: yarn install
key: key
path: ~/.bun/install/cache
- run: make node_modules
- uses: reviewdog/action-eslint@v1
with:
reporter: github-pr-review
level: warning
fail_on_error: true
fail_level: warning
- uses: reviewdog/action-stylelint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: warning
fail_on_error: true
fail_level: warning
- name: tsc
run: yarn run check
run: ./bin/tools/bun run check
17 changes: 4 additions & 13 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import type { StorybookConfig } from '@storybook/react-vite'

import { join, dirname } from 'path'

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')))
}
const config: StorybookConfig = {
staticDirs: ['./static'],
stories: ['../web/src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-interactions'),
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: {
name: getAbsolutePath('@storybook/react-vite'),
name: '@storybook/react-vite',
options: {},
},
docs: {
Expand Down
934 changes: 0 additions & 934 deletions .yarn/releases/yarn-4.5.3.cjs

This file was deleted.

17 changes: 0 additions & 17 deletions .yarnrc.yml

This file was deleted.

103 changes: 42 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ SWO_DB_URL_NEXT = $(shell go run ./devtools/scripts/db-url "$(DB_URL)" "$(SWO_DB

LOG_DIR=
GOPATH:=$(shell go env GOPATH)
YARN_VERSION=4.5.3
PG_VERSION=13

# add all files except those under web/src/build and web/src/cypress
NODE_DEPS=.pnp.cjs .yarnrc.yml .gitrev $(shell find web/src -path web/src/build -prune -o -path web/src/cypress -prune -o -type f -print) web/src/app/editor/expr-parser.ts
NODE_DEPS=.gitrev $(shell find web/src -path web/src/build -prune -o -path web/src/cypress -prune -o -type f -print) web/src/app/editor/expr-parser.ts node_modules

# Use sha256sum on linux and shasum -a 256 on mac
SHA_CMD := $(shell if [ -x "$(shell command -v sha256sum 2>/dev/null)" ]; then echo "sha256sum"; else echo "shasum -a 256"; fi)
Expand All @@ -35,7 +34,7 @@ export CY_ACTION = open
export CY_BROWSER = chrome

export CGO_ENABLED = 0
export PATH := $(PWD)/bin:$(PATH)
export PATH := $(PWD)/bin:$(PWD)/bin/tools:$(PATH)
export GOOS = $(shell go env GOOS)
export GOALERT_DB_URL_NEXT = $(DB_URL_NEXT)

Expand All @@ -62,6 +61,10 @@ CONTAINER_TOOL ?= docker

all: test

.PHONY: check_arch
check_arch:
./devtools/scripts/arch-check.sh

release: container-demo container-goalert bin/goalert-linux-amd64.tgz bin/goalert-linux-arm.tgz bin/goalert-linux-arm64.tgz bin/goalert-darwin-amd64.tgz bin/goalert-windows-amd64.zip ## Build all release artifacts

Makefile.binaries.mk: devtools/genmake/*
Expand All @@ -80,6 +83,16 @@ $(BIN_DIR)/tools/mailpit: mailpit.version
$(BIN_DIR)/tools/sqlc: sqlc.version
go run ./devtools/gettool -t sqlc -v $(shell cat sqlc.version) -o $@

$(BIN_DIR)/tools/bun: bun.version
go run ./devtools/gettool -t bun -v $(shell cat bun.version) -o $@

bun.lock: $(BIN_DIR)/tools/bun
$(BIN_DIR)/tools/bun install

node_modules: $(BIN_DIR)/tools/bun package.json bun.lock
$(BIN_DIR)/tools/bun install
touch "$@"

$(BIN_DIR)/tools/prometheus: prometheus.version
go run ./devtools/gettool -t prometheus -v $(shell cat prometheus.version) -o $@

Expand Down Expand Up @@ -114,9 +127,8 @@ goalert-client.key: system.ca.pem plugin.ca.key plugin.ca.pem
goalert-client.ca.pem: system.ca.pem plugin.ca.key plugin.ca.pem
go run ./cmd/goalert gen-cert client

cypress: bin/goalert.cover bin/psql-lite bin/pgmocktime $(NODE_DEPS) web/src/schema.d.ts $(BIN_DIR)/build/integration/cypress/plugins/index.js
$(MAKE) ensure-yarn
yarn cypress install
cypress: bin/goalert.cover bin/psql-lite bin/pgmocktime $(NODE_DEPS) web/src/schema.d.ts $(BIN_DIR)/build/integration/cypress/plugins/index.js node_modules
$(BIN_DIR)/tools/bun run cypress install

cy-wide: cypress ## Start cypress tests in desktop mode with dev build in UI mode
GOALERT_VERSION=$(GIT_VERSION) CONTAINER_TOOL=$(CONTAINER_TOOL) PG_VERSION=$(PG_VERSION) CYPRESS_viewportWidth=1440 CYPRESS_viewportHeight=900 go run ./devtools/runproc -f Procfile.cypress
Expand Down Expand Up @@ -144,11 +156,7 @@ web/src/schema.d.ts: graphql2/schema.graphql graphql2/graph/*.graphqls web/src/g
help: ## Show all valid options
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

start: bin/goalert bin/mockoidc $(NODE_DEPS) web/src/schema.d.ts $(BIN_DIR)/tools/prometheus $(BIN_DIR)/tools/mailpit ## Start the developer version of the application
@if [ -d ".vscode" ]; then \
echo "Detected .vscode directory, running 'vscode' target"; \
$(MAKE) vscode; \
fi
start: check_arch bin/goalert bin/mockoidc $(NODE_DEPS) web/src/schema.d.ts $(BIN_DIR)/tools/prometheus $(BIN_DIR)/tools/mailpit ## Start the developer version of the application
go run ./devtools/waitfor -timeout 1s "$(DB_URL)" || make postgres
GOALERT_VERSION=$(GIT_VERSION) GOALERT_STRICT_EXPERIMENTAL=1 go run ./devtools/runproc -f Procfile -l Procfile.local

Expand Down Expand Up @@ -186,8 +194,7 @@ start-integration: web/src/build/static/app.js bin/goalert bin/psql-lite bin/wai
GOALERT_DB_URL="$(INT_DB_URL)" ./bin/runproc -f Procfile.integration

jest: $(NODE_DEPS)
$(MAKE) ensure-yarn
yarn run jest $(JEST_ARGS)
$(BIN_DIR)/tools/bun run jest $(JEST_ARGS)

test: $(NODE_DEPS) jest $(BIN_DIR)/tools/mailpit ## Run all unit tests
rm -rf $(PWD)/test/coverage/unit
Expand All @@ -197,28 +204,10 @@ test: $(NODE_DEPS) jest $(BIN_DIR)/tools/mailpit ## Run all unit tests
check: check-go check-js ## Run all lint checks
./devtools/ci/tasks/scripts/codecheck.sh

.yarnrc.yml: package.json
$(MAKE) yarn
touch "$@"

.yarn/releases/yarn-$(YARN_VERSION).cjs:
yarn set version $(YARN_VERSION) || $(MAKE) yarn

ensure-yarn: # Yarn ensures the correct version of yarn is installed
@echo "Checking yarn version..."
@yarn --version | grep -q -F "$(YARN_VERSION)" || $(MAKE) yarn
$(MAKE) .yarn/releases/yarn-$(YARN_VERSION).cjs

yarn:
corepack enable
corepack prepare yarn@$(YARN_VERSION) --activate

check-js: generate $(NODE_DEPS)
$(MAKE) ensure-yarn
yarn install
yarn run fmt
yarn run lint
yarn run check
$(BIN_DIR)/tools/bun run fmt
$(BIN_DIR)/tools/bun run lint
$(BIN_DIR)/tools/bun run check

check-go: generate $(BIN_DIR)/tools/golangci-lint
@go mod tidy
Expand Down Expand Up @@ -250,26 +239,24 @@ test-smoke: smoketest
test-unit: test

test-components: $(NODE_DEPS) bin/waitfor
yarn build-storybook --test --quiet 2>/dev/null
yarn playwright install chromium
yarn concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"yarn http-server storybook-static -a 127.0.0.1 --port 6008 --silent" \
"./bin/waitfor tcp://localhost:6008 && yarn test-storybook --ci --url http://127.0.0.1:6008 --maxWorkers 2"
$(BIN_DIR)/tools/bun run build-storybook --test --quiet 2>/dev/null
$(BIN_DIR)/tools/bun run playwright install chromium
$(BIN_DIR)/tools/bun run concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"$(BIN_DIR)/tools/bun run http-server storybook-static -a 127.0.0.1 --port 6008 --silent" \
"./bin/waitfor tcp://localhost:6008 && $(BIN_DIR)/tools/bun run test-storybook --ci --url http://127.0.0.1:6008 --maxWorkers 2"

storybook: ensure-yarn $(NODE_DEPS) # Start the Storybook UI
yarn storybook
storybook: $(NODE_DEPS) # Start the Storybook UI
$(BIN_DIR)/tools/bun run storybook

playwright-run: $(NODE_DEPS) bin/mockoidc web/src/build/static/app.js bin/goalert.cover web/src/schema.d.ts $(BIN_DIR)/tools/prometheus $(BIN_DIR)/tools/mailpit reset-integration ## Start playwright tests in headless mode
$(MAKE) ensure-yarn
rm -rf test/coverage/integration/playwright
mkdir -p test/coverage/integration/playwright
yarn playwright install chromium
GOCOVERDIR=test/coverage/integration/playwright yarn playwright test
$(BIN_DIR)/tools/bun run playwright install chromium
GOCOVERDIR=test/coverage/integration/playwright $(BIN_DIR)/tools/bun run playwright test

playwright-ui: $(NODE_DEPS) bin/mockoidc web/src/build/static/app.js bin/goalert web/src/schema.d.ts $(BIN_DIR)/tools/prometheus $(BIN_DIR)/tools/mailpit reset-integration ## Start the Playwright UI
$(MAKE) ensure-yarn
yarn playwright install chromium
yarn playwright test --ui
playwright-ui: $(NODE_DEPS) bin/mockoidc web/src/build/static/app.js bin/goalert web/src/schema.d.ts $(BIN_DIR)/tools/prometheus reset-integration $(BIN_DIR)/tools/mailpit ## Start the Playwright UI
$(BIN_DIR)/tools/bun run playwright install chromium
$(BIN_DIR)/tools/bun run playwright test --ui

smoketest: $(BIN_DIR)/tools/mailpit
rm -rf test/coverage/smoke
Expand Down Expand Up @@ -298,27 +285,24 @@ tools:
go get -u golang.org/x/tools/cmd/goimports
go get -u golang.org/x/tools/cmd/stringer

.pnp.cjs: yarn.lock Makefile package.json .yarnrc.yml
$(MAKE) ensure-yarn
yarn install && touch "$@"


web/src/app/editor/expr-parser.ts: web/src/app/editor/expr.grammar .pnp.cjs

web/src/app/editor/expr-parser.ts: web/src/app/editor/expr.grammar node_modules
# we need to use .tmp.ts as the extension because lezer-generator will append .ts to the output file
yarn run lezer-generator $< --noTerms --typeScript -o $@.tmp.ts
yarn run prettier -l --write $@.tmp.ts
bin/tools/bun run lezer-generator $< --noTerms --typeScript -o $@.tmp.ts
bin/tools/bun run prettier -l --write $@.tmp.ts
cat $@.tmp.ts | sed "s/You probably shouldn't edit it./DO NOT EDIT/" >$@
rm $@.tmp.ts

web/src/build/static/explore.js: web/src/build/static/app.js
web/src/build/static/app.js: $(NODE_DEPS)
$(MAKE) ensure-yarn
rm -rf web/src/build/static
mkdir -p web/src/build/static
cp -f web/src/app/public/icons/favicon-* web/src/app/public/logos/lightmode_* web/src/app/public/logos/darkmode_* web/src/build/static/
# used for email templates
cp web/src/app/public/logos/goalert-alt-logo.png web/src/build/static/
GOALERT_VERSION=$(GIT_VERSION) yarn run esbuild --prod
GOALERT_VERSION=$(GIT_VERSION) $(BIN_DIR)/tools/bun run esbuild --prod
touch "$@"

notification/desttype_string.go: notification/desttype.go
Expand Down Expand Up @@ -361,11 +345,8 @@ new-migration:
@echo "-- +migrate Up\n\n\n-- +migrate Down\n" >migrate/migrations/$(shell date +%Y%m%d%H%M%S)-$(NAME).sql
@echo "Created: migrate/migrations/$(shell date +%Y%m%d%H%M%S)-$(NAME).sql"

vscode: $(NODE_DEPS)
yarn dlx @yarnpkg/sdks vscode

upgrade-js: ## Interactively upgrade javascript packages
yarn upgrade-interactive
vscode:
echo "make vscode is no longer necessary since the migration to bun"

test/coverage/total.out: test/coverage/integration/*/* test/coverage/*/* Makefile
rm -rf test/coverage/total
Expand Down
2 changes: 1 addition & 1 deletion Makefile.binaries.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ container-demo: bin/goalert-linux-amd64.tgz bin/linux-amd64/resetdb bin/goalert-

$(BIN_DIR)/build/integration/cypress/plugins/index.js: package.json yarn.lock web/src/esbuild.cypress.js $(shell find ./web/src/cypress)
rm -rf $@
yarn run esbuild-cy
$(BIN_DIR)/tools/bun run esbuild-cy
mkdir -p $@/plugins
cp web/src/cypress/plugins/index.js $@/plugins/index.js
touch $@
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ smtp: ./bin/tools/mailpit -s localhost:1025 -l localhost:8025
prom: bin/tools/prometheus --log.level=warn --config.file=devtools/prometheus/prometheus.yml --storage.tsdb.path=bin/prom-data/ --web.listen-address=localhost:9090

@watch-file=./web/src/esbuild.config.js
ui: yarn run esbuild --watch
ui: ./bin/tools/bun run esbuild --watch

grpcui: go run ./devtools/waitfor tcp://localhost:1234 && go run github.com/fullstorydev/grpcui/cmd/grpcui -plaintext -open-browser=false -port 8234 localhost:1234

Expand Down
6 changes: 3 additions & 3 deletions Procfile.cypress
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ build: while true; do make -qs bin/goalert.cover || make bin/goalert.cover || (e
goalert: go run ./devtools/waitfor postgres://postgres@127.0.0.1:5433 && go run ./devtools/procwrap -test=127.0.0.1:3042 bin/goalert.cover -l=127.0.0.1:3042 --ui-dir=web/src/build --db-url=postgres://postgres@127.0.0.1:5433 --slack-base-url=http://127.0.0.1:3040/slack --stub-notifiers --log-errors-only --public-url=http://127.0.0.1:3040$HTTP_PREFIX --enable-secure-headers

@watch-file=./web/src/esbuild.config.js
ui: yarn run esbuild --watch
ui: ./bin/tools/bun run esbuild --watch

@watch-file=./web/src/esbuild.cypress.js
build-cy: yarn run esbuild-cy --watch
build-cy: ./bin/tools/bun run esbuild-cy --watch

slack: go run ./devtools/mockslack/cmd/mockslack -client-id=000000000000.000000000000 -client-secret=00000000000000000000000000000000 -access-token=xoxp-000000000000-000000000000-000000000000-00000000000000000000000000000000 -prefix=/slack -single-user=bob -addr=127.0.0.1:3046

proxy: go run ./devtools/simpleproxy -addr=127.0.0.1:3040 /slack/=http://127.0.0.1:3046 http://127.0.0.1:3042

@oneshot
cypress: go run ./devtools/waitfor http://127.0.0.1:3042 && CYPRESS_DB_URL=postgres://postgres@127.0.0.1:5433 yarn cypress open --config baseUrl=http://127.0.0.1:3040$HTTP_PREFIX
cypress: go run ./devtools/waitfor http://127.0.0.1:3042 && CYPRESS_DB_URL=postgres://postgres@127.0.0.1:5433 ./bin/tools/bun run cypress open --config baseUrl=http://127.0.0.1:3040$HTTP_PREFIX

db: $CONTAINER_TOOL rm -f smoketest-postgres || true; $CONTAINER_TOOL run -it --rm --name smoketest-postgres -p5433:5432 -e=POSTGRES_HOST_AUTH_METHOD=trust postgres:$PG_VERSION-alpine
2 changes: 1 addition & 1 deletion Procfile.cypress.ci
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@oneshot
cypress: go run ./devtools/waitfor http://127.0.0.1:3042 && CYPRESS_DB_URL=$DB_URL yarn cypress $CY_ACTION --config baseUrl=http://127.0.0.1:3040$HTTP_PREFIX
cypress: go run ./devtools/waitfor http://127.0.0.1:3042 && CYPRESS_DB_URL=$DB_URL ./bin/tools/bun run cypress $CY_ACTION --config baseUrl=http://127.0.0.1:3040$HTTP_PREFIX

goalert: go run ./devtools/waitfor $DB_URL && go run ./devtools/procwrap -test=127.0.0.1:3042 bin/goalert.cover -l=127.0.0.1:3042 --db-url=$DB_URL --slack-base-url=http://127.0.0.1:3040/slack --stub-notifiers --log-errors-only --public-url=http://127.0.0.1:3040$HTTP_PREFIX --enable-secure-headers

Expand Down
6 changes: 3 additions & 3 deletions Procfile.cypress.prod
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ slack: go run ./devtools/mockslack/cmd/mockslack -client-id=000000000000.0000000
proxy: go run ./devtools/simpleproxy -addr=127.0.0.1:3040 /slack/=http://127.0.0.1:3046 http://127.0.0.1:3042

@oneshot
cypress: go run ./devtools/waitfor http://127.0.0.1:3042 && CYPRESS_DB_URL=postgres://postgres@127.0.0.1:5433 yarn cypress $CY_ACTION --config baseUrl=http://127.0.0.1:3040$HTTP_PREFIX
cypress: go run ./devtools/waitfor http://127.0.0.1:3042 && CYPRESS_DB_URL=postgres://postgres@127.0.0.1:5433 ./bin/tools/bun run cypress $CY_ACTION --config baseUrl=http://127.0.0.1:3040$HTTP_PREFIX

db: $CONTAINER_TOOL rm -f smoketest-postgres || true; $CONTAINER_TOOL run -it --rm --name smoketest-postgres -p5433:5432 -e=POSTGRES_HOST_AUTH_METHOD=trust postgres:$PG_VERSION-alpine


@watch-file=./web/src/esbuild.config.js
ui: yarn run esbuild --watch --prod
ui: ./bin/tools/bun run esbuild --watch --prod

@watch-file=./web/src/esbuild.cypress.js
build-cy: yarn run esbuild-cy --watch
build-cy: ./bin/tools/bun run esbuild-cy --watch
2 changes: 1 addition & 1 deletion Procfile.swo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ smtp: ./bin/tools/mailpit -s localhost:1025 -l localhost:8025
prom: bin/tools/prometheus --log.level=warn --config.file=devtools/prometheus/prometheus-swo.yml --storage.tsdb.path=bin/prom-data/ --web.listen-address=localhost:9090

@watch-file=./web/src/esbuild.config.js
ui: yarn run esbuild --watch
ui: ./bin/tools/bun run esbuild --watch

@watch-file=./bin/goalert
ga2: ./bin/goalert -l=localhost:3050 --ui-dir=web/src/build --db-url=postgres://goalert@localhost:5435/goalert?sslmode=disable --listen-prometheus=localhost:2113 --db-url-next=postgres://goalert@localhost:5435/goalert2 --api-only --enable-secure-headers
Expand Down
Loading
Loading