From 56ca1c022963c4f8519d14ebd2f101b50fa08076 Mon Sep 17 00:00:00 2001 From: Melle Boersma Date: Sun, 18 Aug 2024 14:22:04 +0200 Subject: [PATCH] Add github action --- .github/workflows/main.yml | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..fcb9e24 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,59 @@ +name: CI Pipeline + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:latest + env: + POSTGRES_DB: test_db + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/test_db + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install dependencies + run: npm install + + - name: Run linter + run: npm run lint + + - name: Wait for Postgres to be ready + run: | + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for postgres..." + sleep 1 + done + + - name: Run tests with coverage + run: npm run test:coverage + + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: coverage \ No newline at end of file