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: use Task #1535

Merged
merged 22 commits into from
Apr 17, 2024
Prev Previous commit
Next Next commit
Some fixes
  • Loading branch information
fortuna committed Apr 16, 2024
commit 21ff2700937a774defb953f1c221407b5265a24f
20 changes: 13 additions & 7 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ set: [pipefail]

run: when_changed

vars:
REPO_ROOT: "{{.ROOT_DIR}}"
BUILD_ROOT: "{{.ROOT_DIR}}/build"

includes:
metrics_server: ./src/metrics_server/Taskfile.yml
sentry_webhook: ./src/sentry_webhook/Taskfile.yml
shadowbox: ./src/shadowbox/Taskfile.yml
metrics_server:
taskfile: ./src/metrics_server/Taskfile.yml
vars: {OUTPUT_BASE: '{{joinPath .BUILD_ROOT "metrics_server"}}'}

vars:
ROOT_DIR: "{{.TASKFILE_DIR}}"
BUILD_DIR: "{{.TASKFILE_DIR}}/build"
sentry_webhook:
taskfile: ./src/sentry_webhook/Taskfile.yml
vars: {OUTPUT_BASE: '{{joinPath .BUILD_ROOT "metrics_server"}}'}

shadowbox: ./src/shadowbox/Taskfile.yml

tasks:
clean:
desc: Clean output files
cmds:
- rm -rf .task src/*/node_modules/ build/ node_modules/ third_party/shellcheck/download/ third_party/*/bin third_party/jsign/*.jar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to remove the ./task binary built by npm install as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Done


format:
desc: Format staged files
cmds: ['npx pretty-quick --staged --pattern "**/*.{cjs,html,js,json,md,ts}"']
Expand Down
2 changes: 1 addition & 1 deletion src/metrics_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ task metrics_server:start
```
- Integration test
```sh
task metrics_server:integration:test
task metrics_server:integration_test
```
32 changes: 20 additions & 12 deletions src/metrics_server/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
version: '3'

vars:
SERVER_DIR: '{{joinPath .USER_WORKING_DIR "build/metrics_server"}}'
requires:
vars: [OUTPUT_BASE]

tasks:
clean:
desc: Clean metrics server output
cmds:
- rm -rf "{{.SERVER_DIR}}"
- rm -rf "{{.OUTPUT_BASE}}"

build:
desc: Build the metrics server
vars:
BUILD_MODE: '{{.BUILD_MODE | default "dev"}}'
TARGET_DIR: '{{joinPath .SERVER_DIR .BUILD_MODE}}'
TARGET_DIR: &default-target-dir '{{joinPath .OUTPUT_BASE .BUILD_MODE}}'
cmds:
- rm -rf '{{.TARGET_DIR}}'
- npx tsc --project '{{.TASKFILE_DIR}}' --outDir '{{.TARGET_DIR}}'
Expand All @@ -24,24 +24,32 @@ tasks:

deploy:dev:
desc: Deploy the development metrics server
deps: [{task: build, vars: {BUILD_MODE: dev}}]
vars:
BUILD_MODE: "dev"
TARGET_DIR: *default-target-dir
deps: [{task: build, vars: {BUILD_MODE: "{{.BUILD_MODE}}", TARGET_DIR: "{{.TARGET_DIR}}"}}]
cmds:
- gcloud app deploy '{{.TASKFILE_DIR}}/dispatch.yaml' '{{joinPath .SERVER_DIR "dev"}}' --project uproxysite --verbosity info --promote --stop-previous-version
- gcloud app deploy '{{.TASKFILE_DIR}}/dispatch.yaml' '{{.TARGET_DIR}}' --project uproxysite --verbosity info --promote --stop-previous-version

deploy:prod:
desc: Deploy the production metrics server
deps: [{task: build, vars: {BUILD_MODE: prod}}]
vars:
BUILD_MODE: "prod"
TARGET_DIR: *default-target-dir
deps: [{task: build, vars: {BUILD_MODE: "{{.BUILD_MODE}}", TARGET_DIR: "{{.TARGET_DIR}}"}}]
cmds:
- gcloud app deploy '{{.TASKFILE_DIR}}/dispatch.yaml' '{{joinPath .SERVER_DIR "prod"}}' --project uproxysite --verbosity info --no-promote --no-stop-previous-version
- gcloud app deploy '{{.TASKFILE_DIR}}/dispatch.yaml' '{{joinPath .OUTPUT_BASE "prod"}}' --project uproxysite --verbosity info --no-promote --no-stop-previous-version

start:
desc: Start the metrics server locally
deps: [build]
vars:
BUILD_MODE: '{{.BUILD_MODE | default "dev"}}'
TARGET_DIR: *default-target-dir
deps: [{task: build, vars: {BUILD_MODE: "{{.BUILD_MODE}}", TARGET_DIR: "{{.TARGET_DIR}}"}}]
cmds:
- cp '{{.TASKFILE_DIR}}/config_dev.json' '{{.SERVER_DIR}}/config.json'
- npx node '{{.SERVER_DIR}}/index.js'
- node '{{joinPath .TARGET_DIR "index.js"}}'

integration:test:
integration_test:
desc: Test the deployed dev metrics server
cmds:
- '{{.TASKFILE_DIR}}/test_integration.sh'
Expand Down
14 changes: 7 additions & 7 deletions src/sentry_webhook/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
version: '3'

vars:
WEBHOOK_DIR: '{{joinPath .USER_WORKING_DIR "build/sentry_webhook"}}'

requires:
vars: [OUTPUT_BASE]
tasks:
clean:
desc: Clean Sentry webhook output
cmds:
- rm -rf "{{.WEBHOOK_DIR}}"
- rm -rf "{{.OUTPUT_BASE}}"

build:
desc: Build the Sentry webhook
cmds:
- npx tsc --project '{{.TASKFILE_DIR}}/tsconfig.prod.json' --outDir '{{.WEBHOOK_DIR}}'
- cp '{{.TASKFILE_DIR}}/package.json' '{{.WEBHOOK_DIR}}'
- npx tsc --project '{{.TASKFILE_DIR}}/tsconfig.prod.json' --outDir '{{.OUTPUT_BASE}}'
- cp '{{.TASKFILE_DIR}}/package.json' '{{.OUTPUT_BASE}}'

deploy:
desc: Deploy the Sentry webhook to GCP Cloud Functions
Expand All @@ -23,7 +23,7 @@ tasks:
--project=uproxysite
--runtime=nodejs18
--trigger-http
--source='{{.WEBHOOK_DIR}}'
--source='{{.OUTPUT_BASE}}'
--entry-point=postSentryEventToSalesforce

test:
Expand Down