Skip to content

Commit 0e207c5

Browse files
authored
Merge pull request #11 from gobeam/fix/update_docs
docs: add workflow test badge in README.md and add e2e test command o…
2 parents e9291c5 + 57a0ce1 commit 0e207c5

6 files changed

Lines changed: 37 additions & 12 deletions

File tree

.github/actions/setvars/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: 'Set environment variables'
2+
description: 'Configures environment variables for a workflow'
3+
inputs:
4+
varFilePath:
5+
description: 'File path to variable file or directory. Defaults to ./.github/variables/* if none specified and runs against each file in that directory.'
6+
required: false
7+
default: ./.github/variables/*
8+
runs:
9+
using: "composite"
10+
steps:
11+
- run: |
12+
sed "" ${{ inputs.varFilePath }} >> $GITHUB_ENV
13+
shell: bash

.github/variables/myvars.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NODE_ENV=test
2+
DB_TYPE=postgres
3+
DB_HOST=localhost
4+
DB_PORT=5432
5+
DB_DATABASE_NAME=truthy_db
6+
DB_USERNAME=truthy_user
7+
DB_PASSWORD=truthypwd

.github/workflows/test.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: test
22

33
on: push
44

5-
jobs:
5+
jobs:
66
test:
77
runs-on: ubuntu-latest
88

@@ -15,13 +15,16 @@ jobs:
1515
POSTGRES_PASSWORD: truthypwd
1616
ports:
1717
- 5432:5432
18+
1819
redis:
1920
image: redis
2021
options: >-
2122
--health-cmd "redis-cli ping"
2223
--health-interval 10s
2324
--health-timeout 5s
2425
--health-retries 5
26+
ports:
27+
- 6379:6379
2528

2629
steps:
2730
- uses: actions/checkout@v2
@@ -31,15 +34,10 @@ jobs:
3134
with:
3235
node-version: 14.3.0
3336

34-
- name: Set environment variables
35-
uses: allenevans/set-env@v2.0.0
37+
- name: Set Environment Variables
38+
uses: ./.github/actions/setvars
3639
with:
37-
NODE_ENV: test
38-
DATABASE_HOST: 127.0.0.1
39-
DATABASE_PORT: ${{ job.services.postgres.ports[5432] }}
40-
DATABASE_NAME: truthy_db
41-
DATABASE_USER: truthy_user
42-
DATABASE_PASSWORD: truthypwd
40+
varFilePath: ./.github/variables/myvars.env
4341

4442
- name: Install dependencies
4543
run: npm install
@@ -48,4 +46,7 @@ jobs:
4846
run: npm run lint
4947

5048
- name: Run unit test
51-
run: npm run test:unit
49+
run: npm run test:unit
50+
51+
- name: Run e2e test
52+
run: npm run test:e2e

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<br>
1010
<p align="center">
1111
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/gobeam/truthy">
12+
<img alt="Workflow test" src="https://github.com/gobeam/truthy/actions/workflows/test.yml/badge.svg">
1213
<img alt="GitHub" src="https://img.shields.io/github/license/gobeam/truthy">
1314
<img alt="Lines of code" src="https://img.shields.io/tokei/lines/github/gobeam/truthy">
1415
<img src='https://www.codetriage.com/gobeam/truthy/badges/users.svg' alt='Open Source Helpers' />

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test:watch": "jest --config ./test/unit/jest-unit.json --watch",
2121
"test:cov": "jest --coverage",
2222
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
23-
"test:e2e": "jest --config ./test/e2e/jest-e2e.json",
23+
"test:e2e": "jest --config ./test/e2e/jest-e2e.json --runInBand --detectOpenHandles",
2424
"test:unit": "jest --config ./test/unit/jest-unit.json --runInBand",
2525
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config src/config/ormconfig.ts",
2626
"orm-create": "npm run typeorm migration:create -- -n",

test/factories/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ export class AppFactory {
114114
}
115115

116116
const setupRedis = async () => {
117-
const redis = new Redis({});
117+
const redis = new Redis({
118+
host: process.env.REDIS_HOST || 'localhost',
119+
port: parseInt(process.env.REDIS_PORT) || 6379
120+
});
118121
await redis.flushall();
119122
return redis;
120123
};

0 commit comments

Comments
 (0)