Update python-ci.yml #4
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: Python CI | ||
| on: | ||
| push: | ||
| branches: [ master, lab03 ] | ||
| paths: | ||
| - 'app_python/**' | ||
| - '.github/workflows/python-ci.yml' | ||
| pull_request: | ||
| paths: | ||
| - 'app_python/**' | ||
| jobs: | ||
| test-build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| cache: "pip" | ||
| - name: Install dependencies | ||
| run: | | ||
| pip install -r app_python/requirements.txt | ||
| pip install -r app_python/requirements-dev.txt | ||
| - name: Lint | ||
| run: ruff check app_python | ||
| - name: Run tests | ||
| run: pytest app_python/tests | ||
| - name: Generate version | ||
| run: echo "VERSION=$(date +%Y.%m.%d)" >> $GITHUB_ENV | ||
| - name: Login Docker | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Snyk Scan | ||
| uses: snyk/actions/python@master | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| working-directory: app_python | ||
| with: | ||
| command: test | ||
| - name: Build and Push Docker Image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ./app_python | ||
| push: true | ||
| tags: | | ||
| maksimmenshikh/devops-info-service:${{ env.VERSION }} | ||
| maksimmenshikh/devops-info-service:latest | ||