Repository navigation
feat(monday_trade): add MondayStockRouter contract address #157
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: Verify PR Contracts | |
| on: | |
| pull_request: | |
| branches: [main, master] | |
| paths: | |
| - "mainnet/**.json" | |
| - "mainnet/**.jsonc" | |
| jobs: | |
| verify-contracts: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # Fetch all history to compare with base branch | |
| - name: Get changed files | |
| id: changed-files | |
| run: | | |
| # Get the base and head commits | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
| # Get all changed files in mainnet folder (json and jsonc) | |
| CHANGED_FILES=$(git diff --name-only --diff-filter=AM "$BASE_SHA" "$HEAD_SHA" | grep -E '^mainnet/.*\.(json|jsonc)$' || true) | |
| if [ -z "$CHANGED_FILES" ]; then | |
| echo "No JSON/JSONC files changed in mainnet folder" | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "Changed files:" | |
| echo "$CHANGED_FILES" | |
| # Save changed files for later use | |
| echo "$CHANGED_FILES" > changed_files.txt | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| - name: Set up Python | |
| if: steps.changed-files.outputs.has_changes == 'true' | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: Install uv | |
| if: steps.changed-files.outputs.has_changes == 'true' | |
| uses: astral-sh/setup-uv@v8.1.0 | |
| with: | |
| enable-cache: true | |
| - name: Install dependencies | |
| if: steps.changed-files.outputs.has_changes == 'true' | |
| run: uv sync | |
| - name: Verify contracts | |
| if: steps.changed-files.outputs.has_changes == 'true' | |
| id: verify | |
| env: | |
| BLOCKVISION_API_KEY: ${{ secrets.BLOCKVISION_API_KEY }} | |
| run: | | |
| # Read changed files and run verification | |
| FILES=$(cat changed_files.txt | tr '\n' ' ') | |
| echo "Running verification on: $FILES" | |
| # Run the verification script and capture output | |
| set +e # Don't exit on error | |
| source .venv/bin/activate | |
| OUTPUT=$(python scripts/check_verified_contracts.py $FILES 2>&1) | |
| EXIT_CODE=$? | |
| set -e | |
| # Save output to file for comment | |
| echo "$OUTPUT" > verification_output.txt | |
| echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT | |
| # Print output for workflow logs | |
| echo "$OUTPUT" | |
| exit 0 | |
| - name: Post verification results as comment | |
| if: steps.changed-files.outputs.has_changes == 'true' && always() | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const output = fs.readFileSync('verification_output.txt', 'utf8'); | |
| const exitCode = '${{ steps.verify.outputs.exit_code }}'; | |
| const changedFiles = fs.readFileSync('changed_files.txt', 'utf8').trim().split('\n'); | |
| const filesList = changedFiles.map(f => `- \`${f}\``).join('\n'); | |
| const comment = `## Contract Verification Results | |
| ### Changed Files | |
| ${filesList} | |
| ### Verification Output | |
| \`\`\` | |
| ${output} | |
| \`\`\` | |
| --- | |
| <sub>Workflow run: [${context.workflow}](${context.payload.repository.html_url}/actions/runs/${context.runId})</sub> | |
| `; | |
| // Always surface the results in the job step summary so they're | |
| // visible on the Actions run page even when we can't post a PR | |
| // comment. Pull requests from forks run with a read-only | |
| // GITHUB_TOKEN (and without repo secrets), so createComment 403s. | |
| await core.summary.addRaw(comment).write(); | |
| // Posting the PR comment is best-effort: don't fail the job if the | |
| // token isn't allowed to write (e.g. fork PRs). Warn instead. | |
| try { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: comment | |
| }); | |
| } catch (error) { | |
| core.warning( | |
| `Could not post the results as a PR comment ` + | |
| `(${error.status ?? 'unknown'}: ${error.message}). ` + | |
| `This is expected for pull requests from forks, which run with a ` + | |
| `read-only token — see the job summary above for the results.` | |
| ); | |
| } |