Skip to content

Commit 15cb476

Browse files
committed
add test ci workflow
1 parent 1c4f35f commit 15cb476

5 files changed

Lines changed: 50 additions & 7 deletions

File tree

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:16-alpine
16+
env:
17+
POSTGRES_DB: easy_auth_test
18+
POSTGRES_USER: test_user
19+
POSTGRES_PASSWORD: test_password
20+
ports:
21+
- 5432:5432
22+
options: >-
23+
--health-cmd "pg_isready -U test_user -d easy_auth_test"
24+
--health-interval 5s
25+
--health-timeout 3s
26+
--health-retries 5
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 22
34+
35+
- name: Install dependencies
36+
run: |
37+
cd packages/totp && npm ci
38+
cd ../auth && npm ci
39+
40+
- name: Run auth tests
41+
env:
42+
PGPORT: "5432"
43+
run: cd packages/auth && npm run test:run

packages/auth/src/__tests__/auth.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ describe("AuthContext", () => {
786786
beforeAll(async () => {
787787
pool = new Pool({
788788
host: "localhost",
789-
port: 5433,
789+
port: parseInt(process.env.PGPORT || "5433"),
790790
database: "easy_auth_test",
791791
user: "test_user",
792792
password: "test_password",
@@ -924,7 +924,7 @@ describe("Schema operations", () => {
924924
beforeAll(async () => {
925925
pool = new Pool({
926926
host: "localhost",
927-
port: 5433,
927+
port: parseInt(process.env.PGPORT || "5433"),
928928
database: "easy_auth_test",
929929
user: "test_user",
930930
password: "test_password",
@@ -1042,7 +1042,7 @@ describe("authenticateRequest", () => {
10421042
beforeAll(async () => {
10431043
pool = new Pool({
10441044
host: "localhost",
1045-
port: 5433,
1045+
port: parseInt(process.env.PGPORT || "5433"),
10461046
database: "easy_auth_test",
10471047
user: "test_user",
10481048
password: "test_password",
@@ -1149,7 +1149,7 @@ describe("Standalone role functions", () => {
11491149
beforeAll(async () => {
11501150
pool = new Pool({
11511151
host: "localhost",
1152-
port: 5433,
1152+
port: parseInt(process.env.PGPORT || "5433"),
11531153
database: "easy_auth_test",
11541154
user: "test_user",
11551155
password: "test_password",

packages/auth/src/__tests__/oauth-test-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare module "express-session" {
1313
export async function createTestDatabase() {
1414
const pool = new Pool({
1515
host: "localhost",
16-
port: 5433,
16+
port: parseInt(process.env.PGPORT || "5433"),
1717
database: "easy_auth_test",
1818
user: "test_user",
1919
password: "test_password",

packages/auth/src/__tests__/test-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare module "express-session" {
1313
export async function createTestDatabase() {
1414
const pool = new Pool({
1515
host: "localhost",
16-
port: 5433,
16+
port: parseInt(process.env.PGPORT || "5433"),
1717
database: "easy_auth_test",
1818
user: "test_user",
1919
password: "test_password",

packages/auth/src/__tests__/two-factor-test-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare module "express-session" {
1313
export async function createTestDatabase() {
1414
const pool = new Pool({
1515
host: "localhost",
16-
port: 5433,
16+
port: parseInt(process.env.PGPORT || "5433"),
1717
database: "easy_auth_test",
1818
user: "test_user",
1919
password: "test_password",

0 commit comments

Comments
 (0)