diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 57766ac9..1ff0e90e 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -12,7 +12,7 @@ on: branches: [ master ] jobs: - jobs_001: + job_001: name: Validate framework package runs-on: ubuntu-latest @@ -41,10 +41,29 @@ jobs: working-directory: packages/framework run: dart test - jobs_002: + job_002: name: Validate ORM packages 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: - uses: actions/checkout@v2 @@ -116,3 +135,14 @@ jobs: working-directory: packages/orm/angel_orm_postgres 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 \ No newline at end of file diff --git a/packages/orm/angel_orm_postgres/example/main.dart b/packages/orm/angel_orm_postgres/example/main.dart index 772f7ca4..039d097a 100644 --- a/packages/orm/angel_orm_postgres/example/main.dart +++ b/packages/orm/angel_orm_postgres/example/main.dart @@ -7,7 +7,7 @@ void main() async { PgEndpoint( host: 'localhost', port: 5432, - database: 'orm_test', + database: Platform.environment['POSTGRES_DB'] ?? 'orm_test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123', ), diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index 3c3169f1..44d3265a 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -27,7 +27,8 @@ Future closePg(QueryExecutor executor) async { } Future connectToPostgres(Iterable 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', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123'); await conn.open(); @@ -43,7 +44,8 @@ Future connectToPostgres(Iterable schemas) async { Future connectToPostgresPool1( Iterable schemas) async { 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', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123'); } @@ -65,7 +67,7 @@ Future connectToPostgresPool( PgEndpoint( host: 'localhost', port: 5432, - database: 'orm_test', + database: Platform.environment['POSTGRES_DB'] ?? 'orm_test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123', ),