Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
492 changes: 492 additions & 0 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

403 changes: 403 additions & 0 deletions .github/workflows/code-quality.yml

Large diffs are not rendered by default.

501 changes: 501 additions & 0 deletions .github/workflows/health-monitoring.yml

Large diffs are not rendered by default.

524 changes: 524 additions & 0 deletions .github/workflows/release-readiness.yml

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions .github/workflows/test-strategy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
name: Comprehensive Testing Strategy

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
# Fast unit tests with SQLite (runs on every push)
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
git clone --depth 1 --branch v4.2.7 https://github.com/netbox-community/netbox.git /tmp/netbox
pip install -r /tmp/netbox/requirements.txt
pip install -r requirements.txt
pip install pytest pytest-django coverage

- name: Run unit tests (SQLite - Fast)
run: |
cd /tmp/netbox/netbox
cp $GITHUB_WORKSPACE/business_application/test_settings.py ./
export DJANGO_SETTINGS_MODULE=test_settings
export PYTHONPATH=/tmp/netbox/netbox:$GITHUB_WORKSPACE
python manage.py migrate --settings=test_settings
python -m pytest $GITHUB_WORKSPACE/business_application/tests/ -v -k "not integration" --tb=short

# Comprehensive integration tests with PostgreSQL (runs on main/develop)
integration-tests:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.event_name == 'pull_request'

services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: netbox
POSTGRES_USER: netbox
POSTGRES_DB: netbox
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install PostgreSQL client
run: sudo apt-get update && sudo apt-get install -y postgresql-client

- name: Wait for services
run: |
# Wait for PostgreSQL with authentication test
timeout=60; counter=0
while [ $counter -lt $timeout ]; do
if pg_isready -h localhost -p 5432 -U netbox &&
PGPASSWORD=netbox psql -h localhost -U netbox -d netbox -c 'SELECT 1;' >/dev/null 2>&1; then
echo "PostgreSQL ready and authenticated!"
break
fi
sleep 2; counter=$((counter + 1))
done
env:
PGPASSWORD: netbox

- name: Install dependencies
run: |
git clone --depth 1 --branch v4.2.7 https://github.com/netbox-community/netbox.git /tmp/netbox
pip install -r /tmp/netbox/requirements.txt
pip install -r requirements.txt
pip install pytest pytest-django coverage

- name: Configure NetBox
run: |
cd /tmp/netbox/netbox
cp netbox/configuration_example.py netbox/configuration.py
cat >> netbox/configuration.py << EOF

SECRET_KEY = 'integration-test-secret-key'
DATABASES = {
'default': {
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'netbox',
'HOST': '127.0.0.1',
'PORT': 5432,
'ENGINE': 'django.db.backends.postgresql',
}
}
REDIS = {
'tasks': {'HOST': 'localhost', 'PORT': 6379, 'DATABASE': 0, 'SSL': False},
'caching': {'HOST': 'localhost', 'PORT': 6379, 'DATABASE': 1, 'SSL': False}
}
PLUGINS = ['business_application']
DEBUG = True
EOF

- name: Run integration tests (PostgreSQL - Comprehensive)
run: |
cd /tmp/netbox/netbox
export DJANGO_SETTINGS_MODULE=netbox.settings
export PYTHONPATH=/tmp/netbox/netbox:$GITHUB_WORKSPACE
python manage.py migrate
python -m pytest $GITHUB_WORKSPACE/business_application/tests/ -v --tb=short

# Smoke test - just verify plugin loads
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Smoke test (plugin import)
run: |
git clone --depth 1 --branch v4.2.7 https://github.com/netbox-community/netbox.git /tmp/netbox
pip install -r /tmp/netbox/requirements.txt
pip install -r requirements.txt
cd /tmp/netbox/netbox
export PYTHONPATH=/tmp/netbox/netbox:$GITHUB_WORKSPACE
python -c "
import sys
sys.path.append('$GITHUB_WORKSPACE')
import business_application
print(f'✅ Plugin {business_application.__name__} imported successfully')
print(f'📦 Version: {getattr(business_application, \"__version__\", \"unknown\")}')
"
80 changes: 80 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Unit Tests (No Database)

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
unit-tests:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-

- name: Install NetBox (minimal)
run: |
# Install NetBox dependencies only
git clone --depth 1 --branch v4.2.7 https://github.com/netbox-community/netbox.git /tmp/netbox
pip install -r /tmp/netbox/requirements.txt

- name: Install plugin dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-django pytest-cov coverage

- name: Set environment variables
run: |
echo "DJANGO_SETTINGS_MODULE=business_application.test_settings" >> $GITHUB_ENV
echo "PYTHONPATH=/tmp/netbox/netbox:$GITHUB_WORKSPACE" >> $GITHUB_ENV

- name: Run unit tests (SQLite in-memory)
run: |
cd /tmp/netbox/netbox
# Copy our test settings
cp $GITHUB_WORKSPACE/business_application/test_settings.py ./

# Run Django migrations with SQLite
python manage.py migrate --settings=test_settings

# Run unit tests
python -m pytest $GITHUB_WORKSPACE/business_application/tests/ -v \
--tb=short \
--settings=test_settings \
--disable-warnings \
-x

- name: Run unit tests with coverage
run: |
cd /tmp/netbox/netbox
coverage run --source='$GITHUB_WORKSPACE/business_application' \
-m pytest $GITHUB_WORKSPACE/business_application/tests/ \
--settings=test_settings \
--disable-warnings
coverage report -m
coverage xml

