From c1596e02278b37e8fae8812026999ed6ab1746e0 Mon Sep 17 00:00:00 2001 From: "M.Palerme" Date: Wed, 27 Dec 2023 12:44:05 +0100 Subject: [PATCH] #26 use compose to test --- .github/workflows/test_unit.yml | 18 ++---------------- Dockerfile.test | 9 +++++++++ compose.test.yaml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 Dockerfile.test create mode 100644 compose.test.yaml diff --git a/.github/workflows/test_unit.yml b/.github/workflows/test_unit.yml index abefa74..4f701ef 100644 --- a/.github/workflows/test_unit.yml +++ b/.github/workflows/test_unit.yml @@ -42,22 +42,8 @@ jobs: steps: - name: Get repo uses: actions/checkout@v3 - - name: add client - run: | - sudo apt-get update -y - sudo apt-get install --yes postgresql-client - - name: check psql - run: psql --help - - name: Configure Database - run: | - psql -tc "CREATE TABLE proj(id SERIAL PRIMARY KEY);" - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: latest - cache: 'npm' - - name: Installation project s packages - run: npm ci + - name: Test in container with compose + run: docker compose -f "compose.test.yaml" up -d --build - name: Test & coverage run: npm run coverage - name: Report coverage diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..18c22c5 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,9 @@ +FROM node:latest +WORKDIR /EP2M2 +COPY . . +EXPOSE 3000 +RUN mkdir /results +ENV EP2M2_DIR_SHARE=/shareFile +ENV EP2M2_DIR_RESULT=/results +ENV PGHOST=db +CMD ["npm", "run", "test"] diff --git a/compose.test.yaml b/compose.test.yaml new file mode 100644 index 0000000..4dddd06 --- /dev/null +++ b/compose.test.yaml @@ -0,0 +1,33 @@ +services: + web: + build: .Dockerfile.test + ports: + - "80:3000" + volumes: + - shareFile:/shareFile + - ./test:/EP2M2/test + env_file: + - ./secrets/pg.env + + + api: + image: inraep2m2/service-p2m2tools-api:latest + container_name: p2m2ToolsApi + volumes: + - shareFile:/shareFile + + db: + image: postgres:latest + container_name: db + volumes: + - ./db/init.sql:/docker-entrypoint-initdb.d/init.sql + env_file: + - ./secrets/pg.env + +volumes: + shareFile: + + + + +