-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds proof ingestion workflow #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: Fetch and add new proofs | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| # once a week | ||
| - cron: '0 0 * * 0' | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| fetch-and-add: | ||
| env: | ||
| BRANCH: proof-auto-add-${{ github.run_id }} | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| TOP_SOURCES_LIST: ${{ vars.TOP_SOURCES_LIST }} | ||
| OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} | ||
| API_KEY: ${{ secrets.API_KEY }} | ||
| API_BASE_URL: ${{ vars.API_BASE_URL }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: main | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
semmet95 marked this conversation as resolved.
|
||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
|
|
||
| - name: Setup Git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Create branch from main | ||
| run: | | ||
| git checkout -b "$BRANCH" origin/main | ||
|
|
||
| - name: Run proof fetch script (with retries) | ||
| run: | | ||
| set -e | ||
| attempt=1 | ||
| max=3 | ||
| until [ $attempt -gt $max ]; do | ||
| echo "Attempt $attempt..." | ||
| if python scripts/ingest_proofs.py; then | ||
| echo "Script succeeded" | ||
| break | ||
| fi | ||
| attempt=$((attempt+1)) | ||
| if [ $attempt -le $max ]; then | ||
| echo "Retrying in 60 seconds..." | ||
| sleep 60 | ||
| fi | ||
| done | ||
| if [ $attempt -gt $max ]; then | ||
| echo "Script failed after $max attempts" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Commit and push changes | ||
| id: commit | ||
| run: | | ||
| git add --all | ||
| if git diff --cached --quiet; then | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| echo "No changes to commit" | ||
| else | ||
| git commit -m "chore(proofs): adds new proofs for the ingested claims" | ||
| git push origin "$BRANCH" | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Create Pull Request | ||
| if: steps.commit.outputs.changed == 'true' | ||
| run: | | ||
| gh pr create \ | ||
| --title "Auto PR: Scheduled addition of new proofs" \ | ||
| --body "Adds proofs for claims made by the ingested sources in the last week for ingestion" \ | ||
| --base main | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: POST New Proof Documents on Merge | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| post: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
semmet95 marked this conversation as resolved.
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
semmet95 marked this conversation as resolved.
|
||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
|
|
||
| - name: Get added files in latest commit | ||
| id: added | ||
| run: | | ||
| files=$(git diff --diff-filter=A HEAD~1 HEAD --name-only | grep -E '^(proofs)/' || true) | ||
|
semmet95 marked this conversation as resolved.
|
||
| echo "Added files:" | ||
| echo "$files" | ||
| # Trim only leading/trailing whitespace, preserve internal spaces in filenames | ||
| files=$(echo "$files" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') | ||
| echo "ADDED_FILES<<EOF" >> "$GITHUB_ENV" | ||
| echo "$files" >> "$GITHUB_ENV" | ||
| echo "EOF" >> "$GITHUB_ENV" | ||
|
|
||
| - name: POST new documents | ||
| if: env.ADDED_FILES != '' | ||
| run: python scripts/post_requests.py | ||
| env: | ||
| API_BASE_URL: ${{ vars.API_BASE_URL }} | ||
| API_KEY: ${{ secrets.API_KEY }} | ||
|
|
||
| - name: Nothing to POST | ||
| if: env.ADDED_FILES == '' | ||
| run: echo "No new request documents to POST." | ||
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.