Skip to content

style: just wrapped yaml strings #2

style: just wrapped yaml strings

style: just wrapped yaml strings #2

Workflow file for this run

# https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers#running-jobs-directly-on-the-runner-machine
# Bun github-action documentation
# https://bun.sh/guides/runtime/cicd
# https://github.com/oven-sh/setup-bun
# Resources used:
# - https://remarkablemark.org/blog/2021/03/14/setup-postgresql-in-github-actions/
name: testing::/apps/ds_auth
on:
# workflow_call makes the whole job re-usable by other workflows
workflow_call:
workflow_dispatch:
push:
branches: [ main ]
jobs:
# Label of the container job
testing_disclone_ds_auth:
name:
testing::ds_auth
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
services:
coruscant_db:
image: postgres
env:
POSTGRES_PASSWORD: 'password'
POSTGRES_DB: 'disclone'
POSTGRES_USER: 'ds_auth'
# 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/tcp
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: "step 1 - copy code into the github action runner"
# official github action => copy repository's code into runner
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: "step 1 1/2 - downloading the postgresql client"
# needs the --yes to autoconfirm on install, in order to not prompt 'are you sure?' because it would hang the runner
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: "step 1 2/2 - seeding the database "
working-directory: "apps/db"
# needed env for psql #could also do: export PGPASSWORD=password or PGPASSWORD=password psql --host....
env:
PGPASSWORD: password
run: |
psql --host localhost --username ds_auth --port 5432 --dbname disclone --file init_ds_auth.sql --echo-all --echo-errors --echo-queries
- name: "step 2 - setting-up bun"
# official bun action => sets up bun ( see top of the file for doc)
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: "step 3 - installing dependencies"
working-directory: "apps/ds_auth"
run: bun install
- name: "step 4 - run: bun test"
working-directory: "apps/ds_auth"
#.env.test will not be found because it's specified in the .gitignore, it's never moved to the runner
run: |
export NODE_ENV=development
export SECRET=supersecret
export PORT=4020
export POSTGRES_HOST=localhost
echo $POSTGRES_PORT
export POSTGRES_DB=disclone
export POSTGRES_USER=ds_auth
export POSTGRES_PASSWORD=password
export PASSWORD_PEPPER=pepper
bun test
env:
# The hostname used to communicate with the PostgreSQL service container
POSTGRES_HOST: 'coruscant_db'
# The default PostgreSQL port
POSTGRES_PORT: 5432
# the database we're talking to
POSTGRES_DB: 'disclone'
# the database user running commands
POSTGRES_USER: 'ds_auth'
# the password for our POSTGRES_USER
POSTGRES_PASSWORD: 'password'