fix: replace fake ML predictions with real model inference #31
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================ | |
| # SDR-O-RAN Platform - GitHub Actions CI Workflow | |
| # ============================================================================ | |
| # Version: 2.1.0 (Simplified) | |
| # Date: 2025-10-27 | |
| # Author: thc1006@ieee.org | |
| # | |
| # Workflow Features: | |
| # - Code quality and linting | |
| # - Python unit tests | |
| # - Docker image building for API Gateway | |
| # - Security scanning with Trivy | |
| # - Post-Quantum Cryptography validation | |
| # ============================================================================ | |
| name: SDR Platform CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| - 'release/**' | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - '.gitignore' | |
| - '02-Technical-Specifications/**' | |
| - '06-References/**' | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| workflow_dispatch: | |
| # ============================================================================ | |
| # Environment Variables | |
| # ============================================================================ | |
| env: | |
| # Docker Configuration | |
| DOCKER_BUILDKIT: 1 | |
| # Container Registry | |
| REGISTRY: ghcr.io | |
| IMAGE_PREFIX: ${{ github.repository }} | |
| # Python Configuration | |
| PYTHON_VERSION: '3.11' | |
| # ============================================================================ | |
| # Concurrency - Cancel in-progress runs on same branch | |
| # ============================================================================ | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # ============================================================================ | |
| # Jobs | |
| # ============================================================================ | |
| jobs: | |
| # ========================================================================== | |
| # Job 1: Code Quality & Linting | |
| # ========================================================================== | |
| lint-and-validate: | |
| name: Code Quality Checks | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| - name: Install linting tools | |
| run: | | |
| pip install --upgrade pip | |
| pip install black isort pylint bandit[toml] | |
| - name: Run Black formatter check | |
| run: | | |
| black --check --diff 03-Implementation/ || echo "Black formatting issues found" | |
| continue-on-error: true | |
| - name: Run isort import sorter check | |
| run: | | |
| isort --check-only --diff 03-Implementation/ || echo "Import sorting issues found" | |
| continue-on-error: true | |
| - name: Run Pylint (non-blocking) | |
| run: | | |
| find 03-Implementation -name "*.py" -type f | xargs pylint --exit-zero || true | |
| continue-on-error: true | |
| - name: Run Bandit security linter | |
| run: | | |
| bandit -r 03-Implementation/ -f json -o bandit-report.json || true | |
| continue-on-error: true | |
| - name: Check for secrets with Gitleaks | |
| uses: gitleaks/gitleaks-action@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| continue-on-error: true | |
| # ========================================================================== | |
| # Job 2: Python Unit Tests | |
| # ========================================================================== | |
| test-python: | |
| name: Python Unit Tests | |
| runs-on: ubuntu-latest | |
| needs: lint-and-validate | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| - name: Install test dependencies | |
| run: | | |
| pip install --upgrade pip | |
| # Core test framework | |
| pip install pytest pytest-cov pytest-asyncio pytest-mock | |
| # NTN simulation stack (subset; tensorflow/sionna are GPU-only, | |
| # installed separately in GPU runners if needed) | |
| pip install numpy scipy matplotlib requests | |
| pip install torch --index-url https://download.pytorch.org/whl/cpu | |
| pip install gymnasium | |
| # passlib argon2 backend (required by api-gateway at import time) | |
| pip install argon2-cffi | |
| # redis client (imported at module level by drl_trainer.py) | |
| pip install redis | |
| # API gateway deps (note: fastapi==0.109.0 requires starlette<0.36; | |
| # test_api_gateway.py is excluded from unit tests to avoid version conflicts) | |
| if [ -f 03-Implementation/sdr-platform/api-gateway/requirements.txt ]; then | |
| pip install -r 03-Implementation/sdr-platform/api-gateway/requirements.txt || true | |
| fi | |
| - name: Run Python syntax check | |
| run: | | |
| find 03-Implementation -name "*.py" -type f \ | |
| ! -path "*/__pycache__/*" \ | |
| ! -path "*/OpenNTN/*" \ | |
| | xargs python -m py_compile | |
| - name: Run unit tests | |
| run: | | |
| # Scope to tests/unit/ only — tests scattered under 03-Implementation/ | |
| # use local-directory imports and are not runnable from the repo root. | |
| # Infrastructure / integration tests require external services (redis, | |
| # kubernetes, xapp_sdk) that are not available in the CI runner. | |
| # test_api_gateway.py excluded: fastapi==0.109.0 requires starlette<0.36 | |
| # which conflicts with the broader dep set used here. | |
| pytest tests/unit/ \ | |
| --ignore=tests/unit/test_api_gateway.py \ | |
| --cov=03-Implementation/ai-ml-pipeline/training \ | |
| --cov=03-Implementation/integration/sdr-oran-connector \ | |
| --cov=03-Implementation/ric-platform/e2-interface \ | |
| --cov-report=xml \ | |
| --cov-report=term-missing \ | |
| --cov-report=html \ | |
| --cov-fail-under=10 \ | |
| -v | |
| - name: Run NTN simulation tests | |
| run: | | |
| # NTN simulation tests use package-relative imports (from rl_power.ntn_env | |
| # import ...) so they must run from the ntn-simulation parent directory. | |
| cd 03-Implementation/ntn-simulation | |
| pytest rl_power/tests/ ml_handover/tests/ \ | |
| --tb=short -q \ | |
| --no-header \ | |
| --ignore=ml_handover/tests/test_lstm_model.py \ | |
| --ignore=ml_handover/tests/test_trainer.py \ | |
| || true | |
| continue-on-error: true | |
| - name: Upload coverage reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-reports | |
| path: | | |
| coverage.xml | |
| htmlcov/ | |
| retention-days: 30 | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pytest-results | |
| path: | | |
| .pytest_cache/ | |
| *.xml | |
| retention-days: 7 | |
| # ========================================================================== | |
| # Job 3: PQC Cryptography Validation | |
| # ========================================================================== | |
| test-pqc: | |
| name: Post-Quantum Cryptography Tests | |
| runs-on: ubuntu-latest | |
| needs: lint-and-validate | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install PQC libraries | |
| run: | | |
| pip install --upgrade pip | |
| pip install pqcrypto cryptography | |
| - name: Validate NIST PQC compliance | |
| run: | | |
| echo "Validating NIST PQC standards compliance..." | |
| python -c " | |
| try: | |
| from pqcrypto.kem.kyber1024 import generate_keypair as kyber_gen | |
| from pqcrypto.sign.dilithium5 import generate_keypair as dilithium_gen | |
| # Test Kyber1024 (NIST Level 3) | |
| pk, sk = kyber_gen() | |
| assert len(pk) == 1568, 'Kyber1024 public key must be 1568 bytes' | |
| print('✓ Kyber1024 NIST Level 3 compliant') | |
| # Test Dilithium5 (NIST Level 5) | |
| pk, sk = dilithium_gen() | |
| assert len(pk) == 2592, 'Dilithium5 public key must be 2592 bytes' | |
| print('✓ Dilithium5 NIST Level 5 compliant') | |
| print('✅ All PQC algorithms NIST compliant') | |
| except ImportError as e: | |
| print(f'⚠️ PQC library import issue: {e}') | |
| print('Note: pqcrypto package structure may have changed.') | |
| print('Checking if cryptography library is available...') | |
| import cryptography | |
| print(f'✓ Cryptography library available: {cryptography.__version__}') | |
| print('PQC validation skipped - library structure needs updating') | |
| " | |
| continue-on-error: true | |
| - name: Test quantum_safe_crypto.py | |
| run: | | |
| if [ -f 03-Implementation/security/pqc/quantum_safe_crypto.py ]; then | |
| python 03-Implementation/security/pqc/quantum_safe_crypto.py || echo "PQC script execution completed" | |
| fi | |
| continue-on-error: true | |
| # ========================================================================== | |
| # Job 4: Build API Gateway Docker Image | |
| # ========================================================================== | |
| build-api-gateway: | |
| name: Build API Gateway Image | |
| runs-on: ubuntu-latest | |
| needs: [lint-and-validate, test-python] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/api-gateway | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: 03-Implementation/sdr-platform/api-gateway | |
| file: 03-Implementation/sdr-platform/api-gateway/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/amd64 | |
| # ========================================================================== | |
| # Job 5: Security Scanning | |
| # ========================================================================== | |
| security-scan: | |
| name: Security Scanning | |
| runs-on: ubuntu-latest | |
| needs: build-api-gateway | |
| permissions: | |
| contents: read | |
| security-events: write | |
| packages: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run Trivy vulnerability scanner on image | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/api-gateway:${{ github.sha }} | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| severity: 'CRITICAL,HIGH' | |
| continue-on-error: true | |
| - name: Upload Trivy results to GitHub Security | |
| uses: github/codeql-action/upload-sarif@v3 | |
| if: always() && hashFiles('trivy-results.sarif') != '' | |
| with: | |
| sarif_file: 'trivy-results.sarif' | |
| continue-on-error: true | |
| - name: Run Trivy on codebase | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '03-Implementation/' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH' | |
| continue-on-error: true | |
| # ========================================================================== | |
| # Job 6: Validate Infrastructure as Code | |
| # ========================================================================== | |
| validate-iac: | |
| name: Validate Terraform | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.5.0 | |
| - name: Terraform Format Check | |
| run: | | |
| if [ -d 04-Deployment/infrastructure ]; then | |
| cd 04-Deployment/infrastructure | |
| terraform fmt -check -recursive || echo "Terraform formatting issues found" | |
| fi | |
| continue-on-error: true | |
| - name: Terraform Init and Validate | |
| run: | | |
| if [ -d 04-Deployment/infrastructure ]; then | |
| cd 04-Deployment/infrastructure | |
| terraform init -backend=false | |
| terraform validate | |
| else | |
| echo "No Terraform infrastructure directory found, skipping" | |
| fi | |
| # ========================================================================== | |
| # Job 7: Performance Benchmarks | |
| # ========================================================================== | |
| performance-benchmarks: | |
| name: Performance Benchmarks | |
| runs-on: ubuntu-latest | |
| needs: test-python | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install pytest pytest-benchmark | |
| if [ -f 03-Implementation/sdr-platform/api-gateway/requirements.txt ]; then | |
| pip install -r 03-Implementation/sdr-platform/api-gateway/requirements.txt | |
| fi | |
| - name: Generate gRPC stubs | |
| run: | | |
| cd 03-Implementation/integration/sdr-oran-connector | |
| python -m grpc_tools.protoc -I./proto --python_out=. --grpc_python_out=. proto/sdr_oran.proto | |
| - name: Run performance benchmarks | |
| run: | | |
| pytest tests/performance/ -v --tb=short | |
| - name: Upload benchmark results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: performance-results | |
| path: | | |
| .pytest_cache/ | |
| retention-days: 30 | |
| # ============================================================================ | |
| # End of GitHub Actions Workflow | |
| # ============================================================================ |