packages:
- name: lib
type: yarn
srcs:
- "src/**/*.ts"
- .eslintrc
- package.json
- mocha.opts
deps:
- :dbtest
- components/gitpod-protocol:lib
config:
packaging: library
yarnLock: ${coreYarnLockBase}/yarn.lock
tsconfig: tsconfig.json
dontTest: true
- name: latest-migration
type: generic
srcs:
- "src/typeorm/migration/*.ts"
- "scripts/generate-latest-migration.sh"
config:
dontTest: false
commands:
- ["sh", "-c", "scripts/generate-latest-migration.sh > latest-migration.txt"]
test:
- ["scripts/generate-latest-migration.sh", "test"]
- ["sh", "-c", "rm -rf src"]
- ["sh", "-c", "rm -rf scripts"]
- name: migrations
type: yarn
srcs:
- "src/**/*.ts"
- .eslintrc
- package.json
deps:
- components/gitpod-protocol:lib
config:
dontTest: true
packaging: offline-mirror
yarnLock: ${coreYarnLockBase}/yarn.lock
tsconfig: tsconfig.json
- name: dbtest
type: yarn
srcs:
- "src/**/*.ts"
- .eslintrc
- package.json
- mocha.opts
deps:
- :dbtest-init
- components/gitpod-protocol:lib
config:
packaging: library
yarnLock: ${coreYarnLockBase}/yarn.lock
tsconfig: tsconfig.json
commands:
test: ["yarn", "db-test"]
build: ["yarn", "build"]
- name: dbtest-init
type: generic
srcs:
- package.json
- hack/*.sql
deps:
- :migrations
- install/installer/pkg/components/database/incluster/init:init-scripts
env:
- DB_PORT=23306
- DB_USER=root
- DB_PASSWORD=test
- DB_ENCRYPTION_KEYS=[{"name":"general","version":1,"primary":true,"material":"5vRrp0H4oRgdkPnX1qQcS54Q0xggr6iyho42IQ1rO+c="}]
ephemeral: true
config:
commands:
- ["sh", "-c", "mysqladmin ping --wait=${DB_RETRIES:-1} -h $DB_HOST --port $DB_PORT -p$DB_PASSWORD -u$DB_USER --default-auth=mysql_native_password --silent || (docker container rm test-mysql; docker run --name test-mysql -d -e MYSQL_ROOT_PASSWORD=$DB_PASSWORD -e MYSQL_TCP_PORT=$DB_PORT -p $DB_PORT:$DB_PORT mysql:8.0.33 --default-authentication-plugin=mysql_native_password; while ! mysqladmin ping -h \"$DB_HOST\" -P \"$DB_PORT\" -p$DB_PASSWORD -u$DB_USER --default-auth=mysql_native_password --silent; do echo \"waiting for DB...\"; sleep 2; done)"]
- ["mkdir", "-p", "init-scripts"]
- ["sh", "-c", "find . -name \"*.sql\" | sort | xargs -I file cp file init-scripts"]
- ["sh", "-c", "ls init-scripts | sort | xargs -I file cat init-scripts/file | sed -e 's/__GITPOD_USERNAME__/gitpod/g' | sed -e 's/__GITPOD_USERNAME__/gitpod/g' | sed -e 's/__GITPOD_DB_NAME__/gitpod/g' | tee debug.txt | mysql -h \"$DB_HOST\" -P \"$DB_PORT\" -p$DB_PASSWORD -u $DB_USER"]
- ["sh", "-c", "mkdir -p mig; cd mig; ../components-gitpod-db--migrations/install.sh"]
- ["yarn", "--cwd", "mig/node_modules/@gitpod/gitpod-db", "run", "migrate-migrations"]
- ["yarn", "--cwd", "mig/node_modules/@gitpod/gitpod-db", "typeorm", "migrations:run"]
- ["rm", "-rf", "mig"]
- name: docker
type: docker
srcs:
- migrate.sh
- migrate_gcp.sh
- typeorm.sh
- typeorm_gcp.sh
deps:
- :migrations
argdeps:
- imageRepoBase
config:
buildArgs:
VERSION: ${version}
dockerfile: leeway.Dockerfile
metadata:
helm-component: dbMigrations
image:
- ${imageRepoBase}/db-migrations:${version}
- ${imageRepoBase}/db-migrations:commit-${__git_commit}
scripts:
- name: init-testdb
description: "Starts a properly initialized MySQL instance to run tests against. Usage: '. $(leeway run components/gitpod-db:init-testdb)'"
deps: []
script: |
export DB_HOST=${DB_HOST:-127.0.0.1}
leeway build components/gitpod-db/go:init-testdb
- name: db-test-env
description: "Creates a file with env vars necessary for running DB tests. The file delets itself after being sourced. Usage: '. $(leeway run components/gitpod-db:db-test-env)'"
deps: []
script: |
TMP="$(mktemp)"
echo '#!/bin/bash' > $TMP
echo 'export DB_ENCRYPTION_KEYS="[{\"name\":\"general\",\"version\":1,\"primary\":true,\"material\":\"5vRrp0H4oRgdkPnX1qQcS54Q0xggr6iyho42IQ1rO+c=\"}]";export DB_HOST=${DB_HOST:-127.0.0.1};export DB_PORT=23306;export DB_USER=root;export DB_PASSWORD=test;' >> $TMP
echo "rm -f $TMP" >> $TMP
echo $TMP