diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 90bbb3522..f69eb11a5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,8 @@ jobs: mask-password: 'true' - name: Add CKAN url to hosts run: sudo echo "127.0.0.1 ckan-dev" | sudo tee -a /etc/hosts + - name: Add Frontend url to hosts + run: sudo echo "127.0.0.1 frontend" | sudo tee -a /etc/hosts - name: Build and push CKAN image to ECR env: REGISTRY: ${{ steps.login-ecr.outputs.registry }} @@ -51,16 +53,17 @@ jobs: --build-arg NEXTAUTH_SECRET=${{ secrets.DEV_FRONTEND_NEXTAUTH_SECRET }} \ --build-arg NEXTAUTH_URL=${{ secrets.DEV_FRONTEND_NEXTAUTH_URL }} \ --build-arg CKAN_URL=${{ secrets.DEV_FRONTEND_CKAN_URL }} \ - --build-arg SYS_ADMIN_API_KEY=${{ secrets.SYS_ADMIN_API_KEY }} \ deployment/frontend docker push $REGISTRY/$FRONTEND_REPO:$IMAGE_TAG - name: Set up Docker Containers env: CKAN_IMAGE: '${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_CKAN_REPO }}:${{ github.sha }}' - MINIO_ROOT_USER: 'minioadmin' - MINIO_ROOT_PASSWORD: 'minioadmin' - run: docker compose -f docker-compose.test.yml --env-file .env.example up --build -d + run: | + docker compose -f docker-compose.test.yml --env-file .env.example up --build -d \ + ckan-dev datapusher db solr redis minio minio-setup working-directory: ./ckan-backend-dev + - name: Print Container names + run: docker ps -a - name: Cypress Install and CKAN setup uses: cypress-io/github-action@v6 with: @@ -69,16 +72,25 @@ jobs: node-version: 18 runTests: false working-directory: ./integration-tests + - name: Create sysadmin API for Authorization + run: bash ./ckan-backend-dev/ckan/scripts/cypress_setup.sh + - name: Set up Frontend Docker Container + env: + CKAN_IMAGE: '${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_CKAN_REPO }}:${{ github.sha }}' + run: docker compose -f docker-compose.test.yml --env-file .env.example up --build -d frontend + working-directory: ./ckan-backend-dev + - name: Print Container names + run: docker ps -a + - name: Print frontend logs + run: docker logs wri-frontend - name: Cypress Install and Frontend setup uses: cypress-io/github-action@v6 with: wait-on: 'http://localhost:3000' - wait-on-timeout: 120 + wait-on-timeout: 60 node-version: 18 runTests: false working-directory: ./e2e-tests - - name: Create sysadmin API for Authorization - run: bash ./ckan-backend-dev/ckan/scripts/cypress_setup.sh - name: Run Integration tests 🧪 uses: cypress-io/github-action@v6 with: @@ -89,6 +101,12 @@ jobs: with: command: npm run test working-directory: ./e2e-tests + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: cypress-screenshots + path: /home/runner/work/wri-odp/wri-odp/e2e-tests/cypress/screenshots + if-no-files-found: ignore - name: Copy run_unit_tests.sh run: docker cp ./ckan/scripts/run_unit_tests.sh ckan-wri:/srv/app/run_unit_tests.sh working-directory: ./ckan-backend-dev diff --git a/ckan-backend-dev/.env.example b/ckan-backend-dev/.env.example index 4afa455c5..bb264f73a 100644 --- a/ckan-backend-dev/.env.example +++ b/ckan-backend-dev/.env.example @@ -106,5 +106,14 @@ CKAN___SCHEMING__PRESETS=ckanext.wri.schema:presets.json CKANEXT__AUTH__INCLUDE_FRONTEND_LOGIN_TOKEN=True # custom auth -CKANEXT__WRI__ODP_URL=http://localhost:3000 +CKANEXT__WRI__ODP_URL=http://frontend:3000 +# Frontend Creds +NEXTAUTH_SECRET=secret +NEXTAUTH_URL=http://frontend:3000 +CKAN_URL=http://ckan-dev:5000 +S3_ACCESS_KEY_ID=${MINIO_ROOT_USER} +S3_SECRET_KEY_ID=${MINIO_ROOT_PASSWORD} +S3_BUCKET_NAME=ckan +S3_BUCKET_REGION=us-east-1 +SYS_ADMIN_API_KEY=CKAN_API_TOKEN \ No newline at end of file diff --git a/ckan-backend-dev/.env.frontend.example b/ckan-backend-dev/.env.frontend.example new file mode 100644 index 000000000..667024fad --- /dev/null +++ b/ckan-backend-dev/.env.frontend.example @@ -0,0 +1,11 @@ +# Minio +MINIO_ROOT_USER=minioadmin +MINIO_ROOT_PASSWORD=minioadmin +NEXTAUTH_SECRET=secret +NEXTAUTH_URL=http://localhost:3000 +CKAN_URL=http://ckan-dev:5000 +S3_ACCESS_KEY_ID=${MINIO_ROOT_USER} +S3_SECRET_KEY_ID=${MINIO_ROOT_PASSWORD} +S3_BUCKET_NAME=ckan +S3_BUCKET_REGION=us-east-1 +SYS_ADMIN_API_KEY=CKAN_API_TOKEN \ No newline at end of file diff --git a/ckan-backend-dev/ckan/scripts/cypress_setup.sh b/ckan-backend-dev/ckan/scripts/cypress_setup.sh index 244d68617..93fe1cc84 100755 --- a/ckan-backend-dev/ckan/scripts/cypress_setup.sh +++ b/ckan-backend-dev/ckan/scripts/cypress_setup.sh @@ -18,3 +18,4 @@ cp ../../../integration-tests/cypress.json.example ../../../integration-tests/cy # Replace the token placeholder with the generated token sed -i "s/CKAN_API_TOKEN/$token/g" ../../../integration-tests/cypress.json sed -i "s/CKAN_API_TOKEN/$token/g" ../../../e2e-tests/cypress.config.js +sed -i "s/CKAN_API_TOKEN/$token/g" ../../.env.example diff --git a/ckan-backend-dev/docker-compose.test.yml b/ckan-backend-dev/docker-compose.test.yml index 02522f2dc..1834986af 100755 --- a/ckan-backend-dev/docker-compose.test.yml +++ b/ckan-backend-dev/docker-compose.test.yml @@ -44,17 +44,12 @@ services: - NEXTAUTH_SECRET=secret - NEXTAUTH_URL=http://localhost:3000 - CKAN_URL=http://ckan-dev:5000 - environment: - - NEXTAUTH_SECRET=secret - - NEXTAUTH_URL=http://localhost:3000 - - CKAN_URL=http://ckan-dev:5000 - - S3_ACCESS_KEY_ID=${MINIO_ROOT_USER} - - S3_SECRET_KEY_ID=${MINIO_ROOT_PASSWORD} - - S3_BUCKET_NAME=ckan - - S3_BUCKET_REGION=us-east-1 - - SYS_ADMIN_API_KEY=${SYS_ADMIN_API_KEY} ports: - "0.0.0.0:3000:3000" + depends_on: + - ckan-dev + env_file: + - ".env.example" healthcheck: test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:3000"] diff --git a/deployment/frontend/Dockerfile b/deployment/frontend/Dockerfile index 63fbddf04..01333ac35 100644 --- a/deployment/frontend/Dockerfile +++ b/deployment/frontend/Dockerfile @@ -6,7 +6,6 @@ WORKDIR /usr/src/app ARG NEXTAUTH_SECRET ARG NEXTAUTH_URL ARG CKAN_URL -ARG SYS_ADMIN_API_KEY COPY . . diff --git a/e2e-tests/cypress/e2e/auth.cy.js b/e2e-tests/cypress/e2e/auth.cy.js index b1a876cda..dcc3f4d4f 100644 --- a/e2e-tests/cypress/e2e/auth.cy.js +++ b/e2e-tests/cypress/e2e/auth.cy.js @@ -38,6 +38,8 @@ describe("Login modal", () => { cy.get("#request-reset-button").click(); + cy.contains("Password reset link sent to email address"); + }); });