Skip to content

Commit

Permalink
Merge pull request #17 from firmanJS/master
Browse files Browse the repository at this point in the history
Improve Github actions
  • Loading branch information
firmanJS authored Mar 8, 2021
2 parents bb7b0b9 + 684e87c commit 956c92d
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 71 deletions.
83 changes: 58 additions & 25 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
# node-version: [10.x, 12.x, 14.x, 15.x]
Expand All @@ -29,29 +25,66 @@ jobs:
node-version: ${{ matrix.node-version }}
# skip because using docker
# - run: npm install

- name: Create env file
run: |
touch .env
echo APP_PORT=${{ secrets.APP_PORT }} >> .env
echo MONGO_INITDB_DATABASE=${{ secrets.MONGO_INITDB_DATABASE }} >> .env
echo MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }} >> .env
echo MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }} >> .env
echo MONGO_PORT=${{ secrets.MONGO_PORT }} >> .env
echo TZ=${{ secrets.TZ }} >> .env
echo SECRET_KEY=${{ secrets.SECRET_KEY }} >> .env
echo NODE_ENV=${{ secrets.NODE_ENV }} >> .env
echo MONGO_SERVICE=${{ secrets.MONGO_SERVICE }} >> .env
echo AUTH_SOURCE=${{ secrets.AUTH_SOURCE }} >> .env

run-docker-compose:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} && install dependencies
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Build docker-compose
run: docker-compose -f docker-compose.yml up --build -d
- name: Create env file
run: |
touch .env
echo APP_PORT=${{ secrets.APP_PORT }} >> .env
echo MONGO_INITDB_DATABASE=${{ secrets.MONGO_INITDB_DATABASE }} >> .env
echo MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }} >> .env
echo MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }} >> .env
echo MONGO_PORT=${{ secrets.MONGO_PORT }} >> .env
echo TZ=${{ secrets.TZ }} >> .env
echo SECRET_KEY=${{ secrets.SECRET_KEY }} >> .env
echo NODE_ENV=${{ secrets.NODE_ENV }} >> .env
echo MONGO_SERVICE=${{ secrets.MONGO_SERVICE }} >> .env
echo AUTH_SOURCE=${{ secrets.AUTH_SOURCE }} >> .env
- name: Build docker-compose
run: docker-compose -f docker-compose.yml up --build -d

# - name: publish coverage
# uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageCommand: docker-compose exec boillerplate npm run coverage-report
# debug: true
# - name: Running test inside container docker
# run: docker exec -t boillerplate npm run test

- name: coverage
uses: codecov/codecov-action@v1
with:
name: actions ${{ matrix.node }}
fail_ci_if_error: false
codecov:
needs: run-docker-compose
runs-on: ubuntu-latest
steps:
- name: coverage
uses: codecov/codecov-action@v1
with:
name: actions ${{ matrix.node }}
fail_ci_if_error: false

# coverage:
# needs: [ codecov ]
# name: coverage
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# with:
# node-version: '14.x'
# - run: npm install
# - uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageCommand: npm run coverage-report
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language:
node_js
before_install:
- npm install -g codecov
script:
- istanbul cover ./node_modules/mocha/bin/_mocha --reporter lcovonly -- -R spec
- codecov
File renamed without changes.
1 change: 0 additions & 1 deletion helpers/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const successResponse = (res, msg, data) => res.status(200).json({
const customResponse = (res, code, msg, data) => {
log.info(msg)
res.status(code).json({
code,
message: msg,
data
})
Expand Down
21 changes: 21 additions & 0 deletions mocha.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"stats": {
"suites": 2,
"tests": 1,
"passes": 1,
"pending": 0,
"failures": 0,
"start": "2021-03-08T04:42:37.596Z",
"end": "2021-03-08T04:42:37.671Z",
"duration": 75
},
"failures": [],
"passes": [
{
"title": "it should login user invalid user",
"fullTitle": "Users /POST Login user it should login user invalid user",
"duration": 69
}
],
"skipped": []
}
Loading

0 comments on commit 956c92d

Please sign in to comment.