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

refactor: new ci pipeline #878

Merged
merged 6 commits into from Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .env
@@ -1,31 +1,31 @@
DB=pg
DB_NAME=lucid

MYSQL_HOST=mysql
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=virk
MYSQL_PASSWORD=password

MYSQL_LEGACY_HOST=mysql_legacy
MYSQL_LEGACY_HOST=localhost
MYSQL_LEGACY_PORT=3306
MYSQL_LEGACY_USER=virk
MYSQL_LEGACY_PASSWORD=password

MYSQL_REPLICA_1_HOST=mysql_replica_1
MYSQL_REPLICA_1_HOST=localhost
MYSQL_REPLICA_1_PORT=3306
MYSQL_REPLICA_1_USER=virk
MYSQL_REPLICA_1_PASSWORD=password

MYSQL_REPLICA_2_HOST=mysql_replica_2
MYSQL_REPLICA_2_HOST=localhost
MYSQL_REPLICA_2_PORT=3306
MYSQL_REPLICA_2_USER=virk
MYSQL_REPLICA_2_PASSWORD=password

PG_HOST=pg
PG_HOST=localhost
PG_PORT=5432
PG_USER=virk
PG_PASSWORD=password

MSSQL_SERVER=microsoftsql
MSSQL_SERVER=localhost
MSSQL_USER=sa
MSSQL_PASSWORD=arandom&233password
130 changes: 127 additions & 3 deletions .github/workflows/test.yml
Expand Up @@ -2,12 +2,136 @@ name: test
on:
- push
- pull_request

jobs:
build:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- run: npm install
Julien-R44 marked this conversation as resolved.
Show resolved Hide resolved

lint:
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v2
Julien-R44 marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- run: npm install
- run: npm run lint

typecheck:
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- run: npm install
- run: npx tsc

test-postgres:
runs-on: ubuntu-latest
needs: [install, lint, typecheck]
Julien-R44 marked this conversation as resolved.
Show resolved Hide resolved
strategy:
matrix:
node-version: [14, 16, 18]
postgres-version: [11, 14]
Julien-R44 marked this conversation as resolved.
Show resolved Hide resolved
services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_DB: lucid
POSTGRES_USER: virk
POSTGRES_PASSWORD: password
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install
run: npm install
- name: Run Postgres Tests
run: npm run test:pg

test-mysql:
runs-on: ubuntu-latest
needs: [install, lint, typecheck]
strategy:
matrix:
mysql: [{ version: '5.7', command: 'mysql_legacy' }, { version: '8.0', command: 'mysql' }]
node-version: [14, 16, 18]
services:
mysql:
image: mysql:${{ matrix.mysql.version }}
env:
MYSQL_DATABASE: lucid
MYSQL_USER: virk
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- '3306:3306'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install
run: npm install
- name: Run Mysql Tests
run: npm run test:${{ matrix.mysql.command }}

test-sqlite:
runs-on: ubuntu-latest
needs: [install, lint, typecheck]
strategy:
matrix:
lib: ['sqlite', 'better_sqlite']
node-version: [14, 16, 18]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install
run: npm install
- name: Run Sqlite Tests
run: npm run test:${{ matrix.lib }}

test-mssql:
runs-on: ubuntu-latest
needs: [install, lint, typecheck]
strategy:
matrix:
node-version: [14, 16, 18]
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
SA_PASSWORD: 'arandom&233password'
ACCEPT_EULA: 'Y'
ports:
- '1433:1433'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install
run: npm install
- name: Run tests
run: npm run test
- name: Run Mssql Tests
run: npm run test:mssql
14 changes: 0 additions & 14 deletions docker-compose-test.yml

This file was deleted.

13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -16,14 +16,13 @@
"scripts": {
"mrm": "mrm --preset=@adonisjs/mrm-preset",
"pretest": "npm run lint",
"test:better_sqlite": "cross-env DB=better_sqlite FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
"test:sqlite": "cross-env DB=sqlite FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
"test:mysql": "cross-env DB=mysql FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
"test:mysql_legacy": "cross-env DB=mysql_legacy FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
"test:mssql": "cross-env DB=mssql FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
"test:pg": "cross-env DB=pg FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
"test:better_sqlite": "sh ./scripts/run-tests.sh better_sqlite",
"test:sqlite": "sh ./scripts/run-tests.sh sqlite",
"test:mysql": "sh ./scripts/run-tests.sh mysql",
"test:mysql_legacy": "sh ./scripts/run-tests.sh mysql_legacy",
"test:mssql": "sh ./scripts/run-tests.sh mssql",
"test:pg": "sh ./scripts/run-tests.sh pg",
"test:docker": "npm run test:mysql && npm run test:mysql_legacy && npm run test:pg && npm run test:mssql",
"test": "docker-compose -f docker-compose.yml -f docker-compose-test.yml build && docker-compose -f docker-compose.yml -f docker-compose-test.yml run --rm test && npm run test:sqlite && npm run test:better_sqlite",
"lint": "eslint . --ext=.ts",
"clean": "del-cli build",
"compile": "npm run lint && npm run clean && tsc && npm run copyfiles",
Expand Down
11 changes: 4 additions & 7 deletions Dockerfile → scripts/Dockerfile
@@ -1,10 +1,10 @@
FROM node:16.14.0-alpine as build-deps

RUN apk update && apk upgrade && \
apk add --update git && \
apk add --update openssh && \
apk add --update bash && \
apk add --update wget && \
apk add --update git && \
apk add --update openssh && \
apk add --update bash && \
apk add --update wget && \
apk add --update g++ make python3

WORKDIR /usr/src/app
Expand All @@ -17,7 +17,4 @@ RUN chmod +x /wait-for-it.sh

COPY . .

COPY ./start.sh /start.sh
RUN chmod +x /start.sh

RUN npm run build
7 changes: 6 additions & 1 deletion docker-compose.yml → scripts/docker-compose.yml
Expand Up @@ -12,6 +12,7 @@ services:
- '3306:3306'
expose:
- '3306'

mysql_replica_1:
platform: linux/x86_64
image: mysql:5.7
Expand All @@ -24,6 +25,7 @@ services:
- '3304:3306'
expose:
- '3306'

mysql_replica_2:
platform: linux/x86_64
image: mysql:5.7
Expand All @@ -36,6 +38,7 @@ services:
- '3303:3306'
expose:
- '3306'

mysql:
platform: linux/x86_64
image: mysql:8.0
Expand All @@ -49,6 +52,7 @@ services:
- '3305:3306'
expose:
- '3306'

pg:
image: postgres:11
environment:
Expand All @@ -59,7 +63,8 @@ services:
- 5432:5432
expose:
- '5432'
microsoftsql:

mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
- 21433:1433
Expand Down
9 changes: 9 additions & 0 deletions scripts/run-tests.sh
@@ -0,0 +1,9 @@
#!/bin/bash

docker-compose -f ./scripts/docker-compose.yml down

if [ $1 != "better_sqlite" ] && [ $1 != "sqlite" ]; then
docker-compose -f ./scripts/docker-compose.yml up -d $1
fi

DB=better_sqlite FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts
Julien-R44 marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 0 additions & 3 deletions start.sh

This file was deleted.