Skip to content

[pact] feat: Adding github action for contract test #65

[pact] feat: Adding github action for contract test

[pact] feat: Adding github action for contract test #65

name: Backend Service Tests
on:
push:
branches: [ "main" ]
paths:
- "backend/**"
pull_request:
branches: [ "main" ]
paths:
- "backend/**"
defaults:
run:
working-directory: ./backend
jobs:
build:
runs-on: ubuntu-latest
env:
API_URL: http://localhost:5000
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Create .env file
run: echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" > .env
- name: Start service in docker
run: |
npm run docker:up
- name: Wait for service to start
run: |
sleep 15
- name: Print application logs
run: docker-compose logs
- name: Test connectivity
run: curl ${API_URL}
- name: Run Service Tests
run: |
npm ci
npm run test:service
- name: Stop service in docker
run: |
npm run docker:down