OBO flow changes using user managed identity credentials (#68) #154
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: Code Quality | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
quality: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install ".[dev]" | |
- name: Check code quality | |
id: quality | |
continue-on-error: true | |
run: | | |
echo "::group::Running isort" | |
isort_output=$(isort . --skip-glob=**/_version.py --extend-skip-glob=__init__.py --check-only --diff 2>&1) || isort_failed=true | |
echo "$isort_output" | |
echo "::endgroup::" | |
echo "::group::Running Black" | |
black_output=$(black . --check --diff 2>&1) || black_failed=true | |
echo "$black_output" | |
echo "::endgroup::" | |
echo "::group::Running Flake8" | |
flake8_output=$(flake8 . 2>&1) || flake8_failed=true | |
echo "$flake8_output" | |
echo "::endgroup::" | |
echo "::group::Running MyPy" | |
mypy_output=$(mypy fabric_rti_mcp --explicit-package-bases 2>&1) || mypy_failed=true | |
echo "$mypy_output" | |
echo "::endgroup::" | |
# Prepare markdown report | |
echo "# Code Quality Report" > report.md | |
echo "" >> report.md | |
if [ "$isort_failed" = true ]; then | |
echo "### ❌ isort checks failed" >> report.md | |
echo "\`\`\`" >> report.md | |
echo "$isort_output" >> report.md | |
echo "\`\`\`" >> report.md | |
else | |
echo "### ✅ isort checks passed" >> report.md | |
fi | |
if [ "$black_failed" = true ]; then | |
echo "### ❌ Black checks failed" >> report.md | |
echo "\`\`\`" >> report.md | |
echo "$black_output" >> report.md | |
echo "\`\`\`" >> report.md | |
else | |
echo "### ✅ Black checks passed" >> report.md | |
fi | |
if [ "$flake8_failed" = true ]; then | |
echo "### ❌ Flake8 checks failed" >> report.md | |
echo "\`\`\`" >> report.md | |
echo "$flake8_output" >> report.md | |
echo "\`\`\`" >> report.md | |
else | |
echo "### ✅ Flake8 checks passed" >> report.md | |
fi | |
if [ "$mypy_failed" = true ]; then | |
echo "### ❌ MyPy checks failed" >> report.md | |
echo "\`\`\`" >> report.md | |
echo "$mypy_output" >> report.md | |
echo "\`\`\`" >> report.md | |
else | |
echo "### ✅ MyPy checks passed" >> report.md | |
fi | |
if [ "$isort_failed" = true ] || [ "$black_failed" = true ] || [ "$flake8_failed" = true ] || [ "$mypy_failed" = true ]; then | |
echo "checks_failed=true" >> $GITHUB_OUTPUT | |
else | |
echo "checks_failed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Run tests | |
id: tests | |
continue-on-error: true | |
run: | | |
echo "::group::Running pytest" | |
pytest_output=$(python -m pytest 2>&1) || pytest_failed=true | |
echo "$pytest_output" | |
echo "::endgroup::" | |
# Add test results to report | |
if [ "$pytest_failed" = true ]; then | |
echo "### ❌ Pytest checks failed" >> report.md | |
echo "\`\`\`" >> report.md | |
echo "$pytest_output" >> report.md | |
echo "\`\`\`" >> report.md | |
else | |
echo "### ✅ Pytest checks passed" >> report.md | |
fi | |
if [ "$pytest_failed" = true ]; then | |
echo "tests_failed=true" >> $GITHUB_OUTPUT | |
else | |
echo "tests_failed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Post results | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs'); | |
const report = fs.readFileSync('report.md', 'utf8'); | |
// Posting comments doesn't work if the PR is from another repository (fork) due to permissions. | |
// This is crude solution but should work. | |
try { | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: report | |
}); | |
} | |
catch (error) { | |
console.error("Error posting comment:", error); | |
} | |
- name: Check results | |
if: steps.quality.outputs.checks_failed == 'true' || steps.tests.outputs.tests_failed == 'true' | |
run: exit 1 |