check_and_update_missing_query_forms #18
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: Check and Update Missing Query Forms | |
| on: | |
| schedule: | |
| # Runs at 00:00 UTC on the first day of every month. | |
| - cron: "0 0 1 * *" | |
| workflow_dispatch: # allow manual trigger | |
| jobs: | |
| check-repository: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_remote_main: ${{ steps.check.outputs.is_remote_main }} | |
| steps: | |
| - name: Check repository | |
| id: check | |
| run: | | |
| if [ "$GITHUB_REPOSITORY" = "scribe-org/Scribe-Data" ]; then | |
| echo "is_remote_main=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "is_remote_main=false" >> "$GITHUB_OUTPUT" | |
| echo "::warning::This workflow should only run in scribe-org/Scribe-Data repository." | |
| fi | |
| create-pull-request: | |
| needs: check-repository | |
| if: needs.check-repository.outputs.is_remote_main == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.x" | |
| - name: Install Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-dev.txt | |
| pip install -e . | |
| - name: Generate Missing Features Data | |
| run: | | |
| # Set up paths | |
| QUERY_DIR="$(pwd)/src/scribe_data/wikidata/language_data_extraction" | |
| echo "Query directory: ${QUERY_DIR}" | |
| # Generate the missing features data with all keys processing and automatic dump download. | |
| PYTHONPATH=$PYTHONPATH:$(pwd)/src | |
| python src/scribe_data/check/check_missing_forms/check_missing_forms.py "${QUERY_DIR}" --download-dump --process-all-keys | |
| # Debug steps to understand the state. | |
| # - name: Debug Info | |
| # run: | | |
| # echo "Current branch: $(git branch --show-current)" | |
| # echo "List of changes:" | |
| # git status | |
| - name: Make Changes | |
| run: | | |
| git add src/scribe_data/wikidata/language_data_extraction/**/*.sparql | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| # - name: Debug Missing Features Data | |
| # if: always() | |
| # run: | | |
| # # Print the contents of the missing features JSON file if it exists. | |
| # if [ -f query_check_missing_features.json ]; then | |
| # echo "Contents of query_check_missing_features.json:" | |
| # cat query_check_missing_features.json | |
| # else | |
| # echo "query_check_missing_features.json not found" | |
| # fi | |
| - name: Check Generated Query Forms | |
| working-directory: ./src/scribe_data/check | |
| run: | | |
| python check_query_identifiers.py | |
| python check_query_forms.py | |
| - name: Post-run Status | |
| if: failure() | |
| run: echo "Generated SPARQL query forms or identifiers check failed. Please fix the reported errors." | |
| - name: Generate PR Body | |
| id: pr-body | |
| run: | | |
| # Run the pr_body.py script with the missing features data. | |
| PR_BODY_CONTENT=$(python src/scribe_data/check/check_missing_forms/pr_body.py query_check_missing_features.json) || echo "No missing query forms found." | |
| # Debug output. | |
| # echo "PR Body Content:" | |
| # echo "$PR_BODY_CONTENT" | |
| # Initialize PR body with delimiter. | |
| { | |
| echo "body<<EOF" | |
| echo "$PR_BODY_CONTENT" | |
| echo "EOF" | |
| } >> $GITHUB_OUTPUT | |
| # - name: Debug PR Body Output | |
| # run: | | |
| # # Print the PR body content from the output. | |
| # echo "PR Body from GITHUB_OUTPUT:" | |
| # cat $GITHUB_OUTPUT | |
| # Create a PR only when we're missing forms. | |
| - name: Create Pull Request | |
| if: steps.pr-body.outputs.body != 'No missing query forms found.' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| title: "Chore: Update missing Wikidata query forms" | |
| body: ${{ steps.pr-body.outputs.body }} | |
| base: main | |
| branch: update-missing-query-forms | |
| delete-branch: true | |
| draft: false | |
| commit-message: "Chore: Update missing Wikidata query forms" | |
| committer: GitHub <noreply@github.com> | |
| author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> | |
| # # Debug step to verify PR creation attempt. | |
| # - name: Check PR Creation | |
| # run: | | |
| # echo "Checking if PR was created..." | |
| # gh pr list | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |