From 780480d50ae7f6b1f059b9b7a69fed3e074d87cb Mon Sep 17 00:00:00 2001 From: aasim Date: Tue, 23 Apr 2024 18:21:25 -0400 Subject: [PATCH] testing new docker-compose and workflow settings for service --- .github/workflows/pr_ci_frontend.yaml | 57 ++++++++++++++++----------- docker-compose.yml | 15 +++++++ frontend/playwright.config.ts | 6 --- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pr_ci_frontend.yaml b/.github/workflows/pr_ci_frontend.yaml index be38a21ec..6b1131b8a 100644 --- a/.github/workflows/pr_ci_frontend.yaml +++ b/.github/workflows/pr_ci_frontend.yaml @@ -6,54 +6,65 @@ on: - main types: [opened, reopened, synchronize] +env: + NODE_VERSION: '14' + jobs: frontend: name: Run PR Frontend Check runs-on: ubuntu-latest + environment: dev + + services: + app: # This is the service for the web server needed for Playwright tests + image: docker-compose.yml + env: + FRONTEND_PORT: ${{ secrets.FRONTEND_PORT }} + BACKEND_PORT: ${{ secrets.BACKEND_PORT }} + DATABASE_PORT: ${{ secrets.DATABASE_PORT }} + DATABASE_HOST: ${{ secrets.DATABASE_HOST }} + DATABASE_NAME: ${{ secrets.DATABASE_NAME }} + DATABASE_USER: ${{ secrets.DATABASE_USER }} + DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} + DJANGO_ALLOWED_HOSTS: ${{ secrets.DJANGO_ALLOWED_HOSTS }} + DEBUG: ${{ secrets.DEBUG }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} + ports: + - ${{ secrets.FRONTEND_PORT }}:${{ secrets.FRONTEND_PORT }} + options: --env-file .env.dev up --build + steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node environment uses: actions/setup-node@v4 - - - name: Install Yarn - uses: borales/actions-yarn@v5 with: - cmd: install - dir: "frontend" + node-version: ${{ env.NODE_VERSION }} - - name: Install Prettier - run: yarn add prettier + - name: Install Yarn and dependencies + working-directory: ./frontend + run: yarn install - name: Run Prettier - Formatting check working-directory: ./frontend - run: | - yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore + run: yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore - name: Run Type Check - if: always() - uses: borales/actions-yarn@v4 - with: - cmd: nuxi typecheck - dir: "frontend" + working-directory: ./frontend + run: yarn nuxi typecheck - name: Run eslint - Linting - if: always() - uses: borales/actions-yarn@v4 - with: - cmd: eslint . --ext .js,.vue - dir: "frontend" + working-directory: ./frontend + run: yarn eslint . --ext .js,.vue - name: Install Playwright Browsers working-directory: ./frontend - run: | - yarn playwright install --with-deps + run: yarn playwright install --with-deps - name: Run Playwright tests working-directory: ./frontend - run: | - yarn playwright test + run: yarn playwright test - name: Upload Playwright report if: always() diff --git a/docker-compose.yml b/docker-compose.yml index d29cb3171..f8c8dffc8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,6 +24,11 @@ services: - SECRET_KEY=${SECRET_KEY} depends_on: - db + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:${BACKEND_PORT}/health/ || exit 1"] + interval: 10s + timeout: 5s + retries: 5 frontend: env_file: @@ -37,6 +42,11 @@ services: ports: - "${FRONTEND_PORT}:${FRONTEND_PORT}" - "24678:24678" + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:${FRONTEND_PORT}/ || exit 1"] + interval: 10s + timeout: 5s + retries: 5 db: env_file: @@ -49,3 +59,8 @@ services: - POSTGRES_PASSWORD=${DATABASE_PASSWORD} ports: - "${DATABASE_PORT}:${DATABASE_PORT}" + healthcheck: + test: ["CMD", "pg_isready", "-U", "${DATABASE_USER}"] + interval: 10s + timeout: 5s + retries: 5 diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index 6439f3f9d..7e39a38d8 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -94,10 +94,4 @@ export default defineConfig({ // url: 'http://127.0.0.1:3000', // reuseExistingServer: !process.env.CI, // }, - webServer: { - command: "docker compose --env-file ../.env.dev up --build", - port: 3000, - timeout: 120 * 1000, - reuseExistingServer: !process.env.CI, - }, });