-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
115 lines (82 loc) · 4.7 KB
/
Makefile
File metadata and controls
115 lines (82 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
.PHONY: check clean start start-app start-services format lint-css lint-ts prod smoketest typecheck typecheck-watch typecheck-analyze test test-fast test-watch test-integration test-integration-chrome update-incontext-locale update-snapshots test-integration-image status-prod withdraw-review-request categorize-review-request dump-sandbox-events
INTEGRATION_TEST_IMAGE_TAG=prereview.org-integration-tests
.env:
cp .env.dist .env
clean:
rm -rf .cache dist integration-results node_modules assets/locales src/locales src/manifest.json .dev/server.crt .dev/server.key
node_modules: package.json pnpm-lock.yaml
pnpm install --frozen-lockfile
touch node_modules
check: format lint-ts lint-css typecheck test-fast
update-incontext-locale:
source .env && crowdin download --language=lol --token=$${CROWDIN_PERSONAL_TOKEN}
src/locales: $(shell find locales -type f)
echo 'building locales'
scripts/intlc.sh
touch src/locales
src/manifest.json: node_modules src/locales $(shell find assets -type f | grep -v assets/locales)
npx webpack build --mode development
touch src/manifest.json
start-app: .env node_modules start-services src/manifest.json
POSTGRES_URL=postgres://postgres:password@$(shell docker compose port postgres 5432) \
REDIS_URI=redis://$(shell docker compose port redis 6379) \
HTTP_CACHE_REDIS_URI=redis://$(shell docker compose port redis 6379) \
SMTP_URI=smtp://$(shell docker compose port mailcatcher 1025) \
ENABLE_OPENTELEMETRY=true \
node --watch --watch-preserve-output --env-file=.env src/index.ts
start:
watchexec --restart --watch assets --watch locales --ignore assets/locales/ -- make start-app
prod: .env
docker compose up --build --exit-code-from app
.dev/server.crt .dev/server.key: SHELL := /usr/bin/env bash
.dev/server.crt .dev/server.key: .env
source .env && mkcert -install -cert-file .dev/server.crt -key-file .dev/server.key $$(echo $${PUBLIC_URL} | awk -F[/:] '{print $$4}')
start-services: .dev/server.crt .dev/server.key
docker compose up --detach mailcatcher nginx opentelemetry postgres redis
format: node_modules
npx prettier --ignore-unknown --check --cache --cache-location ".cache/prettier" src '**'
lint-ts: node_modules src/manifest.json
npx eslint --cache --cache-location ".cache/eslint/" --max-warnings 0
lint-css: node_modules
npx stylelint '**/*.css'
smoketest:
docker build --tag prereview-smoketest --target prod .
docker compose down
docker compose up postgres redis --wait
scripts/smoke-test.sh prereview-smoketest
docker compose down
typecheck: node_modules src/manifest.json
npx tsc --incremental --tsBuildInfoFile ".cache/tsc"
typecheck-watch: node_modules src/manifest.json
npx tsc --watch --incremental --tsBuildInfoFile ".cache/tsc"
typecheck-analyze: node_modules src/manifest.json
npx tsc --incremental false --generateTrace ".cache/tsc-trace"
npx analyze-trace .cache/tsc-trace ${TEST}
test: node_modules src/manifest.json
npx vitest run ${TEST}
test-fast: node_modules src/manifest.json
FAST_CHECK_NUM_RUNS=10 npx vitest run --changed --maxWorkers=50%
test-watch: node_modules src/manifest.json
FAST_CHECK_NUM_RUNS=10 npx vitest watch --changed ${TEST}
test-integration: test-integration-image
docker compose up postgres --wait
docker run --rm --env "POSTGRES_URL=postgres://postgres:[email protected]:5432" --add-host="host.docker.internal:host-gateway" --volume "$$(pwd)"/integration-results:/app/integration-results --volume "$$(pwd)"/visual-regression/snapshots:/app/visual-regression/snapshots ${INTEGRATION_TEST_IMAGE_TAG} ${TEST} ${ARGS}
test-integration-chrome: ARGS=--project 'Desktop Chrome'
test-integration-chrome: test-integration
update-snapshots: ARGS=--update-snapshots
update-snapshots: test-integration
test-integration-image:
docker build --target test-integration --tag ${INTEGRATION_TEST_IMAGE_TAG} .
cli-local: .env node_modules start-services
POSTGRES_URL=postgres://postgres:password@$(shell docker compose port postgres 5432) \
node --env-file .env src/cli.ts --wizard
cli-prod: .env node_modules start-services
flyctl --config fly.prod.toml ssh console --region iad --pty --command "node dist/cli.js --wizard"
status-prod:
flyctl --config fly.prod.toml ssh console --region iad --command "node dist/cli.js status"
withdraw-review-request:
flyctl --config fly.prod.toml ssh console --region iad --pty --command "node dist/cli.js withdraw-review-request --wizard"
categorize-review-request:
flyctl --config fly.prod.toml ssh console --region iad --pty --command "node dist/cli.js categorize-review-request --wizard"
dump-sandbox-events:
echo "COPY (SELECT * FROM events ORDER BY position) TO STDOUT WITH (FORMAT CSV, HEADER);" | fly mpg connect nvwq9oz78qe03kl1 -u readonly -d prereview-sandbox | tail -n +2 > data/sandbox-events-dump.csv