Skip to content

Commit

Permalink
Merge pull request #11 from gobeam/fix/update_docs
Browse files Browse the repository at this point in the history
docs: add workflow test badge in README.md and add e2e test command o…
  • Loading branch information
gobeam authored Mar 19, 2022
2 parents e9291c5 + 57a0ce1 commit 0e207c5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
13 changes: 13 additions & 0 deletions .github/actions/setvars/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Set environment variables'
description: 'Configures environment variables for a workflow'
inputs:
varFilePath:
description: 'File path to variable file or directory. Defaults to ./.github/variables/* if none specified and runs against each file in that directory.'
required: false
default: ./.github/variables/*
runs:
using: "composite"
steps:
- run: |
sed "" ${{ inputs.varFilePath }} >> $GITHUB_ENV
shell: bash
7 changes: 7 additions & 0 deletions .github/variables/myvars.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
NODE_ENV=test
DB_TYPE=postgres
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE_NAME=truthy_db
DB_USERNAME=truthy_user
DB_PASSWORD=truthypwd
21 changes: 11 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test

on: push

jobs:
jobs:
test:
runs-on: ubuntu-latest

Expand All @@ -15,13 +15,16 @@ jobs:
POSTGRES_PASSWORD: truthypwd
ports:
- 5432:5432

redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- uses: actions/checkout@v2
Expand All @@ -31,15 +34,10 @@ jobs:
with:
node-version: 14.3.0

- name: Set environment variables
uses: allenevans/[email protected]
- name: Set Environment Variables
uses: ./.github/actions/setvars
with:
NODE_ENV: test
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: ${{ job.services.postgres.ports[5432] }}
DATABASE_NAME: truthy_db
DATABASE_USER: truthy_user
DATABASE_PASSWORD: truthypwd
varFilePath: ./.github/variables/myvars.env

- name: Install dependencies
run: npm install
Expand All @@ -48,4 +46,7 @@ jobs:
run: npm run lint

- name: Run unit test
run: npm run test:unit
run: npm run test:unit

- name: Run e2e test
run: npm run test:e2e
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<br>
<p align="center">
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/gobeam/truthy">
<img alt="Workflow test" src="https://github.com/gobeam/truthy/actions/workflows/test.yml/badge.svg">
<img alt="GitHub" src="https://img.shields.io/github/license/gobeam/truthy">
<img alt="Lines of code" src="https://img.shields.io/tokei/lines/github/gobeam/truthy">
<img src='https://www.codetriage.com/gobeam/truthy/badges/users.svg' alt='Open Source Helpers' />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:watch": "jest --config ./test/unit/jest-unit.json --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/e2e/jest-e2e.json",
"test:e2e": "jest --config ./test/e2e/jest-e2e.json --runInBand --detectOpenHandles",
"test:unit": "jest --config ./test/unit/jest-unit.json --runInBand",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config src/config/ormconfig.ts",
"orm-create": "npm run typeorm migration:create -- -n",
Expand Down
5 changes: 4 additions & 1 deletion test/factories/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ export class AppFactory {
}

const setupRedis = async () => {
const redis = new Redis({});
const redis = new Redis({
host: process.env.REDIS_HOST || 'localhost',
port: parseInt(process.env.REDIS_PORT) || 6379
});
await redis.flushall();
return redis;
};
Expand Down

0 comments on commit 0e207c5

Please sign in to comment.