chore(ci): simplify workflows (#11530)

* chore(ci): reorganize workflows

* chore(ci): prevent duplicate commit validation in PRs

* code review fixes

* code review #2
This commit is contained in:
Lucian Mocanu 2025-06-18 14:58:34 +02:00 committed by GitHub
parent 42e7cbe7da
commit b1e93f736d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 192 additions and 209 deletions

View File

@ -1,12 +1,13 @@
name: "CodeQL"
name: CodeQL
on:
push:
branches: ["master"]
branches:
- master
paths-ignore:
- "docs/**"
pull_request:
branches: ["master"]
branches:
- master
paths-ignore:
- "docs/**"
schedule:

76
.github/workflows/commit-validation.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: Commit Validation
on:
push:
branches:
- "**"
paths-ignore:
- "docs/**"
pull_request:
branches:
- "**"
paths-ignore:
- "docs/**"
workflow_dispatch:
jobs:
formatting:
if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.fork) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- run: npm ci
- run: npm run lint
- run: npm run format:ci
build:
if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.fork) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- run: npm ci
- run: npm run compile
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: build
path: build/
retention-days: 1
tests-linux:
needs: build
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
uses: ./.github/workflows/tests-linux.yml
with:
node-version: ${{matrix.node-version}}
tests-windows:
needs: build
uses: ./.github/workflows/tests-windows.yml
with:
node-version: 20
# Run with most databases possible to provide the coverage of the tests
coverage:
runs-on: ubuntu-latest
needs: [tests-linux, tests-windows]
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

View File

@ -1,13 +0,0 @@
name: coverage
on:
workflow_call
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

View File

@ -1,65 +0,0 @@
name: database-tests-compose
on:
workflow_call:
inputs:
node-version:
required: true
type: string
jobs:
oracle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose up oracle --detach
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
- uses: actions/download-artifact@v4
with:
name: build
path: build/
- run: npm ci
- run: cat ormconfig.sample.json | jq 'map(select(.name == "oracle"))' > ormconfig.json
- run: docker compose up oracle --no-recreate --wait
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: oracle-node:${{ inputs.node-version }}
parallel: true
sap:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose up hanaexpress --detach
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
- uses: actions/download-artifact@v4
with:
name: build
path: build/
- run: npm i
- run: cat ormconfig.sample.json | jq 'map(select(.name == "hanaexpress"))' > ormconfig.json
- run: docker compose up hanaexpress --no-recreate --wait
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: sap-node:${{ inputs.node-version }}
parallel: true

View File

@ -1,17 +1,18 @@
name: Publish Package to npmjs
on:
release:
types: [published]
types:
- published
workflow_dispatch:
jobs:
build:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: 20

View File

@ -1,84 +0,0 @@
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
# https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs
# https://docs.github.com/en/actions/use-cases-and-examples/using-containerized-services/creating-postgresql-service-containers
name: test
on:
push:
branches: ["**"]
paths-ignore:
- "docs/**"
pull_request:
branches: ["master"]
paths-ignore:
- "docs/**"
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- run: npm ci
- run: npm run lint
- run: npm run format:ci
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- run: npm ci
- run: npm run compile
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: build
path: build/
retention-days: 1
# These tests run in standard node containers with their db attached as a service
database-tests:
needs: build
strategy:
fail-fast: false
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [16, 18, 20] #, 22]
uses: ./.github/workflows/database-tests.yml
with:
node-version: ${{matrix.node-version}}
# These tests run with custom docker image attributes that can't be specified in a GHA service
database-tests-compose:
needs: build
strategy:
fail-fast: false
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [18, 20] #, 22]
uses: ./.github/workflows/database-tests-compose.yml
with:
node-version: ${{matrix.node-version}}
database-tests-windows:
needs: build
uses: ./.github/workflows/database-tests-windows.yml
# Run with most databases possible to provide the coverage of the tests
coverage:
if: ${{ always() }}
needs: [database-tests, database-tests-compose, database-tests-windows]
uses: ./.github/workflows/coverage.yml

View File

