ci.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. name: CI
  2. on:
  3. push:
  4. branches:
  5. - renovate/**
  6. pull_request:
  7. merge_group:
  8. workflow_dispatch:
  9. # workflow_ref includes the branch ref & the file name
  10. # which means a unique run per branch for push & pull_request
  11. # pull_request_target would use the ref of the target branch, which would not be suitable
  12. concurrency:
  13. group: '${{ github.workflow_ref }}'
  14. cancel-in-progress: true
  15. jobs:
  16. install-and-build:
  17. # We already run the CI on "push" for renovate branches
  18. if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
  19. strategy:
  20. fail-fast: false
  21. matrix:
  22. node-version: [18, 20]
  23. name: Upload install and build artifact (Node ${{ matrix.node-version }})
  24. runs-on: ubuntu-latest
  25. steps:
  26. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  27. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  28. with:
  29. node-version: ${{ matrix.node-version }}
  30. cache: yarn
  31. - name: Install dependencies
  32. run: yarn install --immutable
  33. - name: Build sequelize
  34. run: yarn build
  35. - name: Reset NX cache
  36. run: yarn nx reset
  37. - name: Compress artifact
  38. run: tar -cf install-build-node-${{ matrix.node-version }}.tar ./packages/*/lib ./node_modules ./packages/*/node_modules
  39. - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  40. with:
  41. name: install-build-artifact-node-${{ matrix.node-version }}
  42. path: install-build-node-${{ matrix.node-version }}.tar
  43. retention-days: 1
  44. lint:
  45. name: Lint code
  46. runs-on: ubuntu-latest
  47. needs: install-and-build
  48. steps:
  49. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  50. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  51. with:
  52. node-version: 20.19.4
  53. cache: yarn
  54. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  55. with:
  56. name: install-build-artifact-node-20
  57. - name: Extract artifact
  58. run: tar -xf install-build-node-20.tar
  59. - run: yarn test:format
  60. unit-test:
  61. strategy:
  62. fail-fast: false
  63. matrix:
  64. node-version: [18, 20]
  65. name: Unit test all dialects (Node ${{ matrix.node-version }})
  66. runs-on: ubuntu-latest
  67. needs: lint
  68. steps:
  69. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  70. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  71. with:
  72. node-version: ${{ matrix.node-version }}
  73. cache: yarn
  74. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  75. with:
  76. name: install-build-artifact-node-${{ matrix.node-version }}
  77. - name: Extract artifact
  78. run: tar -xf install-build-node-${{ matrix.node-version }}.tar
  79. - name: ESM / CJS export equivalence
  80. run: yarn test-unit-esm
  81. - name: Unit tests (validator.js)
  82. run: yarn lerna run test-unit --scope=@sequelize/validator.js
  83. - name: Unit tests (cli)
  84. run: yarn lerna run test-unit --scope=@sequelize/cli
  85. - name: Unit tests (utils)
  86. run: yarn lerna run test-unit --scope=@sequelize/utils
  87. - name: Unit tests (core - mariadb)
  88. run: yarn lerna run test-unit-mariadb --scope=@sequelize/core
  89. - name: Unit tests (mariadb package)
  90. run: yarn lerna run test-unit --scope=@sequelize/mariadb
  91. - name: Unit tests (core - mysql)
  92. run: yarn lerna run test-unit-mysql --scope=@sequelize/core
  93. - name: Unit tests (mysql package)
  94. run: yarn lerna run test-unit --scope=@sequelize/mysql
  95. - name: Unit tests (core - postgres)
  96. run: yarn lerna run test-unit-postgres --scope=@sequelize/core
  97. - name: Unit tests (postgres package)
  98. run: yarn lerna run test-unit --scope=@sequelize/postgres
  99. - name: Unit tests (core - sqlite3)
  100. run: yarn lerna run test-unit-sqlite3 --scope=@sequelize/core
  101. - name: Unit tests (core - mssql)
  102. run: yarn lerna run test-unit-mssql --scope=@sequelize/core
  103. - name: Unit tests (mssql package)
  104. run: yarn lerna run test-unit --scope=@sequelize/mssql
  105. - name: Unit tests (core - db2)
  106. run: yarn lerna run test-unit-db2 --scope=@sequelize/core
  107. - name: Unit tests (core - ibmi)
  108. run: yarn lerna run test-unit-ibmi --scope=@sequelize/core
  109. - name: Unit tests (core - snowflake)
  110. run: yarn lerna run test-unit-snowflake --scope=@sequelize/core
  111. - name: SQLite SSCCE
  112. run: yarn sscce-sqlite3
  113. test-win:
  114. strategy:
  115. fail-fast: false
  116. matrix:
  117. node-version: [18, 20]
  118. name: Build and test on Windows (Node ${{ matrix.node-version }})
  119. runs-on: windows-latest
  120. needs: lint # don't bother running if lint tests fail
  121. steps:
  122. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  123. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  124. with:
  125. node-version: ${{ matrix.node-version }}
  126. cache: yarn
  127. - name: Install dependencies
  128. run: yarn install --immutable
  129. - name: Build sequelize
  130. run: yarn build
  131. - name: Unit tests
  132. run: yarn lerna run test-unit
  133. - name: SSCCE
  134. run: yarn sscce-sqlite3
  135. - name: Integration tests (sqlite3)
  136. run: yarn lerna run test-integration-sqlite3 --scope=@sequelize/core
  137. docs:
  138. name: Generate TypeDoc
  139. runs-on: ubuntu-latest
  140. needs: lint
  141. steps:
  142. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  143. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  144. with:
  145. node-version: 20.19.4
  146. cache: yarn
  147. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  148. with:
  149. name: install-build-artifact-node-20
  150. - name: Extract artifact
  151. run: tar -xf install-build-node-20.tar
  152. - run: yarn docs
  153. test-typings:
  154. strategy:
  155. fail-fast: false
  156. matrix:
  157. ts-version: ['5.5', '5.6', '5.7', '5.8']
  158. name: TS Typings (${{ matrix.ts-version }})
  159. runs-on: ubuntu-latest
  160. needs: lint
  161. steps:
  162. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  163. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  164. with:
  165. node-version: 20.19.4
  166. cache: yarn
  167. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  168. with:
  169. name: install-build-artifact-node-20
  170. - name: Extract artifact
  171. run: tar -xf install-build-node-20.tar
  172. - name: Install TypeScript
  173. run: yarn add typescript@~${{ matrix.ts-version }}
  174. - name: Typing Tests
  175. run: yarn test-typings
  176. test-sqlite3:
  177. strategy:
  178. fail-fast: false
  179. matrix:
  180. node-version: [18, 20]
  181. name: sqlite3 (Node ${{ matrix.node-version }})
  182. runs-on: ubuntu-latest
  183. needs: [unit-test, test-typings]
  184. env:
  185. DIALECT: sqlite3
  186. steps:
  187. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  188. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  189. with:
  190. node-version: ${{ matrix.node-version }}
  191. cache: yarn
  192. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  193. with:
  194. name: install-build-artifact-node-${{ matrix.node-version }}
  195. - name: Extract artifact
  196. run: tar -xf install-build-node-${{ matrix.node-version }}.tar
  197. - name: Integration Tests
  198. run: yarn lerna run test-integration --scope=@sequelize/core
  199. test-postgres:
  200. strategy:
  201. fail-fast: false
  202. matrix:
  203. node-version: [18, 20]
  204. postgres-version: [oldest, latest]
  205. minify-aliases: [true, false]
  206. native: [true, false]
  207. name: postgres ${{ matrix.postgres-version }}${{ matrix.native && ' (native)' || '' }} (Node ${{ matrix.node-version }})${{ matrix.minify-aliases && ' (minified aliases)' || '' }}
  208. runs-on: ubuntu-latest
  209. needs: [unit-test, test-typings]
  210. env:
  211. DIALECT: ${{ matrix.native && 'postgres-native' || 'postgres' }}
  212. SEQ_PG_MINIFY_ALIASES: ${{ matrix.minify-aliases && '1' || '' }}
  213. steps:
  214. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  215. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  216. with:
  217. node-version: ${{ matrix.node-version }}
  218. cache: yarn
  219. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  220. with:
  221. name: install-build-artifact-node-${{ matrix.node-version }}
  222. - name: Extract artifact
  223. run: tar -xf install-build-node-${{ matrix.node-version }}.tar
  224. - name: Install pg-native
  225. run: yarn workspace @sequelize/core add pg-native
  226. if: matrix.native
  227. - run: yarn start-postgres-${{ matrix.postgres-version }}
  228. - name: Integration Tests
  229. run: yarn lerna run test-integration --scope=@sequelize/core
  230. test-oldest-latest:
  231. strategy:
  232. fail-fast: false
  233. matrix:
  234. node-version: [18, 20]
  235. database-version: [oldest, latest]
  236. dialect: [mysql, mariadb, db2]
  237. name: ${{ matrix.dialect }} ${{ matrix.database-version }} (Node ${{ matrix.node-version }})
  238. runs-on: ubuntu-latest
  239. needs: [unit-test, test-typings]
  240. env:
  241. DIALECT: ${{ matrix.dialect }}
  242. steps:
  243. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  244. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  245. with:
  246. node-version: ${{ matrix.node-version }}
  247. cache: yarn
  248. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  249. with:
  250. name: install-build-artifact-node-${{ matrix.node-version }}
  251. - name: Extract artifact
  252. run: tar -xf install-build-node-${{ matrix.node-version }}.tar
  253. - run: yarn start-${{ matrix.dialect }}-${{ matrix.database-version }}
  254. - name: Integration Tests
  255. run: yarn lerna run test-integration --scope=@sequelize/core
  256. test-mssql-latest:
  257. strategy:
  258. fail-fast: false
  259. matrix:
  260. node-version: [18, 20]
  261. name: mssql latest (Node ${{ matrix.node-version }})
  262. runs-on: ubuntu-latest
  263. needs: [unit-test, test-typings]
  264. env:
  265. DIALECT: mssql
  266. steps:
  267. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  268. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  269. with:
  270. node-version: ${{ matrix.node-version }}
  271. cache: yarn
  272. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  273. with:
  274. name: install-build-artifact-node-${{ matrix.node-version }}
  275. - name: Extract artifact
  276. run: tar -xf install-build-node-${{ matrix.node-version }}.tar
  277. - run: yarn start-mssql-latest
  278. - name: Integration Tests
  279. run: yarn lerna run test-integration --scope=@sequelize/core
  280. # TODO: the following CI job is disabled due to mssql 2017 Docker image not working with ubuntu-22.04 or later. See https://github.com/sequelize/sequelize/pull/17772
  281. # test-mssql-oldest:
  282. # strategy:
  283. # fail-fast: false
  284. # matrix:
  285. # node-version: [18, 20]
  286. # name: mssql oldest (Node ${{ matrix.node-version }})
  287. # runs-on: ubuntu-20.04
  288. # needs: [unit-test, test-typings]
  289. # env:
  290. # DIALECT: mssql
  291. # steps:
  292. # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  293. # - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
  294. # with:
  295. # node-version: ${{ matrix.node-version }}
  296. # cache: yarn
  297. # - uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
  298. # with:
  299. # name: install-build-artifact-node-${{ matrix.node-version }}
  300. # - name: Extract artifact
  301. # run: tar -xf install-build-node-${{ matrix.node-version }}.tar
  302. # - run: yarn start-mssql-oldest
  303. # - name: Integration Tests
  304. # run: yarn lerna run test-integration --scope=@sequelize/core
  305. release:
  306. name: Release
  307. runs-on: ubuntu-latest
  308. needs:
  309. # TODO: add test-mssql-oldest back here when it's uncommented
  310. [docs, test-sqlite3, test-postgres, test-oldest-latest, test-mssql-latest]
  311. if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
  312. env:
  313. NPM_TOKEN: '${{ secrets.NPM_TOKEN }}'
  314. steps:
  315. - name: Generate Sequelize Bot Token
  316. id: generate-token
  317. uses: actions/create-github-app-token@v1
  318. with:
  319. app-id: '${{ secrets.SEQUELIZE_BOT_APP_ID }}'
  320. private-key: '${{ secrets.SEQUELIZE_BOT_PRIVATE_KEY }}'
  321. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  322. with:
  323. # Number of commits to fetch. 0 indicates all history for all branches and tags.
  324. # We need the entire history to generate the changelog properly
  325. fetch-depth: 0
  326. # The credentials used for checkout are persisted
  327. # Lerna will use the same credentials later for "git push".
  328. # This must be done using the Sequelize bot.
  329. token: '${{ steps.generate-token.outputs.token }}'
  330. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  331. with:
  332. node-version: 20.19.4
  333. cache: yarn
  334. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  335. with:
  336. name: install-build-artifact-node-20
  337. - name: Extract artifact
  338. run: tar -xf install-build-node-20.tar
  339. - name: Configure git
  340. run: |
  341. git config --global user.name "github-actions[bot]"
  342. git config --global user.email "bot@sequelize.org"
  343. - name: Set npm auth token
  344. run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
  345. - run: yarn publish-all
  346. env:
  347. GITHUB_TOKEN: '${{ steps.generate-token.outputs.token }}'
  348. GH_TOKEN: '${{ steps.generate-token.outputs.token }}'
  349. - id: sequelize
  350. uses: sdepold/github-action-get-latest-release@aa12fcb2943e8899cbcc29ff6f73409b32b48fa1 # master
  351. with:
  352. repository: sequelize/sequelize
  353. - name: Notify channels
  354. run: |
  355. 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 }}}}'
  356. - name: Notify docs repo
  357. run: |
  358. 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"}'