|
|
|
@@ -14,7 +14,7 @@ concurrency:
|
|
|
|
|
jobs:
|
|
|
|
|
backend-tests:
|
|
|
|
|
name: Backend Tests
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
runs-on: vps
|
|
|
|
|
env:
|
|
|
|
|
SECRET_KEY: test-secret-key-for-ci-environment-32chars-minimum
|
|
|
|
|
|
|
|
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
|
|
- name: Checkout repository
|
|
|
|
|
run: |
|
|
|
|
|
if [ ! -d .git ]; then
|
|
|
|
|
git clone --depth=1 "http://gitea:3000/${GITHUB_REPOSITORY}.git" .
|
|
|
|
|
git clone --depth=1 "http://100.78.131.124:3300/${GITHUB_REPOSITORY}.git" .
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: Setup Python
|
|
|
|
@@ -62,25 +62,25 @@ jobs:
|
|
|
|
|
rm -rf venv
|
|
|
|
|
python3 -m venv venv
|
|
|
|
|
. venv/bin/activate
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements.txt || \
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements.txt || \
|
|
|
|
|
pip install -r requirements.txt
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements-dev.txt || \
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements-dev.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements-dev.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements-dev.txt || \
|
|
|
|
|
pip install -r requirements-dev.txt
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "Installing fresh dependencies..."
|
|
|
|
|
python3 -m venv venv
|
|
|
|
|
. venv/bin/activate
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements.txt || \
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements.txt || \
|
|
|
|
|
pip install -r requirements.txt
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements-dev.txt || \
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements-dev.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --retries 3 --timeout 30 -r requirements-dev.txt || \
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR --index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements-dev.txt || \
|
|
|
|
|
pip install -r requirements-dev.txt
|
|
|
|
|
timeout 300 pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
|
|
|
|
timeout 600 pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
|
|
|
|
echo "Saving venv to cache $CACHE_KEY..."
|
|
|
|
|
cp -a venv $CACHE_DIR/ || echo "Warning: cache save failed"
|
|
|
|
|
fi
|
|
|
|
@@ -102,13 +102,13 @@ jobs:
|
|
|
|
|
|
|
|
|
|
frontend-tests:
|
|
|
|
|
name: Frontend Tests
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
runs-on: vps
|
|
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
- name: Checkout repository
|
|
|
|
|
run: |
|
|
|
|
|
if [ ! -d .git ]; then
|
|
|
|
|
git clone --depth=1 "http://gitea:3000/${GITHUB_REPOSITORY}.git" .
|
|
|
|
|
git clone --depth=1 "http://100.78.131.124:3300/${GITHUB_REPOSITORY}.git" .
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: Setup Node.js
|
|
|
|
@@ -170,7 +170,7 @@ jobs:
|
|
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
|
name: Deploy to Production
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
runs-on: nas
|
|
|
|
|
if: always()
|
|
|
|
|
needs: [backend-tests, frontend-tests]
|
|
|
|
|
env:
|
|
|
|
@@ -283,9 +283,9 @@ jobs:
|
|
|
|
|
continue
|
|
|
|
|
skip_net = False
|
|
|
|
|
out.append(l)
|
|
|
|
|
open('/tmp/prod-ci.yml','w').writelines(out)
|
|
|
|
|
open('/nas-dashboard/prod-ci.yml','w').writelines(out)
|
|
|
|
|
"
|
|
|
|
|
docker compose -f /tmp/prod-ci.yml up -d --pull never 2>&1 || true
|
|
|
|
|
docker compose -f /nas-dashboard/prod-ci.yml up -d --pull never 2>&1 || true
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! docker container inspect nas-dashboard >/dev/null 2>&1; then
|
|
|
|
@@ -299,6 +299,10 @@ jobs:
|
|
|
|
|
docker run -d --name nas-dashboard \
|
|
|
|
|
--restart unless-stopped \
|
|
|
|
|
-p 127.0.0.1:4000:4000 \
|
|
|
|
|
--health-cmd 'python -c "import urllib.request; urllib.request.urlopen(\"http://localhost:4000/api/health\")"' \
|
|
|
|
|
--health-interval 30s \
|
|
|
|
|
--health-timeout 5s \
|
|
|
|
|
--health-retries 3 \
|
|
|
|
|
-e DOCKER_HOST=tcp://docker-socket-proxy:2375 \
|
|
|
|
|
-e GITEA_URL=http://gitea:3000 \
|
|
|
|
|
-e GITEA_TOKEN=${GITEA_TOKEN} \
|
|
|
|
|