Skip to content

Commit

Permalink
refactor: modernize SSCCE (#218)
Browse files Browse the repository at this point in the history
* refactor: modernize

* refactor: modernize sscce

* feat: add docker images

* build: update ci

* refactor: remove .idea

* refactor: update tsconfig/gitignore

* build: use node 14

* build: disable linter on sscce file

* docs: document the need to install pg-hstore if using DataTypes.HSTORE

* docs: update documentation

* feat: run against Sequelize 6 & 7 on node 10 to 16

* fix: make start:x scripts work in cjs

* fix: ignore internal ts error

* ci: dedupe CI runs

* docs: update references to sscce.ts
  • Loading branch information
ephys authored Apr 10, 2022
1 parent cb84939 commit a8ce25f
Show file tree
Hide file tree
Showing 46 changed files with 843 additions and 464 deletions.
26 changes: 14 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 10
},
"extends": [
"eslint:recommended",
"plugin:node/recommended"
"@ephys/eslint-config-typescript",
"@ephys/eslint-config-typescript/node"
],
"rules": {
"no-unused-vars": "off",
"node/no-unpublished-require": "off"
}
"unicorn/prefer-node-protocol": "off",
"no-console": "off",
"import/order": "off",
"prefer-object-has-own": "off",
"unicorn/prefer-at": "off",
"@typescript-eslint/no-unused-expressions": "off",

// we still have to support node 10 while Sequelize 6 remains alive
"unicorn/prefer-module": "off",
"unicorn/prefer-top-level-await": "off"
},
"ignorePatterns": ["src/*"]
}
47 changes: 23 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI
on: [push, pull_request]
on: [pull_request]

