Added a testing case that should resolve to BOG #94
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: AutocompleteMetadata | |
| on: | |
| pull_request_target: | |
| paths: | |
| - 'Molecules/membrane/**/metadata.yaml' | |
| - 'Molecules/solution/**/metadata.yaml' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| add-metadata: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout BilayerData | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| persist-credentials: false | |
| - name: Clone Databank and install | |
| run: | | |
| git clone --depth 1 https://github.com/NMRlipids/FAIRMD_lipids.git "$RUNNER_TEMP/Databank" | |
| pip install "$RUNNER_TEMP/Databank" | |
| - name: Install the gh cli | |
| uses: ksivamuthu/actions-setup-gh-cli@v3 | |
| with: | |
| version: 2.83.0 | |
| - name: Find changed metadata.yaml files | |
| id: files | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| changed_files=$(gh api --paginate \ | |
| "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \ | |
| --jq '.[] | select(.status != "removed") | .filename' \ | |
| | grep -E '^Molecules/(membrane|solution)/[^/]+/metadata\.yaml$' || true) | |
| { | |
| echo "changed_files<<EOF" | |
| echo "$changed_files" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| echo "Changed files:" | |
| echo "$changed_files" | |
| - name: Run AddMetadata.py and create suggestions | |
| if: steps.files.outputs.changed_files != '' | |
| env: | |
| CHANGED_FILES: ${{ steps.files.outputs.changed_files }} | |
| CAS_API_KEY: ${{ secrets.CAS_API_KEY }} | |
| run: | | |
| set -euo pipefail | |
| while IFS= read -r f; do | |
| [ -n "$f" ] || continue | |
| echo "::group::autocomplete_metadata.py $f" | |
| python "$RUNNER_TEMP/Databank/developer/autocomplete_metadata.py" "$f" | |
| echo "::endgroup::" | |
| done <<< "$CHANGED_FILES" | |
| - name: Suggest changes on PR | |
| if: steps.files.outputs.changed_files != '' | |
| uses: reviewdog/action-suggester@v1 | |
| with: | |
| tool_name: addmetadata | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| fail_level: none # post suggestions without failing the job | |
| reviewdog_flags: -tee # echo reviewdog's stdout/stderr to the log |