-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (97 loc) · 3.63 KB
/
testing.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
name: Build and Test
on:
push:
paths-ignore:
- 'docs/**'
- './README.md'
- './.gitignore'
branches:
- main
pull_request:
branches:
- main
jobs:
buildandtest:
name: Build and Scan Image with Integration Tests
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v3
- name: Add CKAN url to hosts
run: sudo echo "127.0.0.1 ckan-dev" | sudo tee -a /etc/hosts
- name: Add Minio url to hosts
run: sudo echo "127.0.0.1 minio" | sudo tee -a /etc/hosts
- name: Copy .env.example into .env
run: |
cp .env.example .env
- name: Install `Xvfb` and others to run browsers for end-to-end testing in local CI/CD simulations
if: ${{ env.ACT }}
run: sudo apt-get update && sudo apt-get install -y xvfb && npx playwright install-deps
- name: Set up Docker Containers
run: |
docker compose -f docker-compose.dev.yml --env-file .env.example up --build -d
- name: Create sysadmin API for Authorization
run: bash ./scripts/cypress_setup.sh
- name: Print Logs
run: docker compose -f docker-compose.dev.yml --env-file .env.example logs
continue-on-error: true
- name: Wait for ckan-tdc-dev to be healthy
run: |
echo "Waiting for ckan-tdc-dev to become healthy"
for i in {1..60}; do
health_status=$(docker inspect --format='{{.State.Health.Status}}' ckan-tdc-dev)
if [ "$health_status" == "healthy" ]; then
echo "ckan-tdc-dev is healthy"
break
elif [ "$health_status" == "unhealthy" ]; then
echo "ckan-tdc-dev is unhealthy, printing logs"
docker compose -f docker-compose.dev.yml logs ckan-tdc-dev
exit 1
else
echo "Current health status: $health_status"
fi
sleep 5
done
if [ "$health_status" != "healthy" ]; then
echo "ckan-tdc-dev did not become healthy in time"
docker compose -f docker-compose.dev.yml logs ckan-tdc-dev
exit 1
fi
- name: Wait for ckan-tdc-db to be healthy
run: |
while ! docker exec ckan-tdc-db pg_isready -U ckandbuser -d ckandb; do
sleep 1
done
- name: Run seeding geographies
run: docker exec ckan-tdc-dev sh -c "ckan -c ckan.ini create-default-geographies"
- name: Copy .env
run: cp .env.example .env
working-directory: ./frontend
- name: Run frontend tests 🧪
uses: cypress-io/github-action@v6
with:
install-command: npm install
build: npm run build
start: npm run start
wait-on: 'http://127.0.0.1:3000'
wait-on-timeout: 600
command: npm run test
working-directory: ./frontend
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: /home/runner/work/ckan-docker-tdc-dev/ckan-docker-tdc-dev/integration-tests/cypress/screenshots
if-no-files-found: ignore
- name: Print Error Logs
if: failure()
run: docker compose -f docker-compose.dev.yml --env-file .env.example logs
- uses: actions/upload-artifact@v3
if: failure()
with:
name: Frontend screenshots
path: ./frontend/cypress/screenshots
if-no-files-found: ignore
- name: Tear down containers
if: failure() || success()
run: docker compose -f docker-compose.dev.yml --env-file .env.example down -v --remove-orphans