Fix actions/upload-artifact@v4 #12
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/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| 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: 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 pytest pytest-cov flake8 black | |
| - name: Lint with flake8 | |
| run: | | |
| # stop the build if there are Python syntax errors or undefined names | |
| flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # exit-zero treats all errors as warnings | |
| flake8 src --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics | |
| - name: Check code formatting with black | |
| run: | | |
| black --check src/ | |
| - name: Test with pytest | |
| run: | | |
| pytest tests/ -v --cov=src --cov-report=xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| web-test: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Start web server | |
| run: | | |
| python -m uvicorn web.app:app --host 127.0.0.1 --port 8000 & | |
| sleep 10 | |
| - name: Test web endpoints | |
| run: | | |
| curl -f http://127.0.0.1:8000/health | |
| curl -f http://127.0.0.1:8000/ | |
| - name: Test API endpoint | |
| run: | | |
| curl -X POST http://127.0.0.1:8000/analyze \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"pain_point":"Test pain point","industry":"technology","company_size":"startup","urgency":"medium"}' \ | |
| -f | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install safety bandit | |
| - name: Run safety check | |
| run: | | |
| safety check | |
| - name: Run bandit security check | |
| run: | | |
| bandit -r src/ -f json -o bandit-report.json | |
| - name: Upload bandit report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: bandit-report | |
| path: bandit-report.json | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| needs: [test, web-test] | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build Docker image | |
| run: | | |
| docker build -t filum-pain-point-agent:latest . | |
| - name: Test Docker image | |
| run: | | |
| docker run -d -p 8000:8000 --name test-container filum-pain-point-agent:latest | |
| sleep 15 | |
| curl -f http://localhost:8000/health | |
| docker stop test-container | |
| deploy-docs: | |
| runs-on: ubuntu-latest | |
| needs: [test, web-test] | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs | |
| force_orphan: true |