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
19 changes: 19 additions & 0 deletions .github/dependency-review-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Dependency review configuration
# https://github.com/actions/dependency-review-action

fail_on_severity: moderate
allow_licenses:
- MIT
- BSD-2-Clause
- BSD-3-Clause
- Apache-2.0
- ISC
- PSF-2.0

deny_licenses:
- MS-PL
- GPL-2.0
- GPL-3.0

vulnerability_check: true
license_check: true
151 changes: 151 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: CI/CD Pipeline

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

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
exclude:
# Exclude some combinations to reduce matrix size
- os: macos-latest
python-version: '3.8'
- os: windows-latest
python-version: '3.11'

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-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt

- name: Run linting
run: |
pip install flake8 black mypy
flake8 react2shell_checker_unified.py tests/
black --check react2shell_checker_unified.py tests/
mypy react2shell_checker_unified.py

- name: Run tests
run: |
pytest --cov=react2shell_checker_unified --cov-report=xml --durations=10

- name: Test cross-platform functionality
run: |
python react2shell_checker_unified.py --path . || echo "Expected to fail on non-React project"

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

security-scan:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run security scan on self
run: python react2shell_checker_unified.py --path .

- name: Run Bandit security scanner
run: |
pip install bandit
bandit -r . -f json -o bandit-report.json || true

- name: Upload security scan results
if: always()
uses: actions/upload-artifact@v3
with:
name: security-scan-results
path: bandit-report.json

build:
runs-on: ubuntu-latest
needs: [test, security-scan]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
- uses: actions/checkout@v4

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

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: python -m build

- name: Check package
run: twine check dist/*

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: python-package
path: dist/

release:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && startsWith(github.event.head_commit.message, 'release:')

steps:
- uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: python-package
path: dist/

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
38 changes: 38 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Dependency Review

on:
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Dependency Review
uses: actions/dependency-review-action@v3
with:
config-file: '.github/dependency-review-config.yml'

license-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Check licenses
run: |
pip install pip-licenses
pip install -r requirements.txt
pip-licenses --format=json > licenses.json

- name: Upload license report
uses: actions/upload-artifact@v3
with:
name: license-report
path: licenses.json
62 changes: 62 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Security Scan

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:

jobs:
vulnerability-scan:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run React2Shell vulnerability scan
run: python react2shell_checker_unified.py --path .

- name: Run dependency vulnerability check
run: |
pip install safety
safety check --output json > safety-report.json || true

- name: Upload vulnerability scan results
if: always()
uses: actions/upload-artifact@v3
with:
name: vulnerability-scan
path: |
safety-report.json

codeql-analysis:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python
queries: security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Loading