@ -1,14 +1,15 @@
name: database-tests
name: tests-linux
on:
workflow_call:
inputs:
node-version:
required: true
type: string
type: number
jobs:
cockroachdb:
# CockroachDB is slow, run less often so it doesn't block other workflows
if: ${{ inputs.node-version >= 20 }}
runs-on: ubuntu-latest
services:
@ -29,7 +30,7 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm ci
- run: cp .github/workflows/test/cockroachdb.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
@ -43,7 +44,7 @@ jobs:
services:
mongodb:
image: mongo:5.0.12
image: mongo:5.0.31
ports:
- "27017:27017"
@ -57,7 +58,7 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm ci
- run: cp .github/workflows/test/mongodb.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
@ -68,10 +69,6 @@ jobs:
mssql:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mssql-version: ["^9.1.1", "^10.0.1", "^11.0.1"]
services:
mssql:
@ -92,14 +89,13 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm install mssql@${{ matrix.mssql-version }}
- run: npm ci
- run: cp .github/workflows/test/mssql.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: mssql-client:${{ matrix.mssql-version }}-node:${{ inputs.node-version }}
flag-name: mssql-node:${{ inputs.node-version }}
parallel: true
mysql_mariadb:
@ -116,7 +112,7 @@ jobs:
MYSQL_PASSWORD: "test"
MYSQL_DATABASE: "test"
mariadb:
image: mariadb:10.10.3
image: mariadb:10.11.13
ports:
- "3307:3306"
env:
@ -135,7 +131,7 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm ci
- run: cp .github/workflows/test/mysql-mariadb.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
@ -157,7 +153,7 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm ci
- run: cp .github/workflows/test/better-sqlite3.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
@ -179,7 +175,7 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm ci
- run: cp .github/workflows/test/sqlite.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
@ -201,7 +197,7 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm ci
- run: cp .github/workflows/test/sqljs.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
@ -215,7 +211,9 @@ jobs:
strategy:
fail-fast: false
matrix:
postgis-version: ["14-3.5", "17-3.5"]
postgis-version:
- "14-3.5"
- "17-3.5"
services:
postgres:
@ -242,11 +240,67 @@ jobs:
with:
name: build
path: build/
- run: npm i
- run: npm ci
- run: cp .github/workflows/test/postgres.ormconfig.json ormconfig.json
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: postgres-postgis:${{ matrix.postgis-version }}-node:${{ inputs.node-version }}
flag-name: postgres:${{ matrix.postgis-version }}-node:${{ inputs.node-version }}
parallel: true
oracle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose up oracle --detach
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
- uses: actions/download-artifact@v4
with:
name: build
path: build/
- run: npm ci
- run: cat ormconfig.sample.json | jq 'map(select(.name == "oracle"))' > ormconfig.json
- run: docker compose up oracle --no-recreate --wait
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: oracle-node:${{ inputs.node-version }}
parallel: true
sap:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose up hanaexpress --detach
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
- uses: actions/download-artifact@v4
with:
name: build
path: build/
- run: npm ci
- run: cat ormconfig.sample.json | jq 'map(select(.name == "hanaexpress"))' > ormconfig.json
- run: docker compose up hanaexpress --no-recreate --wait
- run: npx nyc npm run test:ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: sap-node:${{ inputs.node-version }}
parallel: true

View File

@ -1,9 +1,12 @@
name: database-tests-windows
on: workflow_call
name: tests-windows
on:
workflow_call:
inputs:
node-version:
required: true
type: number
jobs:
better-sqlite3:
runs-on: windows-latest
@ -11,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: ${{ inputs.node-version }}
cache: "npm"
- uses: actions/download-artifact@v4
with:
@ -25,10 +28,9 @@ jobs:
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: better-sqlite3-windows
flag-name: better-sqlite3-node:${{ inputs.node-version }}-windows
parallel: true
sqlite:
runs-on: windows-latest
@ -36,7 +38,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: ${{ inputs.node-version }}
cache: "npm"
- uses: actions/download-artifact@v4
with:
@ -50,10 +52,9 @@ jobs:
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: sqlite-windows
flag-name: sqlite-node:${{ inputs.node-version }}-windows
parallel: true
sqljs:
runs-on: windows-latest
@ -61,7 +62,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: ${{ inputs.node-version }}
cache: "npm"
- uses: actions/download-artifact@v4
with:
@ -75,5 +76,5 @@ jobs:
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: sqljs-windows
flag-name: sqljs-node:${{ inputs.node-version }}-windows
parallel: true

View File

@ -13,7 +13,7 @@ services:
# mariadb
mariadb:
image: "mariadb:10.10.3"
image: "mariadb:10.11.13"
container_name: "typeorm-mariadb"
ports:
- "3307:3306"
@ -23,12 +23,24 @@ services:
MYSQL_PASSWORD: "test"
MYSQL_DATABASE: "test"
# postgres
postgres14:
# postgis is postgres + PostGIS (only). If you need additional extensions,
# it's probably time to create a purpose-built image.
image: "postgis/postgis:14-3.5"
container_name: "typeorm-postgres14"
ports:
- "5432:5432"
environment:
POSTGRES_USER: "test"
POSTGRES_PASSWORD: "test"
POSTGRES_DB: "test"
# postgres
postgres:
# mdillon/postgis is postgres + PostGIS (only). if you need additional
# extensions, it's probably time to create a purpose-built image with all
# necessary extensions. sorry, and thanks for adding support for them!
image: "postgis/postgis:14-3.3"
# postgis is postgres + PostGIS (only). If you need additional extensions,
# it's probably time to create a purpose-built image.
image: "postgis/postgis:17-3.5"
container_name: "typeorm-postgres"
ports:
- "5432:5432"
@ -59,7 +71,7 @@ services:
# oracle
oracle:
image: "container-registry.oracle.com/database/free:23.5.0.0-lite"
image: "container-registry.oracle.com/database/free:23.7.0.0-lite"
container_name: "typeorm-oracle"
ports:
- "1521:1521"
@ -108,7 +120,7 @@ services:
# mongodb
mongodb:
image: "mongo:5.0.12"
image: "mongo:5.0.31"
container_name: "typeorm-mongodb"
ports:
- "27017:27017"