Skip to content

feat: allow sequelize.sync() to create schema automatically if not exist #12724

feat: allow sequelize.sync() to create schema automatically if not exist

feat: allow sequelize.sync() to create schema automatically if not exist #12724

Workflow file for this run

name: CI
on:
push:
branches:
- renovate/**
pull_request:
merge_group:
workflow_dispatch:
# This configuration cancels previous runs if a new run is started on the same PR. Only one run at a time per PR.
# This does not affect pushes to the v7 branch itself, only PRs.
# 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:
install-and-build:
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
name: Upload install and build artifact (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Build sequelize
run: yarn build
- name: Reset NX cache
run: yarn nx reset
- name: Compress artifact
run: tar -cf install-build-node-${{ matrix.node-version }}.tar ./packages/*/lib ./node_modules ./packages/*/node_modules
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: install-build-artifact-node-${{ matrix.node-version }}
path: install-build-node-${{ matrix.node-version }}.tar
retention-days: 1
lint:
name: Lint code
runs-on: ubuntu-latest
needs: install-and-build
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-20
- name: Extract artifact
run: tar -xf install-build-node-20.tar
- run: yarn test:format
unit-test:
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
name: Unit test all dialects (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-${{ matrix.node-version }}
- name: Extract artifact
run: tar -xf install-build-node-${{ matrix.node-version }}.tar
- name: ESM / CJS export equivalence
run: yarn test-unit-esm
- name: Unit tests (validator.js)
run: yarn lerna run test-unit --scope=@sequelize/validator.js
- name: Unit tests (cli)
run: yarn lerna run test-unit --scope=@sequelize/cli
- name: Unit tests (utils)
run: yarn lerna run test-unit --scope=@sequelize/utils
- name: Unit tests (core - mariadb)
run: yarn lerna run test-unit-mariadb --scope=@sequelize/core
- name: Unit tests (mariadb package)
run: yarn lerna run test-unit --scope=@sequelize/mariadb
- name: Unit tests (core - mysql)
run: yarn lerna run test-unit-mysql --scope=@sequelize/core
- name: Unit tests (mysql package)
run: yarn lerna run test-unit --scope=@sequelize/mysql
- name: Unit tests (core - postgres)
run: yarn lerna run test-unit-postgres --scope=@sequelize/core
- name: Unit tests (postgres package)
run: yarn lerna run test-unit --scope=@sequelize/postgres
- name: Unit tests (core - sqlite3)
run: yarn lerna run test-unit-sqlite3 --scope=@sequelize/core
- name: Unit tests (core - mssql)
run: yarn lerna run test-unit-mssql --scope=@sequelize/core
- name: Unit tests (mssql package)
run: yarn lerna run test-unit --scope=@sequelize/mssql
- name: Unit tests (core - db2)
run: yarn lerna run test-unit-db2 --scope=@sequelize/core
- name: Unit tests (core - ibmi)
run: yarn lerna run test-unit-ibmi --scope=@sequelize/core
- name: Unit tests (core - snowflake)
run: yarn lerna run test-unit-snowflake --scope=@sequelize/core
- name: SQLite SSCCE
run: yarn sscce-sqlite3
test-win:
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
name: Build and test on Windows (Node ${{ matrix.node-version }})
runs-on: windows-latest
needs: lint # don't bother running if lint tests fail
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Build sequelize
run: yarn build
- name: Unit tests
run: yarn lerna run test-unit
- name: SSCCE
run: yarn sscce-sqlite3
- name: Integration tests (sqlite3)
run: yarn lerna run test-integration-sqlite3 --scope=@sequelize/core
docs:
name: Generate TypeDoc
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-20
- name: Extract artifact
run: tar -xf install-build-node-20.tar
- run: yarn docs
test-typings:
strategy:
fail-fast: false
matrix:
ts-version: ['5.1', '5.2', '5.3', '5.4']
name: TS Typings (${{ matrix.ts-version }})
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-20
- name: Extract artifact
run: tar -xf install-build-node-20.tar
- name: Install TypeScript
run: yarn add typescript@~${{ matrix.ts-version }}
- name: Typing Tests
run: yarn test-typings
test-sqlite3:
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
name: sqlite3 (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: [unit-test, test-typings]
env:
DIALECT: sqlite3
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-${{ matrix.node-version }}
- name: Extract artifact
run: tar -xf install-build-node-${{ matrix.node-version }}.tar
- name: Integration Tests
run: yarn lerna run test-integration --scope=@sequelize/core
test-postgres:
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
postgres-version: [oldest, latest]
minify-aliases: [true, false]
native: [true, false]
name: postgres ${{ matrix.postgres-version }}${{ matrix.native && ' (native)' || '' }} (Node ${{ matrix.node-version }})${{ matrix.minify-aliases && ' (minified aliases)' || '' }}
runs-on: ubuntu-latest
needs: [unit-test, test-typings]
env:
DIALECT: ${{ matrix.native && 'postgres-native' || 'postgres' }}
SEQ_PG_MINIFY_ALIASES: ${{ matrix.minify-aliases && '1' || '' }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-${{ matrix.node-version }}
- name: Extract artifact
run: tar -xf install-build-node-${{ matrix.node-version }}.tar
- name: Install pg-native
run: yarn workspace @sequelize/core add pg-native
if: matrix.native
- run: yarn start-postgres-${{ matrix.postgres-version }}
- name: Integration Tests
run: yarn lerna run test-integration --scope=@sequelize/core
test-oldest-latest:
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
database-version: [oldest, latest]
dialect: [mysql, mariadb, mssql, db2]
name: ${{ matrix.dialect }} ${{ matrix.database-version }} (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: [unit-test, test-typings]
env:
DIALECT: ${{ matrix.dialect }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-${{ matrix.node-version }}
- name: Extract artifact
run: tar -xf install-build-node-${{ matrix.node-version }}.tar
- run: yarn start-${{ matrix.dialect }}-${{ matrix.database-version }}
- name: Integration Tests
run: yarn lerna run test-integration --scope=@sequelize/core
release:
name: Release
runs-on: ubuntu-latest
needs: [docs, test-sqlite3, test-postgres, test-oldest-latest]
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
env:
NPM_TOKEN: '${{ secrets.NPM_TOKEN }}'
steps:
- name: Generate Sequelize Bot Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: '${{ secrets.SEQUELIZE_BOT_APP_ID }}'
private-key: '${{ secrets.SEQUELIZE_BOT_PRIVATE_KEY }}'
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# We need the entire history to generate the changelog properly
fetch-depth: 0
# The credentials used for checkout are persisted
# Lerna will use the same credentials later for "git push".
# This must be done using the Sequelize bot.
token: '${{ steps.generate-token.outputs.token }}'
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-build-artifact-node-20
- name: Extract artifact
run: tar -xf install-build-node-20.tar
- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "bot@sequelize.org"
- name: Set npm auth token
run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
- run: yarn publish-all
env:
GITHUB_TOKEN: '${{ steps.generate-token.outputs.token }}'
GH_TOKEN: '${{ steps.generate-token.outputs.token }}'
- id: sequelize
uses: sdepold/github-action-get-latest-release@aa12fcb2943e8899cbcc29ff6f73409b32b48fa1 # master
with:
repository: sequelize/sequelize
- name: Notify channels
run: |
curl -XPOST -u "sdepold:${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/sequelize/sequelize/dispatches --data '{"event_type":"Release notifier","client_payload":{"release-id": ${{ steps.sequelize.outputs.id }}}}'
- name: Notify docs repo
run: |
curl -XPOST -u "sdepold:${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/sequelize/website/dispatches --data '{"event_type":"Build website"}'