- name: Upload coverage to artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-unit-tests-python-${{ matrix.python-version }}
path: /tmp/netbox/netbox/coverage.xml
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ staticfiles/
media/

local_requirements.txt
.*

152 changes: 152 additions & 0 deletions GITHUB_ACTIONS_FIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# GitHub Actions Fixes Applied

## 🚨 **Issues Fixed**

### 1. **Deprecated actions/upload-artifact@v3**
- **Problem**: GitHub deprecated v3 of upload-artifact actions (effective January 30, 2025)
- **Solution**: Updated all workflow files to use `actions/upload-artifact@v4`
- **Files Updated**:
- `.github/workflows/ci.yml`
- `.github/workflows/health-monitoring.yml`
- `.github/workflows/code-quality.yml`
- `.github/workflows/release-readiness.yml`

### 2. **NetBox Version Mismatch**
- **Problem**: Workflows trying to clone NetBox v3.7 branch which doesn't exist
- **Root Cause**: Plugin is developed for NetBox 4.2.1+ but workflows referenced old versions
- **Solution**: Updated all NetBox version references from 3.x to 4.x series

---

## 📊 **Version Matrix Updated**

### **Before (Broken)**
```yaml
python-version: ['3.9', '3.10', '3.11']
netbox-version: ['3.6', '3.7', '3.8'] # ❌ These branches don't exist
```

### **After (Fixed)**
```yaml
python-version: ['3.10', '3.11', '3.12']
netbox-version: ['4.0', '4.1', '4.2'] # ✅ Current supported versions
```

---

## 🔧 **Changes Applied**

### **CI/CD Pipeline** (`.github/workflows/ci.yml`)
- ✅ Updated Python versions: `3.10`, `3.11`, `3.12`
- ✅ Updated NetBox versions: `4.0`, `4.1`, `4.2`
- ✅ Fixed `actions/upload-artifact@v3` → `v4`
- ✅ Fixed `codecov/codecov-action@v3` → `v4`
- ✅ Added fallback git clone strategy
- ✅ Updated integration tests to use NetBox 4.2

### **Health Monitoring** (`.github/workflows/health-monitoring.yml`)
- ✅ Updated NetBox references to v4.2
- ✅ Fixed artifact upload actions to v4
- ✅ Updated Python version to 3.11

### **Code Quality** (`.github/workflows/code-quality.yml`)
- ✅ Fixed artifact upload actions to v4
- ✅ Updated Python version to 3.11

### **Release Readiness** (`.github/workflows/release-readiness.yml`)
- ✅ Updated Python/NetBox version matrix
- ✅ Fixed artifact upload actions to v4
- ✅ Set primary test version to Python 3.11 + NetBox 4.2

---

## 🛠️ **Local Development Updates**

### **Setup Scripts**
- ✅ `setup_local_testing.py`: Updated to clone NetBox v4.2
- ✅ `quick_fix.py`: Updated NetBox version requirements
- ✅ Documentation updated to reflect new supported versions

### **Compatibility Matrix**
| Python | NetBox | Status |
|--------|--------|--------|
| 3.10 | 4.0 | ✅ Supported |
| 3.10 | 4.1 | ✅ Supported |
| 3.10 | 4.2 | ✅ Supported |
| 3.11 | 4.0 | ✅ Supported |
| 3.11 | 4.1 | ✅ Supported |
| 3.11 | 4.2 | ✅ **Primary** |
| 3.12 | 4.0 | ✅ Supported |
| 3.12 | 4.1 | ✅ Supported |
| 3.12 | 4.2 | ✅ Supported |

---

## 🚀 **Next Steps**

### **1. Test the Fixes**
```bash
# Push these changes to trigger workflows
git add .
git commit -m "fix: update GitHub Actions to use artifact v4 and NetBox 4.x"
git push
```

### **2. Monitor Workflow Results**
- Check that all workflows run without the artifact deprecation error
- Verify NetBox 4.2 clones successfully
- Ensure all tests pass with the new version matrix

### **3. Update Local Environment**
If you're testing locally, update your setup:
```bash
# Quick update
python quick_fix.py
source quick_env.sh

# Or full setup
python setup_local_testing.py
source setup_test_env.sh
```

---

## 🔍 **What These Fixes Solve**

### **Immediate Issues**
- ✅ **No more artifact v3 deprecation errors**
- ✅ **No more git clone failures** for non-existent NetBox branches
- ✅ **Workflows will run successfully** on GitHub Actions

### **Long-term Benefits**
- ✅ **Future-proof**: Using latest supported versions
- ✅ **Better performance**: artifact v4 has improved upload/download speeds
- ✅ **Correct compatibility**: Testing against actual supported NetBox versions
- ✅ **Consistent environment**: Local and CI use same versions

---

## 📋 **Verification Checklist**

After pushing these changes, verify:

- [ ] CI/CD workflow runs without errors
- [ ] Health monitoring workflow completes successfully
- [ ] Code quality checks pass
- [ ] Release readiness validation works
- [ ] No more deprecation warnings in workflow logs
- [ ] NetBox 4.x installations succeed
- [ ] All test suites pass with new versions

---

## 🎉 **Summary**

Your GitHub Actions workflows are now:
- ✅ **Compatible** with GitHub's latest requirements
- ✅ **Using correct NetBox versions** (4.0-4.2)
- ✅ **Testing appropriate Python versions** (3.10-3.12)
- ✅ **Future-proofed** against deprecations
- ✅ **Aligned** with your plugin's actual requirements

The workflows should now run successfully without the errors you encountered! 🚀
Loading
Loading