generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 21
130 lines (130 loc) · 4.37 KB
/
run-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Run API and App Tests
on:
pull_request:
branches: [main]
# This is also a reusable workflow that can be called from other workflows
workflow_call:
workflow_dispatch:
jobs:
build-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push API Image
run: |
IMAGE_NAME=ghcr.io/hackforla/homeuniteus/api:latest
docker build -t $IMAGE_NAME ./api
docker push $IMAGE_NAME
build-app:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Testing Image
run: |
IMAGE_NAME=ghcr.io/hackforla/homeuniteus/app:latest-test
docker build --build-arg VITE_HUU_API_BASE_URL=http://127.0.0.1:8080/api --target development --tag $IMAGE_NAME ./app
docker push $IMAGE_NAME
- name: Build Production Image
run: |
IMAGE_NAME=ghcr.io/hackforla/homeuniteus/app:latest
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-aws:
runs-on: ubuntu-latest
needs: [build-api]
container:
image: ghcr.io/hackforla/homeuniteus/api:latest
options: --entrypoint /bin/bash --no-healthcheck
steps:
- name: Run Tests With Backend Mocking
run: pytest
working-directory: /opt/HomeUniteUs/api
test-api-real-aws:
runs-on: ubuntu-latest
needs: [build-api]
container:
image: ghcr.io/hackforla/homeuniteus/api:latest
options: --entrypoint /bin/bash --no-healthcheck
env:
COGNITO_REGION: ${{ secrets.COGNITO_REGION }}
COGNITO_ACCESS_ID: ${{ secrets.COGNITO_ACCESS_ID }}
COGNITO_ACCESS_KEY: ${{ secrets.COGNITO_ACCESS_KEY }}
steps:
- name: Run Tests With Backend Mocking
run: pytest --mode=release
working-directory: /opt/HomeUniteUs/api
test-app-mock-backend:
runs-on: ubuntu-latest
needs: [build-app, build-api]
services:
frontend:
image: ghcr.io/hackforla/homeuniteus/app:latest-test
env:
VITE_HUU_API_BASE_URL: http://127.0.0.1:8080/api
container:
image: ghcr.io/hackforla/homeuniteus/app:latest-test
options: --entrypoint /bin/bash --no-healthcheck
env:
CYPRESS_BASE_URL: http://frontend:4040
CYPRESS_USE_MOCK: true
steps:
- name: Run Tests With Backend Mocking
run: npm run cypress:run:mock
working-directory: /app
test-app-real-backend:
runs-on: ubuntu-latest
needs: [build-app, build-api]
services:
backend:
image: ghcr.io/hackforla/homeuniteus/api:latest
env:
ENV: development
HOST: 0.0.0.0
frontend:
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
options: --entrypoint /bin/bash --no-healthcheck
env:
CYPRESS_BASE_URL: http://frontend:4040
CYPRESS_USE_MOCK: false
CYPRESS_REAL_EMAIL: testhost@test.com
CYPRESS_REAL_PASSWORD: Test!123
steps:
- name: Test using a real backend
run: npm run cypress:run:nomock
working-directory: /app
# - uses: actions/checkout@v4
# - name: Use Node.js 20
# uses: actions/setup-node@v4
# with:
# node-version: 20
# cache: "npm"
# cache-dependency-path: app/package-lock.json
# - name: Run npm CI
# run: npm ci
# - name: Test app
# run: npm run test -- --no-color --run
# - name: Run E2E tests
# uses: cypress-io/github-action@v5
# with:
# install: false
# start: npm run dev
# working-directory: ./app
# wait-on: "http://[::1]:4040/"