Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/desloppify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Desloppify Quality Gate

on:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
quality:
name: Code Quality Gate (score >= 70)
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
with:
submodules: false

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Cache desloppify install
id: cache-desloppify
uses: actions/cache@v4
with:
path: /tmp/desloppify
key: desloppify-${{ runner.os }}-${{ hashFiles('.github/workflows/desloppify.yml') }}

- name: Clone desloppify
if: steps.cache-desloppify.outputs.cache-hit != 'true'
run: |
git clone --no-recurse-submodules https://github.com/Open-Paws/desloppify.git /tmp/desloppify

- name: Install desloppify
run: pip install "/tmp/desloppify[full]"

- name: Run quality gate
run: |
SCAN_OUTPUT=$(desloppify scan --path . --profile ci --no-badge 2>&1)
echo "${SCAN_OUTPUT}"
SCORE=$(echo "${SCAN_OUTPUT}" | grep -oP 'objective \K[\d.]+(?=/100)')
if [ -z "${SCORE}" ]; then
echo "ERROR: could not extract objective score from desloppify output"
exit 1
fi
echo "Objective score: ${SCORE}/100"
python3 -c "
score = float('${SCORE}')
threshold = 70
if score < threshold:
print(f'FAIL: objective score {score} is below the minimum {threshold}')
raise SystemExit(1)
print(f'PASS: objective score {score} >= {threshold}')
"
echo "## Desloppify Quality Gate" >> "${GITHUB_STEP_SUMMARY}"
echo "" >> "${GITHUB_STEP_SUMMARY}"
echo "| | |" >> "${GITHUB_STEP_SUMMARY}"
echo "|---|---|" >> "${GITHUB_STEP_SUMMARY}"
echo "| Objective score | **${SCORE}/100** |" >> "${GITHUB_STEP_SUMMARY}"
echo "| Threshold | 70 |" >> "${GITHUB_STEP_SUMMARY}"
echo "| Scan path | \`.\` |" >> "${GITHUB_STEP_SUMMARY}"
python3 -c "
score = float('${SCORE}')
result = 'PASS' if score >= 70 else 'FAIL'
print(f'| Result | **{result}** |')
" >> "${GITHUB_STEP_SUMMARY}"
Loading