2021-04-15 14:48:17 +00:00
|
|
|
name: PostgreSQL service example
|
2021-04-15 08:45:07 +00:00
|
|
|
on: push
|
|
|
|
|
|
|
|
jobs:
|
2021-04-15 14:48:17 +00:00
|
|
|
# Label of the container job
|
2021-04-15 08:45:07 +00:00
|
|
|
build:
|
2021-04-15 14:48:17 +00:00
|
|
|
# Containers must run in Linux based operating systems
|
2021-04-15 08:45:07 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-04-15 14:48:17 +00:00
|
|
|
# Docker Hub image that `container-job` executes in
|
|
|
|
container: node:12-buster
|
|
|
|
env:
|
|
|
|
# The hostname used to communicate with the PostgreSQL service container
|
|
|
|
CODEGEN_DB_HOST: postgres
|
|
|
|
# The default PostgreSQL port
|
|
|
|
CODEGEN_DB_PORT: 5435
|
|
|
|
CODEGEN_DB_USER: codegenuser
|
|
|
|
CODEGEN_DB_PASSWOD: postgres
|
|
|
|
CODEGEN_DB_NAME: codegendb
|
|
|
|
|
|
|
|
# Service containers to run with `container-job`
|
|
|
|
services:
|
|
|
|
# Label used to access the service container
|
|
|
|
postgres:
|
|
|
|
# Docker Hub image
|
|
|
|
image: postgres
|
|
|
|
# Provide the password for postgres
|
|
|
|
env:
|
|
|
|
POSTGRES_PASSWORD: postgres
|
|
|
|
POSTGRES_USER: codegenuser
|
|
|
|
POSTGRES_DB: codegendb
|
|
|
|
port:
|
|
|
|
- 5435:5432
|
|
|
|
# Set health checks to wait until postgres has started
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
|
2021-04-15 08:45:07 +00:00
|
|
|
steps:
|
2021-04-15 14:48:17 +00:00
|
|
|
# Downloads a copy of the code in your repository before running CI tests
|
|
|
|
- name: Check out repository code
|
2021-04-15 08:45:07 +00:00
|
|
|
uses: actions/checkout@v2
|
2021-04-15 14:48:17 +00:00
|
|
|
|
2021-04-15 08:45:07 +00:00
|
|
|
# - name: Coursier cache
|
|
|
|
# uses: coursier/cache-action@v6
|
|
|
|
- name: Setup
|
|
|
|
uses: olafurpg/setup-scala@v10
|
|
|
|
with:
|
|
|
|
java-version: adopt@1.11
|
2021-04-15 14:48:17 +00:00
|
|
|
# - name: Connect to PostgreSQL
|
|
|
|
# # Runs a script that creates a PostgreSQL client, populates
|
|
|
|
# # the client with data, and retrieves data
|
|
|
|
# run: node client.js
|
|
|
|
- name: Migrate
|
|
|
|
run: csbt flyway/flywayMigrate
|
|
|
|
- name: Run Tests
|
|
|
|
run: csbt test
|
|
|
|
- name: Package
|
|
|
|
run: csbt docker:stage
|
|
|
|
# Environment variable used by the `client.js` script to create a new PostgreSQL client.
|