-
Notifications
You must be signed in to change notification settings - Fork 93
148 lines (132 loc) · 4.33 KB
/
unit-tests.yml
File metadata and controls
148 lines (132 loc) · 4.33 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Unit Tests (Smart Image Build)
on: [push, pull_request]
env:
IMAGE_TAG: ghcr.io/rcosdp/weko:${{ github.sha }}
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
max-parallel: 4
matrix:
module:
- invenio-accounts
- invenio-communities
- invenio-db
- invenio-deposit
- invenio-files-rest
- invenio-iiif
- invenio-indexer
- invenio-mail
- invenio-oaiharvester
- invenio-oaiserver
- invenio-oauth2server
- invenio-previewer
- invenio-queues
- invenio-records-rest
- invenio-records
- invenio-resourcesyncclient
- invenio-resourcesyncserver
- invenio-s3
- invenio-stats
- weko-accounts
- weko-admin
- weko-authors
- weko-bulkupdate
- weko-deposit
- weko-gridlayout
- weko-groups
- weko-handle
- weko-index-tree
- weko-indextree-journal
- weko-items-autofill
- weko-items-ui
- weko-itemtypes-ui
- weko-logging
- weko-plugins
- weko-records-ui
- weko-records
- weko-redis
- weko-schema-ui
- weko-search-ui
- weko-sitemap
- weko-swordserver
- weko-theme
- weko-user-profiles
- weko-workflow
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y docker-compose fonts-noto-cjk fonts-noto-color-emoji
- name: Change owner
run: sudo chown -R 1000:1000 ./modules
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Start WEKO containers
run: |
chmod +x install.sh
./install.sh
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
- name: Wait for services to be ready
run: |
echo "Waiting for WEKO services to start..."
start_time=$(date +%s)
max_attempts=60
attempt=0
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
current_time=$(date +%s)
elapsed=$((current_time - start_time))
echo "Attempt $attempt/$max_attempts (${elapsed}s elapsed): Checking WEKO availability..."
# Check if we can connect to the service
if curl -f -s --insecure https://localhost/ > /dev/null 2>&1; then
echo "✓ WEKO is ready! (took ${elapsed}s)"
exit 0
else
# Get HTTP response code for debugging
http_code=$(curl -s -o /dev/null -w "%{http_code}" --insecure https://localhost/ 2>/dev/null || echo "connection_failed")
echo " ✗ HTTP response: $http_code"
fi
if [ $attempt -lt $max_attempts ]; then
echo " → Retrying in 5 seconds..."
sleep 5
fi
done
echo ""
echo "❌ WEKO failed to start within 300 seconds"
echo "Final HTTP response: $(curl -s -o /dev/null -w "%{http_code}" --insecure https://localhost/ 2>/dev/null || echo "connection_failed")"
echo ""
echo "Container status:"
docker compose -f docker-compose2.yml ps
exit 1
- name: Install test dependencies
run: |
docker compose -f docker-compose2.yml exec -T web bash -c "pip install --upgrade pip && pip install tox tox-setuptools-version pytest-timeout"
- name: Run tox in ${{ matrix.module }}
run: |
docker compose -f docker-compose2.yml exec -T web bash -c "cd modules/${{ matrix.module }} && tox"
- name: Show logs if failed
if: failure()
run: docker compose -f docker-compose2.yml logs
- name: Stop containers
if: always()
run: |
docker compose -f docker-compose2.yml down -v
docker system prune -f