-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add docker-compose file for easier creation of local resources * created database migration script * added yarn scripts for local setup & cleanup * update readme
- Loading branch information
1 parent
9fb8254
commit 1b8f48c
Showing
7 changed files
with
274 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM ubuntu:20.04 | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt update -qq && \ | ||
apt install -y --no-install-recommends curl git npm && \ | ||
apt clean && rm -rf /tmp/* var/tmp/* | ||
|
||
WORKDIR /home | ||
|
||
RUN npm install -g yarn typescript n | ||
RUN n 16 && npm install sequelize sequelize-cli pg | ||
|
||
COPY migrations /home/migrations | ||
COPY config /home/config | ||
|
||
RUN curl -O https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh | ||
RUN chmod +x wait-for-it.sh | ||
|
||
CMD ["./wait-for-it.sh", "db:5432", "--", "npx", "sequelize-cli", "db:migrate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#! /bin/bash | ||
|
||
docker container stop testing_pgadmin_1 testing_migration_1 testing_postgres_1 | ||
|
||
docker container rm testing_pgadmin_1 testing_migration_1 testing_postgres_1 | ||
|
||
docker volume rm testing_pgadmin testing_postgres |
23 changes: 23 additions & 0 deletions
23
scripts/actions/translation_workflow/testing/config/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"development": { | ||
"username": "root", | ||
"password": "root", | ||
"database": "translations", | ||
"host": "postgres", | ||
"dialect": "postgres" | ||
}, | ||
"test": { | ||
"username": "root", | ||
"password": "root", | ||
"database": "translations", | ||
"host": "postgres", | ||
"dialect": "postgres" | ||
}, | ||
"production": { | ||
"username": "root", | ||
"password": "root", | ||
"database": "translations", | ||
"host": "postgres", | ||
"dialect": "postgres" | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
scripts/actions/translation_workflow/testing/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: "3.9" | ||
|
||
services: | ||
postgres: | ||
image: postgres:14-alpine | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: root | ||
POSTGRES_USER: root | ||
POSTGRES_DB: translations | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- postgres:/var/lib/postgresql/data | ||
pgadmin: | ||
image: dpage/pgadmin4:6.2 | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: admin@pgadmin.com | ||
PGADMIN_DEFAULT_PASSWORD: password | ||
PGADMIN_LISTEN_PORT: 80 | ||
ports: | ||
- 15432:80 | ||
volumes: | ||
- pgadmin:/var/lib/pgadmin | ||
depends_on: | ||
- postgres | ||
migration: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
depends_on: | ||
- "postgres" | ||
|
||
volumes: | ||
postgres: | ||
pgadmin: |
162 changes: 162 additions & 0 deletions
162
scripts/actions/translation_workflow/testing/migrations/20211201221649-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
'use strict'; | ||
|
||
const { | ||
Sequelize, | ||
QueryInterface, | ||
DataTypes, | ||
Deferrable, | ||
} = require('sequelize'); | ||
|
||
module.exports = { | ||
up: /** @param {QueryInterface} queryInterface @param {Sequelize} Sequelize */ async ( | ||
queryInterface, | ||
Sequelize | ||
) => { | ||
await queryInterface.createTable('locales', { | ||
id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
locale: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
unique: true, | ||
}, | ||
}); | ||
await queryInterface.createTable('statuses', { | ||
id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
status: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
unique: true, | ||
}, | ||
}); | ||
await queryInterface.createTable('jobs', { | ||
id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
job_uid: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
}, | ||
batch_uid: { | ||
type: DataTypes.TEXT, | ||
allowNull: true, | ||
}, | ||
status: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
references: { | ||
model: 'statuses', | ||
key: 'status', | ||
deferrable: Deferrable.INITIALLY_IMMEDIATE, | ||
}, | ||
}, | ||
locale: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
references: { | ||
model: 'locales', | ||
key: 'locale', | ||
deferrable: Deferrable.INITIALLY_IMMEDIATE, | ||
}, | ||
}, | ||
project_id: { | ||
type: DataTypes.TEXT, | ||
allowNull: true, | ||
}, | ||
date_created: { | ||
type: DataTypes.DATE, | ||
}, | ||
date_modified: { | ||
type: DataTypes.DATE, | ||
}, | ||
}); | ||
await queryInterface.createTable('translations', { | ||
id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
slug: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
}, | ||
status: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
}, | ||
locale: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
references: { | ||
model: 'locales', | ||
key: 'locale', | ||
deferrable: Deferrable.INITIALLY_IMMEDIATE, | ||
}, | ||
}, | ||
project_id: { | ||
type: DataTypes.TEXT, | ||
allowNull: true, | ||
}, | ||
date_created: { | ||
type: DataTypes.DATE, | ||
}, | ||
date_modified: { | ||
type: DataTypes.DATE, | ||
}, | ||
}); | ||
await queryInterface.createTable('translations_jobs', { | ||
translation_id: { | ||
type: DataTypes.INTEGER, | ||
references: { | ||
model: 'translations', | ||
key: 'id', | ||
deferrable: Deferrable.INITIALLY_IMMEDIATE, | ||
}, | ||
primaryKey: true, | ||
onDelete: 'CASCADE', | ||
}, | ||
job_id: { | ||
type: DataTypes.INTEGER, | ||
references: { | ||
model: 'jobs', | ||
key: 'id', | ||
deferrable: Deferrable.INITIALLY_IMMEDIATE, | ||
}, | ||
primaryKey: true, | ||
onDelete: 'CASCADE', | ||
}, | ||
}); | ||
await queryInterface.bulkInsert('statuses', [ | ||
{ status: 'PENDING' }, | ||
{ status: 'IN_PROGRESS' }, | ||
{ status: 'IN_REVIEW' }, | ||
{ status: 'COMPLETED' }, | ||
{ status: 'ERRORED' }, | ||
]); | ||
await queryInterface.bulkInsert('locales', [ | ||
{ | ||
locale: 'ja-JP', | ||
}, | ||
]); | ||
}, | ||
|
||
down: /** @param {QueryInterface} queryInterface @param {Sequelize} Sequelize */ async ( | ||
queryInterface, | ||
Sequelize | ||
) => { | ||
await queryInterface.dropAllTables(); | ||
}, | ||
}; |