Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test github action #344

Closed
wants to merge 18 commits into from
29 changes: 7 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
npm ci
npm run lint

unit-tests:
unit-and-integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -39,29 +39,14 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
- name: Install dependencies
working-directory: ./query-connector
run: npm install
- name: Run tests
working-directory: ./query-connector
run: npm run test:unit

integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/checkout@v3
- name: Setup reporting action and run tests
uses: ArtiomTr/jest-coverage-report-action@v2
with:
node-version: ${{env.NODE_VERSION}}
- name: Install dependencies
working-directory: ./query-connector
run: npm install

- name: Run tests
working-directory: ./query-connector
run: npm run test:integration
test-script: npm run test:ci
working-directory: ./query-connector
skip-step: none

end-to-end-tests:
timeout-minutes: 15
Expand Down
2 changes: 2 additions & 0 deletions query-connector/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ certificates
/playwright-report/
/blob-report/
/playwright/.cache/
/coverage
report.json
10 changes: 8 additions & 2 deletions query-connector/integration.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/bin/bash

set -e # Exit immediately if a command exits with a non-zero status

docker compose down --volumes --remove-orphans
docker compose -f docker-compose-integration.yaml up -d

# wait for flyway to finish running before...
docker compose -f docker-compose-integration.yaml logs -f flyway | grep -q "Successfully applied\|No migration necessary"

BASE_CMD="DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db TEST_TYPE=integration jest "
# running our integration tests
DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db TEST_TYPE=integration jest --testPathPattern=tests/integration
if [ "$GENERATE_COVERAGE_REPORT" = "true" ]; then
JEST_CMD="$BASE_CMD --testPathIgnorePatterns='/e2e/' --ci --json --coverage --testLocationInResults --outputFile=report.json"
else
JEST_CMD="$BASE_CMD --testPathPattern=tests/integration"
fi
eval $JEST_CMD
JEST_EXIT_CODE=$?

# Teardown containers
Expand Down
1 change: 1 addition & 0 deletions query-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"start": "NODE_TLS_REJECT_UNAUTHORIZED=0 node .next/standalone/server.js",
"lint": "next lint",
"test": "npm run test:unit && npm run test:integration",
"test:ci": "GENERATE_COVERAGE_REPORT=true bash ./integration.sh",
"test:unit": "jest --testPathIgnorePatterns='/e2e/' '/integration/'",
"test:unit:watch": "jest --watch",
"test:integration": "bash ./integration.sh",
Expand Down
Loading