Update dependency greenlet to v3.5.4 #272
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: Unit Tests | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| # Only run for ansible organization | |
| if: github.repository_owner == 'ansible' | |
| env: | |
| UV_CACHE_DIR: /tmp/.uv-cache | |
| HF_HOME: /tmp/.cache/huggingface | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Cache uv dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.UV_CACHE_DIR }} | |
| key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} | |
| restore-keys: | | |
| uv-${{ runner.os }}- | |
| - name: Cache HuggingFace models | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.HF_HOME }} | |
| key: hf-models-${{ runner.os }}-all-mpnet-base-v2 | |
| restore-keys: | | |
| hf-models-${{ runner.os }}- | |
| - name: Setup development environment | |
| run: make setup | |
| # TODO: Enable linters once pre-existing issues are fixed | |
| # - name: Run linters | |
| # run: make verify | |
| # TODO: Enable type checker once issues are fixed | |
| # - name: Run type checker | |
| # run: make check-types | |
| - name: Run unit tests with coverage | |
| run: PYTHONPATH=src:$PYTHONPATH uv run pytest tests/ -v -c pyproject.toml --cov=src --cov=scripts --cov-report=xml --cov-report=term | |
| # Fix paths in coverage file for SonarCloud | |
| # See https://sonarsource.atlassian.net/browse/SONARPY-1203 | |
| - name: Fix paths in coverage file | |
| if: always() | |
| run: | | |
| if [ -f coverage.xml ]; then | |
| sed -i "s,/home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/,,g" coverage.xml | |
| fi | |
| # Embed PR number in coverage.xml for cross-workflow communication | |
| - name: Embed PR number in coverage.xml | |
| if: github.event_name == 'pull_request' && always() | |
| run: | | |
| if [ -f coverage.xml ]; then | |
| sed -i '2i<!-- PR ${{ github.event.pull_request.number }} -->' coverage.xml | |
| fi | |
| - name: Upload coverage artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage | |
| path: coverage.xml | |
| retention-days: 1 | |
| if-no-files-found: warn | |
| ##################### | |
| # Upload coverage to Codecov | |
| ##################### | |
| - name: Upload Python coverage to Codecov | |
| # Skip for fork PRs where secrets are not available | |
| if: always() && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') | |
| uses: codecov/codecov-action@0f8570b1a125f4937846a11fcfa3bcd548bd8c97 # v4.6.0 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| url: ${{ vars.CODECOV_URL }} | |
| files: ./coverage.xml | |
| flags: python | |
| disable_search: true | |
| fail_ci_if_error: false | |
| ##################### | |
| # SonarCloud analysis | |
| ##################### | |
| - name: Extract repo owner and name | |
| if: always() && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if [ "${{ github.event.repository.fork }}" = "true" ]; then | |
| PARENT_REPO_SLUG=$(gh api repos/${{ github.repository }} | jq -r '.parent.full_name') | |
| IFS="/" read -r REPO_OWNER REPO_NAME <<< "$PARENT_REPO_SLUG" | |
| else | |
| IFS="/" read -r REPO_OWNER REPO_NAME <<< "${GITHUB_REPOSITORY}" | |
| fi | |
| echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV | |
| echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV | |
| - name: Verify SONAR_TOKEN is set | |
| if: always() && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') | |
| run: test -n "$SONAR_TOKEN" || { echo "SONAR_TOKEN is empty — check vars.SONAR_TOKEN_SECRET_NAME"; exit 1; } | |
| env: | |
| SONAR_TOKEN: ${{ secrets[format('{0}', vars.SONAR_TOKEN_SECRET_NAME)] }} | |
| - name: SonarCloud Scan | |
| # Skip for fork PRs where secrets are not available | |
| if: always() && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') | |
| uses: SonarSource/sonarqube-scan-action@v6 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets[format('{0}', vars.SONAR_TOKEN_SECRET_NAME)] }} | |
| with: | |
| args: > | |
| -Dsonar.projectKey=${{ env.REPO_OWNER }}_${{ env.REPO_NAME }} | |
| -Dsonar.organization=${{ env.REPO_OWNER }} | |
| - name: Upload test artifacts (on failure) | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-logs | |
| path: | | |
| .pytest_cache/ | |
| retention-days: 3 | |
| - name: Summary | |
| if: always() | |
| env: | |
| BRANCH_NAME: ${{ github.ref_name }} | |
| JOB_STATUS: ${{ job.status }} | |
| run: | | |
| echo "## Test Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Python Version**: 3.12" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch**: ${BRANCH_NAME}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${JOB_STATUS}" == "success" ]; then | |
| echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ Some tests failed. Check the logs above for details." >> $GITHUB_STEP_SUMMARY | |
| fi |