Files
aitbc/.gitea/workflows/package-tests.yml
aitbc 097cd9cccf
Some checks failed
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 3s
Package Tests / Python package - aitbc-core (push) Failing after 2s
Package Tests / Python package - aitbc-crypto (push) Failing after 4s
Package Tests / Python package - aitbc-sdk (push) Failing after 1s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 6m12s
Package Tests / JavaScript package - aitbc-token (push) Failing after 10s
ci: add venv corruption detection and auto-rebuild in package tests
Added validation checks for venv and venv-build directories with automatic rebuild on corruption detection. Checks for executable pip/python binaries and rebuilds the venv if not found.
2026-04-19 21:28:26 +02:00

187 lines
5.8 KiB
YAML

name: Package Tests
on:
push:
branches: [main, develop]
paths:
- 'packages/**'
- 'pyproject.toml'
- '.gitea/workflows/package-tests.yml'
pull_request:
branches: [main, develop]
workflow_dispatch:
concurrency:
group: package-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
test-python-packages:
name: Python package - ${{ matrix.package.name }}
runs-on: debian
timeout-minutes: 15
strategy:
matrix:
package:
- name: "aitbc-core"
path: "packages/py/aitbc-core"
- name: "aitbc-crypto"
path: "packages/py/aitbc-crypto"
- name: "aitbc-sdk"
path: "packages/py/aitbc-sdk"
- name: "aitbc-agent-sdk"
path: "packages/py/aitbc-agent-sdk"
steps:
- name: Clone repository
run: |
WORKSPACE="/var/lib/aitbc-workspaces/pkg-${{ matrix.package.name }}"
rm -rf "$WORKSPACE"
mkdir -p "$WORKSPACE"
cd "$WORKSPACE"
git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo
- name: Setup and test package
run: |
WORKSPACE="/var/lib/aitbc-workspaces/pkg-${{ matrix.package.name }}"
cd "$WORKSPACE/repo/${{ matrix.package.path }}"
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
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
# Install dependencies
if [[ -f "pyproject.toml" ]]; then
venv/bin/pip install -q -e ".[dev]" 2>/dev/null || venv/bin/pip install -q -e .
fi
if [[ -f "requirements.txt" ]]; then
venv/bin/pip install -q -r requirements.txt
fi
# Linting
echo "=== Linting ==="
if [[ -d "src" ]]; then
mypy src/ --ignore-missing-imports --no-error-summary 2>/dev/null || echo "⚠️ MyPy warnings"
black --check src/ 2>/dev/null || echo "⚠️ Black warnings"
fi
# Tests
echo "=== Tests ==="
if [[ -d "tests" ]]; then
pytest tests/ -q --tb=short
else
echo "⚠️ No tests directory found"
fi
echo "✅ ${{ matrix.package.name }} testing completed"
- name: Build package
run: |
WORKSPACE="/var/lib/aitbc-workspaces/pkg-${{ matrix.package.name }}"
cd "$WORKSPACE/repo/${{ matrix.package.path }}"
if [[ -f "pyproject.toml" ]]; then
bash "$WORKSPACE/repo/scripts/ci/setup-python-venv.sh" \
--repo-dir "$PWD" \
--venv-dir "$PWD/venv-build" \
--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
- name: Cleanup
if: always()
run: rm -rf "/var/lib/aitbc-workspaces/pkg-${{ matrix.package.name }}"
test-javascript-packages:
name: JavaScript package - ${{ matrix.package.name }}
runs-on: debian
timeout-minutes: 15
strategy:
matrix:
package:
- name: "aitbc-sdk-js"
path: "packages/js/aitbc-sdk"
- name: "aitbc-token"
path: "packages/solidity/aitbc-token"
steps:
- name: Clone repository
run: |
WORKSPACE="/var/lib/aitbc-workspaces/jspkg-${{ matrix.package.name }}"
rm -rf "$WORKSPACE"
mkdir -p "$WORKSPACE"
cd "$WORKSPACE"
git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo
- name: Setup and test package
run: |
WORKSPACE="/var/lib/aitbc-workspaces/jspkg-${{ matrix.package.name }}"
cd "$WORKSPACE/repo/${{ matrix.package.path }}"
echo "=== Testing ${{ matrix.package.name }} ==="
if [[ ! -f "package.json" ]]; then
echo "⚠️ No package.json found, skipping"
exit 0
fi
node --version
npm --version
npm install --legacy-peer-deps
# Build
npm run build
echo "✅ Build passed"
# Lint
npm run lint 2>/dev/null && echo "✅ Lint passed" || echo "⚠️ Lint skipped"
# Test
npm test
echo "✅ Tests passed"
echo "✅ ${{ matrix.package.name }} completed"
- name: Cleanup
if: always()
run: rm -rf "/var/lib/aitbc-workspaces/jspkg-${{ matrix.package.name }}"