From ffb1f2a4f8b28106f10e9b546836d598875e1561 Mon Sep 17 00:00:00 2001 From: aitbc Date: Mon, 20 Apr 2026 06:10:32 +0200 Subject: [PATCH] ci: add explicit venv cleanup before setup in all workflows to prevent cache corruption Added `rm -rf venv` (and `venv-build` where applicable) before venv setup in all CI workflows to ensure clean installations and prevent cache corruption issues. Removed redundant venv corruption detection and rebuild logic from package-tests.yml since explicit cleanup makes it unnecessary. --- .gitea/workflows/api-endpoint-tests.yml | 4 ++++ .gitea/workflows/cli-level1-tests.yml | 7 +++++-- .gitea/workflows/integration-tests.yml | 6 +++++- .gitea/workflows/package-tests.yml | 27 ++++--------------------- .gitea/workflows/production-tests.yml | 4 ++++ .gitea/workflows/python-tests.yml | 7 +++++-- .gitea/workflows/security-scanning.yml | 8 ++++++-- .gitea/workflows/staking-tests.yml | 5 ++++- 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/.gitea/workflows/api-endpoint-tests.yml b/.gitea/workflows/api-endpoint-tests.yml index d98e29df..7e8e962f 100644 --- a/.gitea/workflows/api-endpoint-tests.yml +++ b/.gitea/workflows/api-endpoint-tests.yml @@ -34,6 +34,10 @@ jobs: - name: Setup test environment run: | cd /var/lib/aitbc-workspaces/api-tests/repo + + # Remove any existing venv to avoid cache corruption issues + rm -rf venv + bash scripts/ci/setup-python-venv.sh \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv" \ diff --git a/.gitea/workflows/cli-level1-tests.yml b/.gitea/workflows/cli-level1-tests.yml index 4652f7b5..5174547c 100644 --- a/.gitea/workflows/cli-level1-tests.yml +++ b/.gitea/workflows/cli-level1-tests.yml @@ -32,10 +32,13 @@ jobs: - name: Setup Python environment run: | cd /var/lib/aitbc-workspaces/cli-tests/repo - + + # Remove any existing venv to avoid cache corruption issues + rm -rf venv + # Ensure standard directories exist mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc - + bash scripts/ci/setup-python-venv.sh \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv" diff --git a/.gitea/workflows/integration-tests.yml b/.gitea/workflows/integration-tests.yml index 0ed7ae80..d989af03 100644 --- a/.gitea/workflows/integration-tests.yml +++ b/.gitea/workflows/integration-tests.yml @@ -107,12 +107,16 @@ jobs: - name: Setup test environment run: | cd /var/lib/aitbc-workspaces/integration-tests/repo + + # Remove any existing venv to avoid cache corruption issues + rm -rf venv + bash scripts/ci/setup-python-venv.sh \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv" \ --skip-requirements \ --extra-packages "requests pytest httpx pytest-asyncio pytest-timeout click locust" - + # Ensure standard directories exist mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc diff --git a/.gitea/workflows/package-tests.yml b/.gitea/workflows/package-tests.yml index d0047d3a..bb164a42 100644 --- a/.gitea/workflows/package-tests.yml +++ b/.gitea/workflows/package-tests.yml @@ -49,27 +49,19 @@ jobs: echo "=== Testing ${{ matrix.package.name }} ===" echo "Directory: $(pwd)" ls -la - + # Ensure standard directories exist mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc + # Remove any existing venv to avoid cache corruption issues + rm -rf venv venv-build + bash "$WORKSPACE/repo/scripts/ci/setup-python-venv.sh" \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv" \ --mode copy \ --extra-packages "pytest mypy black" - # Validate venv and rebuild if corrupted - if [[ ! -x "venv/bin/pip" ]]; then - echo "⚠️ Corrupted venv detected, rebuilding..." - rm -rf venv - bash "$WORKSPACE/repo/scripts/ci/setup-python-venv.sh" \ - --repo-dir "$PWD" \ - --venv-dir "$PWD/venv" \ - --mode copy \ - --extra-packages "pytest mypy black" - fi - if [[ "${{ matrix.package.name }}" == "aitbc-sdk" ]]; then venv/bin/pip install -q -e "$WORKSPACE/repo/packages/py/aitbc-crypto" fi @@ -111,17 +103,6 @@ jobs: --skip-requirements \ --extra-packages "build" - # Validate venv-build and rebuild if corrupted - if [[ ! -x "venv-build/bin/python" ]]; then - echo "⚠️ Corrupted venv-build detected, rebuilding..." - rm -rf venv-build - bash "$WORKSPACE/repo/scripts/ci/setup-python-venv.sh" \ - --repo-dir "$PWD" \ - --venv-dir "$PWD/venv-build" \ - --skip-requirements \ - --extra-packages "build" - fi - venv-build/bin/python -m build echo "✅ Package built" fi diff --git a/.gitea/workflows/production-tests.yml b/.gitea/workflows/production-tests.yml index 4d85c32f..45a0b4c2 100644 --- a/.gitea/workflows/production-tests.yml +++ b/.gitea/workflows/production-tests.yml @@ -33,6 +33,10 @@ jobs: - name: Setup test environment run: | cd /var/lib/aitbc-workspaces/production-tests/repo + + # Remove any existing venv to avoid cache corruption issues + rm -rf venv + bash scripts/ci/setup-python-venv.sh \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv" \ diff --git a/.gitea/workflows/python-tests.yml b/.gitea/workflows/python-tests.yml index 5ca6461e..da624dbb 100644 --- a/.gitea/workflows/python-tests.yml +++ b/.gitea/workflows/python-tests.yml @@ -35,10 +35,13 @@ jobs: - name: Setup Python environment run: | cd /var/lib/aitbc-workspaces/python-tests/repo - + + # Remove any existing venv to avoid cache corruption issues + rm -rf venv + # Ensure standard directories exist mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc - + bash scripts/ci/setup-python-venv.sh \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv" \ diff --git a/.gitea/workflows/security-scanning.yml b/.gitea/workflows/security-scanning.yml index 74c90138..a0b99ed4 100644 --- a/.gitea/workflows/security-scanning.yml +++ b/.gitea/workflows/security-scanning.yml @@ -38,15 +38,19 @@ jobs: - name: Setup tools run: | cd /var/lib/aitbc-workspaces/security-scan/repo - + # Ensure standard directories exist mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc - + + # Remove any existing venv to avoid cache corruption issues + rm -rf venv + bash scripts/ci/setup-python-venv.sh \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv" \ --skip-requirements \ --extra-packages "bandit pip-audit" + echo "✅ Security tools installed" - name: Python dependency audit diff --git a/.gitea/workflows/staking-tests.yml b/.gitea/workflows/staking-tests.yml index b9c3a0fc..2e7de61c 100644 --- a/.gitea/workflows/staking-tests.yml +++ b/.gitea/workflows/staking-tests.yml @@ -35,7 +35,10 @@ jobs: - name: Setup Python environment run: | cd /var/lib/aitbc-workspaces/staking-tests/repo - + + # Remove any existing venv to avoid cache corruption issues + rm -rf venv + bash scripts/ci/setup-python-venv.sh \ --repo-dir "$PWD" \ --venv-dir "$PWD/venv"