Skip to content

Commit

Permalink
update runner to use database versions and CI comparable to v7 (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
WikiRik authored Feb 10, 2024
1 parent a8ce25f commit 1230359
Show file tree
Hide file tree
Showing 56 changed files with 5,145 additions and 277 deletions.
131 changes: 40 additions & 91 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,124 +1,73 @@
name: CI
on: [pull_request]
on:
pull_request:

env:
SEQ_DB: sequelize_test
SEQ_USER: sequelize_test
SEQ_PW: sequelize_test
# This configuration cancels previous runs if a new run is started on the same PR. Only one run at a time per PR.
# from https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test-sqlite:
strategy:
fail-fast: false
matrix:
# node 10 is the minimum supported version for Sequelize 6
# node 14 is the minimum supported version for Sequelize 7
# node 16 is latest LTS (to keep updated)
node: [10, 14, 16]
name: SQLite (sequelize 6 & 7, node ${{ matrix.node }})
node-version: [10, 18, 20]
name: sqlite (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
env:
DIALECT: sqlite
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 14.x
- run: /bin/bash ./setup/prepare-ci.sh
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- name: Execute SSCCE
run: npm run _test
run: yarn run _test
test-postgres:
strategy:
fail-fast: false
matrix:
postgres-version: [9.5, 10] # Does not work with 12
node-version: [10, 18, 20]
postgres-version: [oldest, latest]
minify-aliases: [true, false]
native: [true, false]
node: [10, 14, 16]
name: Postgres ${{ matrix.postgres-version }}${{ matrix.native && ' (native)' || '' }} (sequelize 6 & 7, node ${{ matrix.node }})
name: postgres ${{ matrix.postgres-version }}${{ matrix.native && ' (native)' || '' }} (Node ${{ matrix.node-version }})${{ matrix.minify-aliases && ' (minified aliases)' || '' }}
runs-on: ubuntu-latest
services:
postgres:
image: sushantdhiman/postgres:${{ matrix.postgres-version }}
env:
POSTGRES_USER: sequelize_test
POSTGRES_DB: sequelize_test
POSTGRES_PASSWORD: sequelize_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
DIALECT: ${{ matrix.native && 'postgres-native' || 'postgres' }}
SEQ_PG_MINIFY_ALIASES: ${{ matrix.minify-aliases && '1' || '' }}
steps:
- run: PGPASSWORD=sequelize_test psql -h localhost -p 5432 -U sequelize_test sequelize_test -c '\l'
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node }}
- run: /bin/bash ./setup/prepare-ci.sh
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- run: yarn start-postgres-${{ matrix.postgres-version }}
- name: Execute SSCCE
run: npm run _test
test-mysql-mariadb:
run: yarn run _test
test-oldest-latest:
strategy:
fail-fast: false
matrix:
node: [10, 14, 16]
db:
- '{ name: "MySQL 5.7", image: "mysql:5.7", dialect: "mysql" }'
- '{ name: "MariaDB 10.3", image: "mariadb:10.3", dialect: "mariadb" }'
name: ${{ fromJson(matrix.db).name }} (node ${{ matrix.node }})
node-version: [10, 18, 20]
database-version: [oldest, latest]
dialect: [mysql, mariadb, mssql]
name: ${{ matrix.dialect }} ${{ matrix.database-version }} (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
services:
mysql:
image: ${{ fromJson(matrix.db).image }}
env:
MYSQL_DATABASE: sequelize_test
MYSQL_USER: sequelize_test
MYSQL_PASSWORD: sequelize_test
MYSQL_ROOT_PASSWORD: sequelize_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin -usequelize_test -psequelize_test status" --health-interval 10s --health-timeout 5s --health-retries 5 --tmpfs /var/lib/mysql:rw
env:
DIALECT: ${{ fromJson(matrix.db).dialect }}
DIALECT: ${{ matrix.dialect }}
steps:
- run: mysql --host 127.0.0.1 --port 3306 -uroot -psequelize_test -e "GRANT ALL ON *.* TO 'sequelize_test'@'%' with grant option; FLUSH PRIVILEGES;"
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node }}
- run: /bin/bash ./setup/prepare-ci.sh
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- run: yarn start-${{ matrix.dialect }}-${{ matrix.database-version }}
- name: Execute SSCCE
run: npm run _test
test-mssql:
strategy:
fail-fast: false
matrix:
node: [10, 14, 16]
mssql-version: [2017, 2019]
name: MSSQL ${{ matrix.mssql-version }} (sequelize 6 & 7, node ${{ matrix.node }})
runs-on: ubuntu-latest
services:
mssql:
image: mcr.microsoft.com/mssql/server:${{ matrix.mssql-version }}-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: Password12!
ports:
- 1433:1433
options: >-
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -l 30 -Q \"SELECT 1\" || exit 1"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 10
env:
DIALECT: mssql
steps:
- run: /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "CREATE DATABASE sequelize_test; ALTER DATABASE sequelize_test SET READ_COMMITTED_SNAPSHOT ON;"
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: /bin/bash ./setup/prepare-ci.sh
- name: Execute SSCCE
run: npm run _test
run: yarn run _test
30 changes: 27 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
node_modules
npm-debug.log
yarn.lock
*.swp
.idea
.DS_STORE
npm-debug.log*
*~
test.sqlite
test.sqlite2
*.sublime*
package-lock.json
pnpm-lock.yaml

