Build and Test #139
Workflow file for this run
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: Build and Test | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| branches: | |
| - "main" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: get-directories | |
| strategy: | |
| matrix: | |
| directory: ${{ fromJson(needs.get-directories.outputs.directories) }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install requirements | |
| run: pip install -r requirements-dev.txt | |
| - name: Update __init__.py | |
| working-directory: src/${{ matrix.directory }} | |
| run: | | |
| name=$(uv run tomlq -r '.project.name' pyproject.toml) | |
| version=$(uv run tomlq -r '.project.version' pyproject.toml) | |
| if [ -d oracle/*_mcp_server ]; then | |
| init_py_file=oracle/*_mcp_server/__init__.py | |
| echo "\"\"\"\nCopyright (c) 2025, Oracle and/or its affiliates.\nLicensed under the Universal Permissive License v1.0 as shown at\nhttps://oss.oracle.com/licenses/upl.\n\"\"\"\n" > $$init_py_file; \ | |
| echo "__project__ = \"$name\"" >> $init_py_file | |
| echo "__version__ = \"$version\"" >> $init_py_file | |
| fi | |
| - name: Sync | |
| working-directory: src/${{ matrix.directory }} | |
| run: uv sync --locked --all-extras --dev | |
| - name: Test | |
| working-directory: src/${{ matrix.directory }} | |
| run: | | |
| uv run pytest --cov=. --cov-report=html | |
| env: | |
| COVERAGE_FILE: .coverage.${{ matrix.directory }} | |
| - name: Build | |
| working-directory: src/${{ matrix.directory }} | |
| run: uv build | |
| - name: Test install | |
| working-directory: src/${{ matrix.directory }} | |
| run: uv pip install . | |
| - name: Store coverage file | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ matrix.directory }} | |
| path: src/${{ matrix.directory }}/.coverage.${{ matrix.directory }} | |
| # By default hidden files/folders (i.e. starting with .) are ignored. | |
| # You may prefer (for security reasons) not setting this and instead | |
| # set COVERAGE_FILE above to not start with a `.`, but you cannot | |
| # use "MERGE_COVERAGE_FILES: true" later on and need to manually | |
| # combine the coverage file using "pipx run coverage combine" | |
| include-hidden-files: true | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.directory }}-coverage-report | |
| path: src/${{ matrix.directory }}/htmlcov | |
| get-directories: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| directories: ${{ steps.get-directories.outputs.directories }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get directories | |
| id: get-directories | |
| run: | | |
| directories=$(ls src | grep -v dbtools-mcp-server | grep -v mysql-mcp-server | grep -v oci-pricing-mcp-server | grep -v oracle-db-doc-mcp-server | jq -R -s -c 'split("\n")[:-1]') | |
| echo "directories=$directories" >> $GITHUB_OUTPUT | |
| coverage: | |
| name: Coverage | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| id: download | |
| with: | |
| pattern: coverage-* | |
| merge-multiple: true | |
| - name: Coverage comment | |
| id: coverage_comment | |
| uses: py-cov-action/python-coverage-comment-action@v3 | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| MERGE_COVERAGE_FILES: true | |
| - name: Store Pull Request comment to be posted | |
| uses: actions/upload-artifact@v4 | |
| if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
| with: | |
| name: python-coverage-comment-action | |
| path: python-coverage-comment-action.txt |