Skip to content

Commit

Permalink
chore: init mysql gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
fratzinger committed May 13, 2024
1 parent f6a9b20 commit 38176b6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ env:
POSTGRES_PASSWORD: password
POSTGRES_DB: sequelize

MYSQL_USER: sequelize
MYSQL_DATABASE: sequelize
MYSQL_PASSWORD: password

jobs:
build:

Expand All @@ -24,10 +28,27 @@ jobs:
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

mysql:
image: mysql:8.4
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_PASSWORD }}
MYSQL_USER: ${{ env.MYSQL_USER }}
MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }}
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries 5

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
database: ['sqlite', 'postgres']
database: ['sqlite', 'postgres', 'mysql']

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 0 additions & 5 deletions src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,6 @@ export class SequelizeAdapter<
} as UpdateOptions)
.catch(errorHandler) as [number, Model[]?];

if (instances?.length) {
// eslint-disable-next-line no-console
console.log('instanceof', instances[0] instanceof Model);
}

if (sequelizeOptions.returning === false) {
return []
}
Expand Down
16 changes: 10 additions & 6 deletions test/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default (DB?: 'postgres' | 'mysql' | string) => {
const logging: Options['logging'] = false;

if (DB === 'postgres') {
console.log(process.env.POSTGRES_DB, process.env.POSTGRES_USER, process.env.POSTGRES_PASSWORD)
return new Sequelize(
process.env.POSTGRES_DB ?? 'sequelize',
process.env.POSTGRES_USER ?? 'postgres',
Expand All @@ -17,11 +16,16 @@ export default (DB?: 'postgres' | 'mysql' | string) => {
}
);
} else if (DB === 'mysql') {
return new Sequelize('sequelize', 'root', '', {
host: '127.0.0.1',
dialect: 'mysql',
logging
});
return new Sequelize(
process.env.MYSQl_DATABASE ?? 'sequelize',
process.env.MYSQL_USER ?? 'root',
process.env.MYSQL_PASSWORD ?? '',
{
host: '127.0.0.1',
dialect: 'mysql',
logging
}
);
} else {
return new Sequelize('sequelize', '', '', {
dialect: 'sqlite',
Expand Down

0 comments on commit 38176b6

Please sign in to comment.