Merge pull request #125 from AET-DevOps26/contract-testing #52
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 Help Service | |
| on: | |
| push: | |
| paths: | |
| - 'services/py-help-service/**' | |
| - 'api/openapi-internal.yaml' | |
| - '.github/workflows/build-help-service.yml' | |
| workflow_dispatch: | |
| workflow_call: | |
| inputs: | |
| push_image: | |
| type: boolean | |
| default: false | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: services/py-help-service | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Linting Tool | |
| run: pip install ruff | |
| - name: Run Ruff Linting | |
| run: ruff check . | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| checks: write | |
| pull-requests: write | |
| defaults: | |
| run: | |
| working-directory: services/py-help-service | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r dev-requirements.txt | |
| - name: Run pytest | |
| env: | |
| INTERNAL_AUTH_SECRET: ${{ secrets.INTERNAL_AUTH_SECRET }} | |
| run: | | |
| pytest --junitxml=report.xml --cov=main --cov-report=html:htmlcov | |
| - name: Publish test results | |
| uses: dorny/test-reporter@v1 | |
| if: always() | |
| with: | |
| name: Help Service Tests | |
| path: services/py-help-service/report.xml | |
| reporter: java-junit | |
| - name: Upload coverage HTML | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: help-service-coverage | |
| path: services/py-help-service/htmlcov/ | |
| retention-days: 7 | |
| build: | |
| needs: [lint, test] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GHCR | |
| if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' || inputs.push_image == true | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lowercase image prefix | |
| run: echo "IMAGE_PREFIX=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: services/py-help-service | |
| push: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' || inputs.push_image == true }} | |
| tags: | | |
| ${{ env.IMAGE_PREFIX }}/py-help-service:${{ github.sha }} | |
| ${{ env.IMAGE_PREFIX }}/py-help-service:latest |