Setup ORM automated tests

This commit is contained in:
thomashii 2022-01-08 15:38:18 +08:00
parent 339fc08e15
commit ac91cde03d
3 changed files with 38 additions and 6 deletions

View file

@ -12,7 +12,7 @@ on:
branches: [ master ] branches: [ master ]
jobs: jobs:
jobs_001: job_001:
name: Validate framework package name: Validate framework package
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -41,10 +41,29 @@ jobs:
working-directory: packages/framework working-directory: packages/framework
run: dart test run: dart test
jobs_002: job_002:
name: Validate ORM packages name: Validate ORM packages
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Service containers to run with `runner-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -116,3 +135,14 @@ jobs:
working-directory: packages/orm/angel_orm_postgres working-directory: packages/orm/angel_orm_postgres
run: dart analyze . run: dart analyze .
- name: angel3_orm_postgres; Run tests
working-directory: packages/orm/angel3_orm_postgres
run: dart test
env:
# The hostname used to communicate with the PostgreSQL service container
POSTGRES_HOST: localhost
# The default PostgreSQL port
POSTGRES_PORT: 5432
POSTGRES_PASSWORD: postgres
POSTGRES_USERNAME: postgres
POSTGRES_DB: postgres

View file

@ -7,7 +7,7 @@ void main() async {
PgEndpoint( PgEndpoint(
host: 'localhost', host: 'localhost',
port: 5432, port: 5432,
database: 'orm_test', database: Platform.environment['POSTGRES_DB'] ?? 'orm_test',
username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test',
password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123',
), ),

View file

@ -27,7 +27,8 @@ Future<void> closePg(QueryExecutor executor) async {
} }
Future<PostgreSqlExecutor> connectToPostgres(Iterable<String> schemas) async { Future<PostgreSqlExecutor> connectToPostgres(Iterable<String> schemas) async {
var conn = PostgreSQLConnection('127.0.0.1', 5432, 'orm_test', var conn = PostgreSQLConnection(
'localhost', 5432, Platform.environment['POSTGRES_DB'] ?? 'orm_test',
username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test',
password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123'); password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123');
await conn.open(); await conn.open();
@ -43,7 +44,8 @@ Future<PostgreSqlExecutor> connectToPostgres(Iterable<String> schemas) async {
Future<PostgreSqlExecutorPool> connectToPostgresPool1( Future<PostgreSqlExecutorPool> connectToPostgresPool1(
Iterable<String> schemas) async { Iterable<String> schemas) async {
PostgreSQLConnection connectionFactory() { PostgreSQLConnection connectionFactory() {
return PostgreSQLConnection('127.0.0.1', 5432, 'orm_test', return PostgreSQLConnection(
'localhost', 5432, Platform.environment['POSTGRES_DB'] ?? 'orm_test',
username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test',
password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123'); password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123');
} }
@ -65,7 +67,7 @@ Future<PostgreSqlPoolExecutor> connectToPostgresPool(
PgEndpoint( PgEndpoint(
host: 'localhost', host: 'localhost',
port: 5432, port: 5432,
database: 'orm_test', database: Platform.environment['POSTGRES_DB'] ?? 'orm_test',
username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test',
password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123',
), ),