update dockerfile #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Run test suits | |
on: | |
push: | |
branches: ['dev'] | |
pull_request: | |
branches: ['qa'] | |
env: | |
BRANCH_NAME: dev | |
jobs: | |
run-integration-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Start all microservices in docker container along with mongodb, postgres, redis and kafka | |
run: | | |
echo "Running all the docker containers..." | |
docker compose up -d | |
continue-on-error: ${{ env.ACT && true || false }} | |
- name: Run test cases | |
run: | | |
docker compose run node-app npm test | |
- name: create test report directory | |
run: | | |
pwd | |
ls | |
mkdir ./testResults | |
- name: Clean up Docker containers | |
if: success() || failure() | |
run: | | |
CONTAINER_ID=$(docker-compose ps -q node-app) | |
echo "Container ID: $CONTAINER_ID" | |
pwd | |
ls -R | |
docker cp "$CONTAINER_ID:/app/testResults/test-report.html" ./testResults | |
ls -R | |
docker compose down --rmi all -v | |
- name: Archive HTML Report | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: ./testResults | |
# # https://afsalbacker.medium.com/a-simple-api-test-automation-setup-using-newman-github-actions-and-slack-f70cfa15efe3 | |
# - name: Publish jest test report to slack | |
# if: success() || failure() | |
# env: | |
# SLACK_TOKEN: '${{ env.ACT && env.SLACK_TOKEN || secrets.SLACK_TOKEN }}' | |
# SLACK_CHANNEL_ID: '${{ env.ACT && env.SLACK_CHANNEL_ID || secrets.SLACK_CHANNEL_ID }}' | |
# uses: MeilCli/slack-upload-file@v3 | |
# with: | |
# slack_token: ${{ env.SLACK_TOKEN }} | |
# channel_id: ${{ env.SLACK_CHANNEL_ID }} | |
# file_path: ./testResults/test-report.html | |
# file_type: 'html' | |
- uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: test-results |