Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/actions/testing/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Testing'

inputs:
npm_token:
description: 'npm_token'
required: true
node_v:
type: string
required: false
default: "12.14.1"
redis_url:
type: string
required: false
db_url:
type: string
required: false

runs:
using: "composite"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: setup node
uses: actions/setup-node@master
with:
node-version: ${{ inputs.node_v }}

# install application dependencies
- uses: c-hive/gha-npm-cache@v1
- name: Install Dependencies
shell: bash
run: npm install
- name: Run tests
shell: bash
env:
REDIS_URL: ${{ inputs.redis_url }}
DB_URL: ${{ inputs.db_url }}
run: |
env IS_LOCAL_LOG=true npm run test
52 changes: 52 additions & 0 deletions .github/workflows/node-testing-with-dbs-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Node testing with DB and Redis workflow

on:
workflow_call:
secrets:
NPM_TOKEN:
required: true
inputs:
node_v:
type: string
required: false
default: "12.14.1"
env:
## Sets environment variable
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_OPTIONS: "--max-old-space-size=4096"

jobs:
testing:
# The type of runner that the job will run on
# Containers must run in Linux based operating systems
runs-on: app_backend

container: node:${{ inputs.node_v }}

# Service containers to add`
services:
# Label used to access the service container
redis:
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:5.7
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: '1234'
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Testing
uses: totango/shared-github-actions/.github/actions/testing@main
id: image
with:
node_v: ${{ inputs.node_v }}
npm_token: ${{ secrets.NPM_TOKEN }}
db_url: mysql
redis_url: redis
33 changes: 5 additions & 28 deletions .github/workflows/node-testing-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,11 @@ jobs:

container: node:${{ inputs.node_v }}

# Service containers to add`
services:
# Label used to access the service container
redis:
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Testing
Comment thread
PeshiTotango marked this conversation as resolved.
uses: totango/shared-github-actions/.github/actions/testing@main
id: image
with:
persist-credentials: false
- name: setup node
uses: actions/setup-node@master
with:
node-version: ${{ inputs.node_v }}

# install application dependencies
- uses: c-hive/gha-npm-cache@v1
- name: Install Dependencies
run: npm install
- name: Run tests
env:
REDIS_URL: 'redis'
run: |
env IS_LOCAL_LOG=true npm run test
node_v: ${{ inputs.node_v }}
npm_token: ${{ secrets.NPM_TOKEN }}