Skip to content

Bump the pip group across 1 directory with 4 updates #7

Bump the pip group across 1 directory with 4 updates

Bump the pip group across 1 directory with 4 updates #7

Workflow file for this run

name: CI/CD Pipeline

Check failure on line 1 in .github/workflows/ci-cd.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci-cd.yml

Invalid workflow file

(Line: 137, Col: 11): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.RENDER_DEPLOY_HOOK_URL != ''
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
# Job 1: Lint and Test
test:
name: Lint and Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov flake8
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=venv,env,.venv,.git,__pycache__
# Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=venv,env,.venv,.git,__pycache__
- name: Run tests
run: |
pytest tests/ -v --cov=app --cov-report=xml --cov-report=term
env:
FLASK_ENV: testing
SECRET_KEY: test-secret-key
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: false
# Job 2: Security Scan
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install safety
run: pip install safety
- name: Run safety check
run: safety check --json || true
- name: Run Bandit security scan
run: |
pip install bandit
bandit -r . -f json -o bandit-report.json || true
- name: Upload security reports
uses: actions/upload-artifact@v3
if: always()
with:
name: security-reports
path: |
bandit-report.json
# Job 3: Build Docker Image
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [test, security]
if: github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
${{ secrets.DOCKER_USERNAME }}/project-management:latest
${{ secrets.DOCKER_USERNAME }}/project-management:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Docker image
run: |
docker build -t project-management:test .
docker run -d -p 8000:8000 --name test-container project-management:test
sleep 10
curl http://localhost:8000/health || exit 1
docker stop test-container
# Job 4: Deploy to Render (optional)
deploy-render:
name: Deploy to Render
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Trigger Render Deployment
if: secrets.RENDER_DEPLOY_HOOK_URL != ''
run: |
curl -X POST "${{ secrets.RENDER_DEPLOY_HOOK_URL }}"
- name: Deployment notification
run: echo "Deployment triggered to Render"