Skip to content

Commit

Permalink
Merge pull request #89 from wri/frontend/envvars
Browse files Browse the repository at this point in the history
Add API Key to frontend for testing
  • Loading branch information
demenech authored Nov 13, 2023
2 parents 950b087 + 010e726 commit fe66992
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 18 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion ckan-backend-dev/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions ckan-backend-dev/.env.frontend.example
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions ckan-backend-dev/ckan/scripts/cypress_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 4 additions & 9 deletions ckan-backend-dev/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
1 change: 0 additions & 1 deletion deployment/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ WORKDIR /usr/src/app
ARG NEXTAUTH_SECRET
ARG NEXTAUTH_URL
ARG CKAN_URL
ARG SYS_ADMIN_API_KEY

COPY . .

Expand Down
2 changes: 2 additions & 0 deletions e2e-tests/cypress/e2e/auth.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ describe("Login modal", () => {

cy.get("#request-reset-button").click();

cy.contains("Password reset link sent to email address");

});
});

Expand Down

0 comments on commit fe66992

Please sign in to comment.