.nyc_output
coverage-*
coverage
tmp
.vscode/
.typedoc-build
node_modules
*.log
/.nx

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
21 changes: 0 additions & 21 deletions .vscode/launch.json

This file was deleted.

File renamed without changes.
72 changes: 72 additions & 0 deletions dev/ci-db-configs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const { env } = process;

export const CiDbConfigs = {
mssql: {
host: env.SEQ_MSSQL_HOST || env.SEQ_HOST || 'localhost',
username: env.SEQ_MSSQL_USER || env.SEQ_USER || 'SA',
password: env.SEQ_MSSQL_PW || env.SEQ_PW || 'Password12!',
port: env.SEQ_MSSQL_PORT || env.SEQ_PORT || 22_019,
database: env.SEQ_MSSQL_DB || env.SEQ_DB || 'sequelize_test',
dialectOptions: {
options: {
encrypt: false,
requestTimeout: 25_000,
},
},
pool: {
max: Number(env.SEQ_MSSQL_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_MSSQL_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
},

mysql: {
database: env.SEQ_MYSQL_DB || env.SEQ_DB || 'sequelize_test',
username: env.SEQ_MYSQL_USER || env.SEQ_USER || 'sequelize_test',
password: env.SEQ_MYSQL_PW || env.SEQ_PW || 'sequelize_test',
host: env.MYSQL_PORT_3306_TCP_ADDR || env.SEQ_MYSQL_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.MYSQL_PORT_3306_TCP_PORT || env.SEQ_MYSQL_PORT || env.SEQ_PORT || 20_057,
pool: {
max: Number(env.SEQ_MYSQL_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_MYSQL_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
},

snowflake: {
username: env.SEQ_SNOWFLAKE_USER || env.SEQ_USER || 'root',
password: env.SEQ_SNOWFLAKE_PW || env.SEQ_PW || '',
database: env.SEQ_SNOWFLAKE_DB || env.SEQ_DB || 'sequelize_test',
dialectOptions: {
account: env.SEQ_SNOWFLAKE_ACCOUNT || env.SEQ_ACCOUNT || 'sequelize_test',
role: env.SEQ_SNOWFLAKE_ROLE || env.SEQ_ROLE || 'role',
warehouse: env.SEQ_SNOWFLAKE_WH || env.SEQ_WH || 'warehouse',
schema: env.SEQ_SNOWFLAKE_SCHEMA || env.SEQ_SCHEMA || '',
},
},

mariadb: {
database: env.SEQ_MARIADB_DB || env.SEQ_DB || 'sequelize_test',
username: env.SEQ_MARIADB_USER || env.SEQ_USER || 'sequelize_test',
password: env.SEQ_MARIADB_PW || env.SEQ_PW || 'sequelize_test',
host: env.MARIADB_PORT_3306_TCP_ADDR || env.SEQ_MARIADB_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.MARIADB_PORT_3306_TCP_PORT || env.SEQ_MARIADB_PORT || env.SEQ_PORT || 21_103,
pool: {
max: Number(env.SEQ_MARIADB_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_MARIADB_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
},

sqlite: {},

postgres: {
database: env.SEQ_PG_DB || env.SEQ_DB || 'sequelize_test',
username: env.SEQ_PG_USER || env.SEQ_USER || 'sequelize_test',
password: env.SEQ_PG_PW || env.SEQ_PW || 'sequelize_test',
host: env.POSTGRES_PORT_5432_TCP_ADDR || env.SEQ_PG_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.POSTGRES_PORT_5432_TCP_PORT || env.SEQ_PG_PORT || env.SEQ_PORT || 23_010,
pool: {
max: Number(env.SEQ_PG_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_PG_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
minifyAliases: Boolean(env.SEQ_PG_MINIFY_ALIASES),
},
};
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup/lib-replacements.ts → dev/lib-replacements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function run() {
} else if (process.argv[2] === '--undo') {
await undoReplacements();
} else {
throw new Error('Invalid call to setup/lib-replacements.js');
throw new Error('Invalid call to dev/lib-replacements.js');
}
}

Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions dev/mariadb/latest/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
mariadb-latest:
container_name: sequelize-mariadb-latest
image: mariadb:11.2.2
environment:
MYSQL_DATABASE: sequelize_test
MYSQL_USER: sequelize_test
MYSQL_PASSWORD: sequelize_test
MYSQL_ROOT_PASSWORD: sequelize_test
ports:
- 21103:3306
volumes:
- mariadb-latest:/var/lib/mysql
healthcheck:
test: ["CMD", "mariadb-admin", "-usequelize_test", "-psequelize_test", "status"]
interval: 3s
timeout: 1s
retries: 10

networks:
default:
name: sequelize-mariadb-latest-network

volumes:
mariadb-latest:
name: sequelize-mariadb-latest-volume
5 changes: 1 addition & 4 deletions setup/mysql/8.0/stop.sh → dev/mariadb/latest/reset.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637


docker-compose -p sequelize-mysql-80 down --remove-orphans

echo "Local MySQL-8.0 instance stopped (if it was running)."
docker compose -p sequelize-mariadb-latest down --remove-orphans --volumes
13 changes: 13 additions & 0 deletions dev/mariadb/latest/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637

docker compose -p sequelize-mariadb-latest down --remove-orphans
docker compose -p sequelize-mariadb-latest up -d

./../../wait-until-healthy.sh sequelize-mariadb-latest

docker exec sequelize-mariadb-latest \
mariadb --host 127.0.0.1 --port 3306 -uroot -psequelize_test -e "GRANT ALL ON *.* TO 'sequelize_test'@'%' with grant option; FLUSH PRIVILEGES;"

DIALECT=mariadb ts-node ../../check-connection.ts
7 changes: 7 additions & 0 deletions dev/mariadb/latest/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637

docker compose -p sequelize-mariadb-latest down --remove-orphans

echo "Local latest supported MariaDB instance stopped (if it was running)."
26 changes: 26 additions & 0 deletions dev/mariadb/oldest/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
mariadb-oldest:
container_name: sequelize-mariadb-oldest
image: mariadb:10.4.30
environment:
MYSQL_DATABASE: sequelize_test
MYSQL_USER: sequelize_test
MYSQL_PASSWORD: sequelize_test
MYSQL_ROOT_PASSWORD: sequelize_test
ports:
- 21103:3306
volumes:
- mariadb-oldest:/var/lib/mysql
healthcheck:
test: ["CMD", "mariadb-admin", "-usequelize_test", "-psequelize_test", "status"]
interval: 3s
timeout: 1s
retries: 10

networks:
default:
name: sequelize-mariadb-oldest-network

volumes:
mariadb-oldest:
name: sequelize-mariadb-oldest-volume
5 changes: 1 addition & 4 deletions setup/mssql/2019/stop.sh → dev/mariadb/oldest/reset.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637


docker-compose -p sequelize-mssql-2019 down --remove-orphans

echo "Local MSSQL-2019 instance stopped (if it was running)."
docker compose -p sequelize-mariadb-oldest down --remove-orphans --volumes
Loading

0 comments on commit 1230359

Please sign in to comment.