update workflows pipeline #36
This file contains hidden or 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: Node.js CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:13 | |
env: | |
POSTGRES_USER: bookdb_owner | |
POSTGRES_PASSWORD: FDXS5CHc1sRa | |
POSTGRES_DB: testdb | |
ports: | |
- 5432:5432 | |
options: --health-cmd "pg_isready -U bookdb_owner" --health-timeout 5s --health-start-period 5s | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- run: npm ci | |
- name: Set up environment variables | |
env: | |
DATABASE_URL: postgresql://bookdb_owner:FDXS5CHc1sRa@localhost:5432/testdb | |
run: echo "Database connection is set." | |
- run: npm run build --if-present | |
- run: npm test |