Add GitHub Actions quick start guide #2
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
| name: CI - Tests & Linting | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis:7-alpine | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-cov flake8 black isort | |
| - name: Lint with flake8 | |
| run: | | |
| # Stop the build if there are Python syntax errors or undefined names | |
| flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # exit-zero treats all errors as warnings | |
| flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Check code formatting with black | |
| run: black --check src/ tests/ || true | |
| - name: Check import sorting with isort | |
| run: isort --check-only src/ tests/ || true | |
| - name: Run stress test | |
| env: | |
| REDIS_HOST: localhost | |
| REDIS_PORT: 6379 | |
| run: | | |
| # Start services in background | |
| python src/gateway/server.py & | |
| GATEWAY_PID=$! | |
| sleep 2 | |
| # Run stress test | |
| python tests/stress_test.py | |
| # Cleanup | |
| kill $GATEWAY_PID || true | |
| timeout-minutes: 5 | |
| - name: Generate coverage report | |
| env: | |
| REDIS_HOST: localhost | |
| REDIS_PORT: 6379 | |
| run: | | |
| pytest tests/ --cov=src/ --cov-report=xml --cov-report=html || true | |
| continue-on-error: true | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: false | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install bandit safety | |
| - name: Security check with bandit | |
| run: bandit -r src/ -ll || true | |
| - name: Check dependencies with safety | |
| run: | | |
| pip install -r requirements.txt | |
| safety check || true |