mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +03:00
502 lines
13 KiB
YAML
502 lines
13 KiB
YAML
name: Continuous Integration
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- 'doc/**'
|
|
tags-ignore:
|
|
- '*.*'
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'doc/**'
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: './go.mod'
|
|
- name: Run linters
|
|
uses: golangci/golangci-lint-action@v5
|
|
with:
|
|
args: --verbose
|
|
|
|
unit:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go: ['1.23', '1.24']
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Run cmd tests
|
|
run: go test -race ./...
|
|
working-directory: cmd
|
|
- name: Run dialect tests
|
|
run: go test -race ./...
|
|
working-directory: dialect
|
|
- name: Run schema tests
|
|
run: go test -race ./...
|
|
working-directory: schema
|
|
- name: Run loader tests
|
|
run: go test -race ./...
|
|
working-directory: entc/load
|
|
- name: Run codegen tests
|
|
run: go test -race ./...
|
|
working-directory: entc/gen
|
|
- name: Run example tests
|
|
working-directory: examples
|
|
run: go test -race ./...
|
|
|
|
generate:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: './go.mod'
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Run go generate
|
|
run: go generate ./... && go mod tidy
|
|
- name: Run go generate on examples directory
|
|
working-directory: examples
|
|
run: go generate ./... && go mod tidy
|
|
- name: Run go generate on integration directory
|
|
working-directory: entc/integration
|
|
run: go generate ./... && go mod tidy
|
|
- name: Check generated files
|
|
run: |
|
|
status=$(git status --porcelain)
|
|
if [ -n "$status" ]; then
|
|
echo "you need to run 'go generate ./...' in root and 'examples' dirs and commit the changes"
|
|
echo "$status"
|
|
git --no-pager diff
|
|
exit 1
|
|
fi
|
|
|
|
integration:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mysql56:
|
|
image: mysql:5.6.35
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 3306:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
mysql57:
|
|
image: mysql:5.7.26
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 3307:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
mysql8:
|
|
image: mysql:8
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 3308:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
maria:
|
|
image: mariadb:10.4 # Temporary to unblock PRs from failing.
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 4306:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
maria102:
|
|
image: mariadb:10.2.32
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 4307:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
maria103:
|
|
image: mariadb:10.3.13
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 4308:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
postgres10:
|
|
image: postgres:10
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5430:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres11:
|
|
image: postgres:11
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5431:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres12:
|
|
image: postgres:12.3
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres13:
|
|
image: postgres:13.1
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5433:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres14:
|
|
image: postgres:14
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5434:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres15:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5435:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres16:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5436:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres17:
|
|
image: postgres:17
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5437:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
gremlin-server:
|
|
image: entgo/gremlin-server
|
|
ports:
|
|
- 8182:8182
|
|
options: >-
|
|
--health-cmd "netstat -an | grep -q 8182"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: './go.mod'
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Run integration tests
|
|
working-directory: entc/integration
|
|
run: go test -race -count=2 ./...
|
|
|
|
migration:
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.ref != 'refs/heads/master' }}
|
|
services:
|
|
mysql56:
|
|
image: mysql:5.6.35
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 3306:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
mysql57:
|
|
image: mysql:5.7.26
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 3307:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
mysql8:
|
|
image: mysql:8
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 3308:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
maria:
|
|
image: mariadb:10.4 # Temporary to unblock PRs from failing.
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 4306:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
maria102:
|
|
image: mariadb:10.2.32
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 4307:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
maria103:
|
|
image: mariadb:10.3.13
|
|
env:
|
|
MYSQL_DATABASE: test
|
|
MYSQL_ROOT_PASSWORD: pass
|
|
ports:
|
|
- 4308:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ppass"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
postgres10:
|
|
image: postgres:10
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5430:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres11:
|
|
image: postgres:11
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5431:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres12:
|
|
image: postgres:12.3
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres13:
|
|
image: postgres:13.1
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5433:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres14:
|
|
image: postgres:14
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5434:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres15:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5435:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres16:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5436:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
postgres17:
|
|
image: postgres:17
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5437:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
gremlin-server:
|
|
image: entgo/gremlin-server
|
|
ports:
|
|
- 8182:8182
|
|
options: >-
|
|
--health-cmd "netstat -an | grep -q 8182"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: './go.mod'
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Checkout origin/master
|
|
run: git checkout origin/master
|
|
- name: Run integration on origin/master
|
|
working-directory: entc/integration
|
|
run: go test -race -count=2 ./...
|
|
- name: Checkout previous HEAD
|
|
run: git checkout -
|
|
- name: Run integration on HEAD
|
|
working-directory: entc/integration
|
|
run: go test -race -count=2 ./...
|