setting up demo repo #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 Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.8, 3.9, '3.10', '3.11'] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Lint with flake8 | |
| run: | | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Type check with mypy | |
| run: | | |
| mypy app/ --ignore-missing-imports | |
| continue-on-error: true | |
| - name: Run tests | |
| run: | | |
| pytest tests/ -v --cov=app --cov-report=xml | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Run Bandit security scanner | |
| run: | | |
| pip install bandit | |
| bandit -r app/ -f json -o bandit-report.json | |
| continue-on-error: true | |
| - name: Upload security report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: security-report | |
| path: bandit-report.json | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Build Docker image | |
| run: | | |
| docker build -t bloghub:${{ github.sha }} . | |
| - name: Test Docker image | |
| run: | | |
| docker run -d -p 5000:5000 bloghub:${{ github.sha }} | |
| sleep 5 | |
| curl -f http://localhost:5000/api/health || exit 1 |