|
| 1 | +name: Modified Target Validation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - "sherlock_project/resources/data.json" |
| 9 | + |
| 10 | +jobs: |
| 11 | + validate-modified-targets: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v5 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v6 |
| 21 | + with: |
| 22 | + python-version: '3.13' |
| 23 | + |
| 24 | + - name: Install Poetry |
| 25 | + uses: abatilo/actions-poetry@v4 |
| 26 | + with: |
| 27 | + poetry-version: 'latest' |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + poetry install --no-interaction --with dev |
| 32 | +
|
| 33 | + - name: Discover modified targets |
| 34 | + id: discover-modified |
| 35 | + run: | |
| 36 | + # Fetch the upstream branch |
| 37 | + git fetch origin ${{ github.base_ref }} --depth=1 |
| 38 | +
|
| 39 | + # Discover changes |
| 40 | + git show origin/${{ github.base_ref }}:sherlock_project/resources/data.json > data.json.base |
| 41 | + CHANGED=$( |
| 42 | + jq --slurpfile base data.json.base --slurpfile head sherlock_project/resources/data.json ' |
| 43 | + [ |
| 44 | + ($head[0] | keys_unsorted[]) as $key |
| 45 | + | select(($base[0][$key] != $head[0][$key]) or ($base[0][$key] | not)) |
| 46 | + | $key |
| 47 | + ] | unique | join(",")' |
| 48 | + ) |
| 49 | +
|
| 50 | + # Preserve changelist |
| 51 | + echo ">>> Changed targets: \n$(echo $CHANGED | tr ',' '\n')" |
| 52 | + echo "changed_targets=$CHANGED" >> "$GITHUB_OUTPUT" |
| 53 | +
|
| 54 | + - name: Validate modified targets |
| 55 | + if: steps.discover-modified.outputs.changed_targets != '' |
| 56 | + run: | |
| 57 | + $(poetry env activate) |
| 58 | + pytest -q --tb no -rA -m validate_targets -n 20 --chunked-sites "${{ steps.discover-modified.outputs.changed_targets }}" |
| 59 | + deactivate |
| 60 | +
|
| 61 | + - name: Announce skip if no modified targets |
| 62 | + if: steps.discover-modified.outputs.changed_targets == '' |
| 63 | + run: | |
| 64 | + echo "No modified targets found" |
0 commit comments