Skip to content

Commit 46f2630

Browse files
committed
feat: github action for otp provider unit tests
1 parent 383eb70 commit 46f2630

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Run OTP provider tests
2+
3+
on:
4+
push:
5+
branches: [SSOTEAM-2382-01]
6+
7+
jobs:
8+
otp-provider-test:
9+
runs-on: ubuntu-24.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Get yarn cache directory path
14+
id: yarn-cache-dir-path
15+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
16+
- name: Cache Node dependencies
17+
uses: actions/cache@v4
18+
id: yarn-cache
19+
with:
20+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
21+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22+
restore-keys: ${{ runner.os }}-yarn-
23+
24+
- name: Install asdf requirements
25+
run: |
26+
sudo apt-get install -y libssl-dev libreadline-dev uuid-dev
27+
28+
- name: Install asdf
29+
uses: asdf-vm/actions/setup@v3
30+
- name: Cache asdf tools
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
/home/runner/.asdf
35+
key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }}
36+
37+
- name: Install asdf
38+
uses: asdf-vm/actions/install@v3
39+
40+
- name: Install app specific asdf plugins
41+
run: |
42+
cat .tool-versions | cut -f 1 -d ' ' | xargs -n 1 asdf plugin-add || true
43+
asdf plugin-update --all
44+
asdf install
45+
asdf reshim
46+
working-directory: ./docker/otp-provider
47+
48+
- name: Install dependencies
49+
run: yarn install
50+
working-directory: ./docker/otp-provider
51+
52+
- name: Setup postgres
53+
env:
54+
PGUSER: postgres
55+
run: |
56+
pg_ctl start
57+
createdb runner || true
58+
chmod +x ./db-setup.sh
59+
./db-setup.sh otp_test
60+
working-directory: ./docker/otp-provider/.bin
61+
62+
- name: Run unit tests
63+
run: |
64+
yarn test
65+
working-directory: ./docker/otp-provider

docker/otp-provider/.bin/db-setup.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
if [[ -n "$1" ]]; then
3+
db="$1"
4+
else
5+
db="otp"
6+
fi
7+
8+
echo "SELECT 'CREATE DATABASE $db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$db')\gexec" | psql -U postgres -d postgres

0 commit comments

Comments
 (0)