Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/fetch_ingest_proofs.yml
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 }}
Comment thread
semmet95 marked this conversation as resolved.
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'
Comment thread
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
5 changes: 2 additions & 3 deletions .github/workflows/post_on_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ jobs:
- name: Get added files in latest commit
id: added
run: |
files=$(git diff --diff-filter=A HEAD~1 HEAD --name-only | grep -E '^(sources|claims|proofs)/' || true)
files=$(git diff --diff-filter=A HEAD~1 HEAD --name-only | grep -E '^(sources|claims)/' || true)
echo "Added files:"
echo "$files"
# Order: sources, claims, proofs
# Order: sources, claims
ordered_files=$(echo "$files" | grep '^sources/' || true)
ordered_files+=$'\n'$(echo "$files" | grep '^claims/' || true)
ordered_files+=$'\n'$(echo "$files" | grep '^proofs/' || true)
# Trim only leading/trailing whitespace, preserve internal spaces in filenames
ordered_files=$(echo "$ordered_files" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
echo "ADDED_FILES<<EOF" >> "$GITHUB_ENV"
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/post_proofs_on_merge.yml
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:
Comment thread
semmet95 marked this conversation as resolved.
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v6
with:
python-version: '3.12'
Comment thread
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)
Comment thread
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."
2 changes: 1 addition & 1 deletion .github/workflows/refresh_scores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Verify Claims and Source Scores

on:
workflow_run:
workflows: ["POST New Documents on Merge"]
workflows: ["POST New Proof Documents on Merge"]
Comment thread
semmet95 marked this conversation as resolved.
types:
- completed

Expand Down
File renamed without changes.
Loading