Skip to content

feat: add duplicate-key QC gate to qcModelChecks #35

feat: add duplicate-key QC gate to qcModelChecks

feat: add duplicate-key QC gate to qcModelChecks #35

Workflow file for this run

name: Run QC tests
on: [pull_request]
env:
RESULT_FILES: >-
qc_duplicate_keys.csv qc_empty_reactions.csv qc_annotation_consistency.csv
qc_unused_entities.csv qc_duplicate_reactions.csv qc_metabolite_completeness.csv
qc_reaction_sanity.csv qc_annotation_issues.csv qc_growth.txt memote_score.md
macaw_results.csv balance_results.csv
jobs:
qc-tests:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install dependencies
run: pip install git+https://github.com/Devlin-Moyer/macaw.git@main numpy==1.26.4
# continue-on-error so a MACAW crash does not skip the balance report and the
# comment; a MACAW crash leaves macaw_results.csv unchanged, so the comment
# shows those rows as pending rather than as this commit's result.
- name: Run MACAW tests
continue-on-error: true
run: python code/test/macawTests.py | tee "$RUNNER_TEMP/macaw_summary.txt"
- name: Mass and charge balance report
continue-on-error: true
run: python code/test/balanceTest.py | tee "$RUNNER_TEMP/balance_summary.txt"
- name: Write MACAW and balance summary
run: |
{
echo "#### MACAW: dead-end and duplicate tests"
echo ""
echo '```'
cat "$RUNNER_TEMP/macaw_summary.txt"
echo '```'
echo ""
echo "#### Mass and charge balance"
echo ""
echo '```'
if [ -s "$RUNNER_TEMP/balance_summary.txt" ]; then
cat "$RUNNER_TEMP/balance_summary.txt"
else
echo "(balance report unavailable)"
fi
echo '```'
} > data/testResults/qc_summary.md
- name: Stamp results with the head commit
run: echo "${{ github.event.pull_request.head.sha }}" > data/testResults/qc_macaw.sha
- name: Fetch target-branch results for comparison
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
git fetch --depth=1 origin "$BASE_REF" || true
mkdir -p "$RUNNER_TEMP/base"
for f in $RESULT_FILES; do
git show "origin/$BASE_REF:data/testResults/$f" > "$RUNNER_TEMP/base/$f" 2>/dev/null || rm -f "$RUNNER_TEMP/base/$f"
done
- name: Mention PR# in README.md
env:
PR_NUMBER: ${{ github.event.number }}
run: sed -i -e "s/[[:digit:]]\{3,4\}\*\* (MACAW/$PR_NUMBER\*\* (MACAW/" data/testResults/README.md
- name: Update local branch before committing changes
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
git stash
git fetch
git checkout $BRANCH_NAME
if git stash list | grep -q 'stash@{'; then
git stash pop
fi
- name: Auto-commit results
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_user_name: memote-bot
# [skip ci] so this results commit does not re-trigger the workflows.
commit_message: "chore: add QC test results [skip ci]"
file_pattern: data/testResults/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- name: Build report comment
id: report
env:
BASE_RESULTS_DIR: ${{ runner.temp }}/base
BASE_REF: ${{ github.event.pull_request.base.ref }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
RESULTS_URL_BASE: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.head_ref }}/data/testResults
run: |
python code/test/buildReport.py
{
echo "results<<QC_EOF"
cat data/testResults/model_qc_summary.md
echo "QC_EOF"
} >> "$GITHUB_OUTPUT"
- name: Post comment
uses: NejcZdovc/comment-pr@v2
with:
file: "commentReport.md"
identifier: "GITHUB_COMMENT_QC"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEST_RESULTS: ${{ steps.report.outputs.results }}
GH_ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}