env:
SEQ_DB: sequelize_test
Expand All @@ -11,28 +11,30 @@ jobs:
strategy:
fail-fast: false
matrix:
combination: ['v5', 'v6', 'v6 with TS']
name: SQLite (${{ matrix.combination }})
# 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 }})
runs-on: ubuntu-latest
env:
DIALECT: sqlite
CI_COMBINATION: ${{ matrix.combination }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x
- run: /bin/bash ./setup/prepare-ci.sh
- name: Execute SSCCE
run: npm run ci
run: npm run _test
test-postgres:
strategy:
fail-fast: false
matrix:
postgres-version: [9.5, 10] # Does not work with 12
native: [true, false]
combination: ['v5', 'v6', 'v6 with TS']
name: Postgres ${{ matrix.postgres-version }}${{ matrix.native && ' (native)' || '' }} (${{ matrix.combination }})
node: [10, 14, 16]
name: Postgres ${{ matrix.postgres-version }}${{ matrix.native && ' (native)' || '' }} (sequelize 6 & 7, node ${{ matrix.node }})
runs-on: ubuntu-latest
services:
postgres:
Expand All @@ -46,25 +48,24 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
DIALECT: ${{ matrix.native && 'postgres-native' || 'postgres' }}
CI_COMBINATION: ${{ matrix.combination }}
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@v1
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: ${{ matrix.node }}
- run: /bin/bash ./setup/prepare-ci.sh
- name: Execute SSCCE
run: npm run ci
run: npm run _test
test-mysql-mariadb:
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" }'
combination: ['v5', 'v6', 'v6 with TS']
name: ${{ fromJson(matrix.db).name }} (${{ matrix.combination }})
name: ${{ fromJson(matrix.db).name }} (node ${{ matrix.node }})
runs-on: ubuntu-latest
services:
mysql:
Expand All @@ -79,23 +80,22 @@ jobs:
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 }}
CI_COMBINATION: ${{ matrix.combination }}
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@v1
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: ${{ matrix.node }}
- run: /bin/bash ./setup/prepare-ci.sh
- name: Execute SSCCE
run: npm run ci
run: npm run _test
test-mssql:
strategy:
fail-fast: false
matrix:
node: [10, 14, 16]
mssql-version: [2017, 2019]
combination: ['v5', 'v6', 'v6 with TS']
name: MSSQL ${{ matrix.mssql-version }} (${{ matrix.combination }})
name: MSSQL ${{ matrix.mssql-version }} (sequelize 6 & 7, node ${{ matrix.node }})
runs-on: ubuntu-latest
services:
mssql:
Expand All @@ -113,13 +113,12 @@ jobs:
--health-retries 10
env:
DIALECT: mssql
CI_COMBINATION: ${{ matrix.combination }}
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@v1
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: ${{ matrix.node }}
- run: /bin/bash ./setup/prepare-ci.sh
- name: Execute SSCCE
run: npm run ci
run: npm run _test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
npm-debug.log
ts-dist
yarn.lock
.idea
63 changes: 35 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
{
"name": "sequelize-sscce",
"description": "SSCCE repository for Sequelize",
"version": "0.0.0-development",
"private": true,
"engines": {
"node": ">=10.0.0"
},
"private": true,
"type": "commonjs",
"license": "MIT",
"dependencies": {
"chai": "^4",
"chai-as-promised": "^7",
"chai-datetime": "^1",
"chalk": "^2",
"cross-env": "^5",
"fs-jetpack": "^2",
"is-plain-object": "^3",
"json-stringify-safe": "^5",
"lodash.defaults": "^4",
"chalk": "^4.1.2",
"cross-env": "^7",
"fs-jetpack": "^4",
"sequelize": "^6",
"sinon": "^9",
"@sequelize/core": "^7.0.0-alpha.10",
"sinon": "^13",
"sinon-chai": "^3"
},
"scripts": {
"start": "cross-env LOCAL_SSCCE=true DIALECT=sqlite node setup/runner.js",
"ts-prep": "del-cli ts-dist && tsc && node setup/ts-setup.js",
"ts": "npm run ts-prep && cross-env LOCAL_TS_RUN=true npm start",
"do-replace": "node setup/lib-replacements.js --do",
"undo-replace": "node setup/lib-replacements.js --undo",
"ci": "node setup/runner.js",
"lint": "eslint ."
"_test": "ts-node setup/runner.ts",
"test:sqlite": "cross-env DIALECT=sqlite npm run _test",
"test:postgres": "cross-env DIALECT=postgres npm run _test",
"test:postgres-native": "cross-env DIALECT=postgres-native npm run _test",
"test:mariadb": "cross-env DIALECT=mariadb npm run _test",
"test:mysql": "cross-env DIALECT=mysql npm run _test",
"test:mssql": "cross-env DIALECT=mssql npm run _test",
"start:mariadb": "bash setup/mariadb/10.3/start.sh",
"start:mysql": "bash setup/mysql/8.0/start.sh",
"start:postgres": "bash setup/postgres/10/start.sh",
"start:mssql": "bash setup/mssql/2019/start.sh",
"stop:mariadb": "bash setup/mariadb/10.3/stop.sh",
"stop:mysql": "bash setup/mysql/8.0/stop.sh",
"stop:postgres": "bash setup/postgres/10/stop.sh",
"stop:mssql": "bash setup/mssql/2019/stop.sh",
"do-replace": "node setup/lib-replacements.ts --do",
"undo-replace": "node setup/lib-replacements.ts --undo",
"lint": "eslint . --fix"
},
"devDependencies": {
"@types/bluebird": "*",
"@ephys/eslint-config-typescript": "^14.1.1",
"@types/chai": "^4",
"@types/chai-as-promised": "^7",
"@types/chai-datetime": "^0.0.36",
"@types/chai-datetime": "^0.0.37",
"@types/lodash": "^4.14.178",
"@types/node": "^10",
"@types/sinon": "^9",
"@types/sinon": "^10",
"@types/sinon-chai": "^3",
"@types/validator": "*",
"@typescript-eslint/eslint-plugin": "2.16.0",
"@typescript-eslint/parser": "2.16.0",
"del-cli": "^3",
"eslint": "^6",
"eslint-plugin-node": "^10",
"sqlite3": "^4",
"typescript": "~4.1"
"del-cli": "^4",
"eslint": "^8",
"lodash": "^4.17.21",
"sqlite3": "^5",
"ts-node": "^10.4.0",
"typescript": "~4.5"
}
}
Loading

0 comments on commit a8ce25f

Please sign in to comment.