diff --git a/.github/workflows/solidity.yml b/.github/workflows/solidity.yml index 611129366..3dfd06d9e 100644 --- a/.github/workflows/solidity.yml +++ b/.github/workflows/solidity.yml @@ -1,15 +1,19 @@ # TODO: Reusify and combine with the `check-lurk-compiles` action and/or make a reusable open-issue action -# This workflow runs Solidity compatibility tests on Arecibo PRs -# On a `pull_request` failure, it writes a PR comment to ensure the author/reviewer are notified -# On a `merge_group` failure, it opens an issue in `solidity-verifier` downstream that compatibility has been broken -# The workflow is not intended to be a required status check, only to noisily surface breaking changes. -# Thus, `merge_group` failures should only happen intentionally when breaking changes need to be merged in Arecibo +# +# This workflow runs autogenerated `solidity-verifier` compatibility tests on Arecibo PRs and notifies if compatibility is broken +# The workflow is intended to be a required status check only to make sure the Rust test & basic job steps work +# It is NOT intended to block breaking changes from merging, only to noisily surface them for review +# +# If the Rust template fails to generate the Solidity test or the job errors for another reason, the workflow fails immediately +# If the Solidity test fails on `pull_request`, it writes a PR comment to ensure the author/reviewer are notified +# If the Solidity test fails on `merge_group`, it opens an issue in `solidity-verifier` downstream that compatibility has been broken +# `merge_group` failures should only happen intentionally when breaking changes need to be merged in Arecibo # # Implementation note: # `falnyr/replace-env-vars-action`, `micalevisk/last-issue-action` and `peter-evans/create-issue-from-file` replace # equivalent functionality in `JasonEtco/create-an-issue`. We can't use the latter because it doesn't allow creating # the issue in another repo. See https://github.com/JasonEtco/create-an-issue/issues/40 -name: Test Solidity Compatibility +name: Test `solidity-verifier` compatibility on: merge_group: @@ -36,8 +40,70 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 - - run: cargo nextest run -E 'test(test_solidity_compatibility)' --release --run-ignored all + - name: Run Solidity test generator + run: | + cargo nextest run -E 'test(test_solidity_compatibility)' --release --run-ignored all --nocapture > test-output + working-directory: ${{ github.workspace }} + - name: Check out `solidity-verifier` for tests + uses: actions/checkout@v4 + with: + repository: lurk-lab/solidity-verifier + path: solidity-verifier + submodules: recursive + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: Prep Solidity test files + run: | + # Get test names from output + TEST_NAMES=$(grep 'test provider::*' test-output | awk -F'[_(.*?)\b...]' '{ print $(NF-3) }') + echo "$TEST_NAMES" + + # Print output of each test to `.t.sol` file + awk -v names="$TEST_NAMES" 'BEGIN { + file_counter = 0 + buffer = "" + # Convert test names to array + split(names, elements, " ") + for (i in elements) { + print "Element:", elements[i] + } + } + + /running 1 test/ { + between = 1 + buffer = "" + } + + between { + buffer = buffer $0 ORS + } + + /^test provider.*$/ { + between = 0 + + if (buffer != "") { + ++file_counter + print buffer > elements[file_counter]".t.sol" + buffer = "" + } + }' test-output + cat ipa.t.sol + + # Clean up + shopt -s nullglob + for file in *.t.sol; do + cat $file | sed '1d' | head -n -2 > tmp.file && mv tmp.file solidity-verifier/test/$file + echo "Formatted file:" + cat solidity-verifier/test/$file + done + shopt -u nullglob + working-directory: ${{ github.workspace }} + - name: Run Forge tests id: solidity-test + run: forge test -vvv + working-directory: ${{ github.workspace }}/solidity-verifier continue-on-error: true # Prepares env vars for use in a PR comment or issue in `solidity-verifier` - name: Set env vars @@ -57,7 +123,7 @@ jobs: echo "COMMIT_URL=$GITHUB_URL/commit/$COMMIT" | tee -a $GITHUB_ENV echo "PR_URL=$GITHUB_URL/pull/$PR_NUMBER" | tee -a $GITHUB_ENV echo "COMMIT=$COMMIT" | tee -a $GITHUB_ENV - # Comment failure on PR when test fails on `pull_request` + # Comment on PR when test fails on `pull_request` - name: Comment on failing run if: steps.solidity-test.outcome != 'success' && github.event_name == 'pull_request' uses: peter-evans/create-or-update-comment@v4 @@ -67,20 +133,6 @@ jobs: `solidity-verifier` compatibility test failed :x: ${{ env.WORKFLOW_URL }} - # Open issue in `solidity-verifier` downstream when test fails on `merge_group` - - uses: actions/checkout@v4 - if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued') - with: - repository: lurk-lab/solidity-verifier - # Have to check out Arecibo again to get the issue template - - uses: actions/checkout@v4 - if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued') - with: - repository: lurk-lab/arecibo - path: ${{ github.workspace }}/template - sparse-checkout: | - .github/SOLIDITY_COMPAT_ISSUE.md - sparse-checkout-cone-mode: false # Substitutes env vars for their values in `SOLIDITY_COMPAT_ISSUE.md` - uses: falnyr/replace-env-vars-action@master if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued') @@ -91,8 +143,8 @@ jobs: COMMIT_URL: ${{ env.COMMIT_URL }} PR_URL: ${{ env.PR_URL }} with: - filename: ./template/.github/SOLIDITY_COMPAT_ISSUE.md - # Finds the last open issue in `solidity-verifier` matching given labels + filename: .github/templates/SOLIDITY_COMPAT_ISSUE.md + # Finds the last open issue matching given labels - name: Find the last open compatibility issue id: last-issue if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued') @@ -105,7 +157,7 @@ jobs: compatibility debt automated issue - # Update existing issue in `solidity-verifier` downstream or create new one + # Update existing issue in `solidity-verifier` or create new one - uses: peter-evans/create-issue-from-file@v5 if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued') with: @@ -113,7 +165,7 @@ jobs: repository: lurk-lab/solidity-verifier issue-number: ${{ steps.last-issue.outputs.issue-number }} title: ":rotating_light: Arecibo compatibility is broken" - content-filepath: ./template/.github/SOLIDITY_COMPAT_ISSUE.md + content-filepath: .github/templates/SOLIDITY_COMPAT_ISSUE.md labels: | compatibility debt diff --git a/src/provider/tests/ipa_pc.rs b/src/provider/tests/ipa_pc.rs index 3c41dafb8..8ab105d1c 100644 --- a/src/provider/tests/ipa_pc.rs +++ b/src/provider/tests/ipa_pc.rs @@ -22,6 +22,7 @@ import \"src/blocks/grumpkin/Grumpkin.sol\"; import \"src/blocks/EqPolynomial.sol\"; import \"src/Utilities.sol\"; import \"src/blocks/IpaPcs.sol\"; +\"@std/Test.sol\";cs.sol\"; contract IpaTest is Test { function composeIpaInput() public pure returns (InnerProductArgument.IpaInputGrumpkin memory) {