Repository navigation
CI: allow formal verification to run on pull requests from forks #6699
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
Changes from 4 commits
1f3247e
e24df7d
7570c62
3b5ef12
b9978a8
8c8606b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| name: Formal verification - Certora | ||
|
|
||
| on: | ||
| # Runs in the context of the base repository so that the CERTORAKEY secret is available to pull | ||
| # requests opened from forks. Access is gated by the `certora` environment, which requires a | ||
| # manual approval from a reviewer before the job starts. Reviewers MUST check the diff for | ||
| # anything that could exfiltrate the key before approving. | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
| - labeled | ||
| workflow_dispatch: {} | ||
|
|
||
| # `github.ref` is the base branch under `pull_request_target`, so key on the pull request number | ||
| concurrency: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
|
|
||
| jobs: | ||
| verify: | ||
| runs-on: ubuntu-latest | ||
| environment: certora | ||
| if: github.event_name != 'pull_request_target' || contains(github.event.pull_request.labels.*.name, 'formal-verification') || contains(github.event.pull_request.labels.*.name, 'formal-verification-force-all') | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
Amxx marked this conversation as resolved.
Resolved
|
||
| with: | ||
| # `pull_request_target` checks out the base by default. This runs the contributor's code, | ||
| # which is why the environment approval above is required. | ||
| ref: ${{ github.event.pull_request.head.sha || github.ref }} | ||
| fetch-depth: 0 # Include history so the diff against the PR base resolves | ||
|
james-toussaint marked this conversation as resolved.
Resolved
|
||
| - name: Set up environment | ||
| uses: ./.github/actions/setup | ||
| with: | ||
| solc: 'on' | ||
| java: 'on' | ||
| python: 'on' | ||
| python-requirements: 'fv-requirements.txt' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be safer to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will cause issues if the user branch updates the dependencies. We would get the one from the base branch. For example: there is a new version of certora, and we want to make a PR that updates the We are going to manually approve everytime anyway.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes in that case we need to push anything related to the config to a branch on the base repo, which I think is compatible with what we want to achieve: "run fv tests on untrusted/external contributor code" |
||
| - name: identify specs that need to be run | ||
| id: arguments | ||
| env: | ||
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
| run: | | ||
| if [[ ${{ github.event_name }} = 'pull_request_target' && ${{ contains(github.event.pull_request.labels.*.name, 'formal-verification-force-all') }} = 'false' ]]; | ||
| then | ||
| # Spec names come from the file names of a pull request that may be untrusted, and end | ||
| # up on a command line downstream. Anything that is not a plain name is dropped here. | ||
| RESULT=$(git diff "$HEAD_SHA".."$BASE_SHA" --name-only -- 'fv/specs/*.spec' | while IFS= read -r file; do | ||
| [[ -f $file ]] || continue | ||
| name=$(basename "${file%.spec}") | ||
| [[ $name =~ ^[A-Za-z0-9_-]+$ ]] && echo "$name" || echo "Ignoring spec with unexpected name: $name" >&2 | ||
| done | tr "\n" " ") | ||
| else | ||
| RESULT='--all' | ||
| fi | ||
|
Amxx marked this conversation as resolved.
Resolved
|
||
| echo "result=$RESULT" >> "$GITHUB_OUTPUT" | ||
| - name: Verify specification | ||
| env: | ||
| SPEC_ARGUMENTS: ${{ steps.arguments.outputs.result }} | ||
| CERTORAKEY: ${{ secrets.CERTORAKEY }} | ||
| run: | | ||
| make -C fv apply | ||
| read -r -a specs <<< "$SPEC_ARGUMENTS" | ||
| node fv/run.js "${specs[@]}" -p 1 -v >> "$GITHUB_STEP_SUMMARY" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Formal verification - Halmos | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
| - labeled | ||
| workflow_dispatch: {} | ||
|
|
||
| concurrency: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
|
|
||
| jobs: | ||
| halmos: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - name: Set up environment | ||
| uses: ./.github/actions/setup | ||
| with: | ||
| foundry: 'on' | ||
| python: 'on' | ||
| python-requirements: 'fv-requirements.txt' | ||
| - name: Run Halmos | ||
| run: halmos --match-test '^symbolic|^testSymbolic' -vv | ||
| env: | ||
| HALMOS_ALLOW_DOWNLOAD: 1 |
Uh oh!
There was an error while loading. Please reload this page.