forked from valory-xyz/trader-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (106 loc) · 3.77 KB
/
python-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
name: Quickstart Tests
on:
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
env:
GNOSIS_RPC_URL: ${{ secrets.GNOSIS_RPC_URL }}
MODIUS_RPC_URL: ${{ secrets.MODIUS_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
DOCKER_LOGS_DIR: ${GITHUB_WORKSPACE}/logs
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Docker
run: |
# Stop and remove existing Docker installations
sudo systemctl stop docker || true
sudo systemctl stop docker.socket || true
# Clean existing installations
sudo apt-get remove -y docker docker-engine docker.io containerd runc
sudo apt-get update
# Install prerequisites
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
# Add Docker's GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add Docker repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Get current user info
CURRENT_USER=$(id -u)
CURRENT_GROUP=$(id -g)
# Start Docker service
sudo systemctl start docker
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y git
- name: Clean Python cache
run: |
sudo rm -rf ~/.cache/pip
sudo rm -rf ~/.cache/poetry
sudo rm -rf .pytest_cache
sudo rm -rf .venv
sudo rm -rf poetry.lock
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Create .env file
run: |
echo "GNOSIS_RPC_URL=${GNOSIS_RPC_URL}" > .env
echo "MODIUS_RPC_URL=${MODIUS_RPC_URL}" >> .env
echo "OPTIMISM_RPC_URL=${OPTIMISM_RPC_URL}" >> .env
echo "BASE_RPC_URL=${BASE_RPC_URL}" >> .env
echo "TEST_PASSWORD=${TEST_PASSWORD}" >> .env
echo "DOCKER_LOGS_DIR=${DOCKER_LOGS_DIR}" >> .env
- name: Install project dependencies
run: |
python -m pip install --upgrade pip
poetry env use python3.10
poetry install --no-interaction
- name: Run tests
run: |
# Run the tests with debug logging
poetry run pytest -v tests/test_run_service.py -s --log-cli-level=INFO
- name: Debug container failure
if: failure()
run: |
echo "==== Docker container status ===="
docker ps -a
echo "==== Container logs ===="
for container in $(docker ps -aq); do
echo "=== Logs for $container ==="
docker logs $container
echo "=== Inspect for $container ==="
docker inspect $container
done
- name: Upload test logs
if: always()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: |
logs/
/logs/
.env
retention-days: 30