Skip to content

Commit

Permalink
Run app tests directly in cypress container 🌲
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Douglas committed Dec 20, 2023
1 parent 63ab06e commit 4075f9f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 84 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/CI-CD-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ jobs:
- name: Build Production Image
run: |
IMAGE_NAME=ghcr.io/hackforla/homeuniteus/app:latest
ENCODED_KEY=$(echo -n "${{ secrets.HUU_EC2_SSH_KEY }}" | base64)
docker build --build-arg VITE_HUU_API_BASE_URL=http://127.0.0.1:8080/api --build-arg ENV_KEY="$ENCODED_KEY" --target production --tag $IMAGE_NAME ./app
docker build --build-arg VITE_HUU_API_BASE_URL=http://127.0.0.1:8080/api --target production --tag $IMAGE_NAME ./app
docker push $IMAGE_NAME
test-api-mock:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -132,6 +131,13 @@ jobs:
image: ghcr.io/hackforla/homeuniteus/app:latest-test
env:
VITE_HUU_API_BASE_URL: http://backend:8080/api
container:
image: ghcr.io/hackforla/homeuniteus/app:latest-test
env:
CYPRESS_BASE_URL: http://frontend:4040
CYPRESS_USE_MOCK: false
CYPRESS_REAL_EMAIL: [email protected]
CYPRESS_REAL_PASSWORD: alskdf454#Adfa
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -143,17 +149,12 @@ jobs:
run: |
curl http://backend:8080/api/auth/signup/host -H "accept: application/json" -H "Content-Type: application/json" -d "{\"email\": \"[email protected]\", \"password\": \"alskdf454#Adfa\"}"
- name: Test without mocking
run: docker run --env CYPRESS_BASE_URL --env CYPRESS_USE_MOCK --env CYPRESS_REAL_EMAIL --env CYPRESS_REAL_PASSWORD ghcr.io/hackforla/homeuniteus/app:latest-test "npx cypress run"
env:
CYPRESS_BASE_URL: http://frontend:4040
CYPRESS_USE_MOCK: false
CYPRESS_REAL_EMAIL: [email protected]
CYPRESS_REAL_PASSWORD: alskdf454#Adfa
run: npx cypress run
deploy:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy
needs: [build-api, build-app, test-api-mock, test-api-nomock, test-app-mock, test-app-nomock]
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.deploy)
steps:
- uses: actions/checkout@v4
# Our deployment process is not dockerized. This means we need to rebuild the API and
# App as packages that can be installed onto the ec2 instance.
# In the future we may consider simply pulling the api:latest and app:latest images
# from the container repository and swapping the runtime containers.
uses: ./.github/workflows/build-deploy-ec2.yml
6 changes: 1 addition & 5 deletions .github/workflows/build-deploy-ec2.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: Build and Deploy to EC2
# workflow_dispatch means this workflow is manually triggered.
# The user will select the branch or tag from the GitHub UI to run this workflow against.
on:
workflow_dispatch:
workflow_call:
jobs:
run-tests:
uses: ./.github/workflows/run-tests.yml
build-api:
runs-on: ubuntu-latest
needs: run-tests
Expand Down
62 changes: 0 additions & 62 deletions .github/workflows/run-tests.yml

This file was deleted.

4 changes: 1 addition & 3 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN npm install
# generate bundles from source
RUN npm run build

# Testing image
# Testing image (consider cypress/included images to get cypress installed by default)
FROM cypress/base as development
WORKDIR /app
RUN apt-get update && apt-get install -y curl
Expand All @@ -30,9 +30,7 @@ CMD ["npx vite --host"]

# Runtime image
FROM nginx as production
ARG ENV_KEY

ENV ENV_KEY=${ENV_KEY}
# Copy client build to runtime image
COPY --from=builder /app/dist /usr/share/nginx/html/

Expand Down

0 comments on commit 4075f9f

Please sign in to comment.