Merge redundant overlapping tools: isotope pattern trio → analyzer, MGF/mzML pair → single converter #13
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: Validate Tools | |
| on: | |
| pull_request: | |
| paths: | |
| - 'tools/**' | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.detect.outputs.matrix }} | |
| has_changes: ${{ steps.detect.outputs.has_changes }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - id: detect | |
| name: Detect changed tool directories | |
| run: | | |
| # Note: github.base_ref is only available on pull_request events | |
| # Find all tool directories that changed in this PR, keeping only | |
| # those that still exist (deleted tool dirs must not be linted/tested). | |
| CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- 'tools/' \ | |
| | grep -oP 'tools/[^/]+/[^/]+/[^/]+/' \ | |
| | sort -u \ | |
| | while read -r dir; do [ -d "$dir" ] && echo "$dir"; done \ | |
| | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| if [ "$CHANGED" = "[]" ] || [ -z "$CHANGED" ]; then | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| echo "matrix=[]" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| echo "matrix=$CHANGED" >> "$GITHUB_OUTPUT" | |
| fi | |
| validate: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.has_changes == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Create shared venv and install dependencies | |
| run: | | |
| python -m venv /tmp/validate_venv | |
| /tmp/validate_venv/bin/python -m pip install pyopenms numpy scipy click pytest ruff | |
| DIRS='${{ needs.detect-changes.outputs.matrix }}' | |
| echo "$DIRS" | jq -r '.[]' | while read -r dir; do | |
| if [ -f "${dir}requirements.txt" ]; then | |
| /tmp/validate_venv/bin/python -m pip install -r "${dir}requirements.txt" | |
| fi | |
| done | |
| - name: Lint changed tools | |
| run: | | |
| DIRS='${{ needs.detect-changes.outputs.matrix }}' | |
| echo "$DIRS" | jq -r '.[]' | while read -r dir; do | |
| if [ -d "$dir" ]; then | |
| echo "::group::ruff $dir" | |
| /tmp/validate_venv/bin/python -m ruff check "$dir" | |
| echo "::endgroup::" | |
| fi | |
| done | |
| - name: Test changed tools | |
| run: | | |
| DIRS='${{ needs.detect-changes.outputs.matrix }}' | |
| echo "$DIRS" | jq -r '.[]' | while read -r dir; do | |
| if [ -d "${dir}tests/" ]; then | |
| echo "::group::pytest $dir" | |
| PYTHONPATH="$dir" /tmp/validate_venv/bin/python -m pytest "${dir}tests/" -v | |
| echo "::endgroup::" | |
| fi | |
| done |