Skip to content

Commit

Permalink
test: api
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jun 27, 2024
1 parent bd314c8 commit eb5d666
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,70 @@ jobs:
- name: Lint Unused Exports
run: npm run lint:unused-exports

api-test:
strategy:
fail-fast: false
matrix:
suite: [api]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
env:
PGHOST: 127.0.0.1
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: postgres
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'api/.nvmrc'

- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm ci --audit=false

- name: Setup integration environment
run: |
sudo ufw disable
docker-compose -f docker/docker-compose.dev.postgres.yml up -d
docker-compose -f docker/docker-compose.dev.postgres.yml logs -t -f --no-color &> docker-compose-logs.txt &
- name: Run tests
run: npm run test:${{ matrix.suite }} -- --coverage

# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}

- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()

- name: Teardown integration environment
run: docker-compose -f docker/docker-compose.dev.postgres.yml down -v -t 0
if: always()

runehook-test:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion api/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "node dist/src/index.js",
"start-ts": "ts-node ./src/index.ts",
"test": "jest --runInBand",
"test:api": "npm run test -- ./tests/api/",
"generate:git-info": "rimraf .git-info && node_modules/.bin/api-toolkit-git-info",
"lint:eslint": "eslint . --ext .ts,.tsx -f unix",
"lint:prettier": "prettier --check src/**/*.ts tests/**/*.ts",
Expand Down
File renamed without changes.

0 comments on commit eb5d666

Please sign in to comment.