-
Notifications
You must be signed in to change notification settings - Fork 10
118 lines (99 loc) · 4.57 KB
/
end2end.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Run integration tests when a maintainer comments `!test` on a PR to feature branch
#
# Default env vars specified in `rust-reference-info.env`
# Overrides default env vars when input to `!test` comment, e.g.
# `!test NOVA_URL=https://github.com/lurk-lab/Nova NOVA_COMMIT=ea4f75c225cb29f523780858ec84f1ff51c229bc NOVA_TEST_NAME=solidity_compatibility_e2e_pasta`
#
# Fails when base branch is `main`, as it doesn't support e2e tests
name: End to end integration tests
on:
issue_comment:
types: [created]
env:
ANVIL_PRIVATE_KEY: ${{secrets.ANVIL_PRIVATE_KEY}}
ANVIL_URL: ${{secrets.ANVIL_RPC_URL}}
jobs:
integration-tests-e2e:
name: E2E verification
runs-on: buildjet-16vcpu-ubuntu-2204
if:
github.event.issue.pull_request
&& github.event.issue.state == 'open'
&& contains(github.event.comment.body, '!test')
&& (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
steps:
- uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- name: Exit if base branch is `main`
if: ${{ steps.comment-branch.outputs.base_ref == 'main' }}
run: |
echo "Cannot run end2end integration tests on PR targeting `main`"
exit 1
continue-on-error: false
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout PR branch
run: gh pr checkout $PR_NUMBER
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Load env defaults
uses: cardinalby/export-env-action@v2
with:
envFile: 'rust-reference-info.env'
- name: Set env from comment body
run: |
BODY=$(printf '${{ github.event.comment.body }}')
NOVA_URL=$(echo $BODY | awk -F'[ =]' '{for (i=1; i<=NF; i++) {if ($i ~ /^NOVA_URL/) {print $(i+1) }}}')
if [[ ! -z $NOVA_URL ]]; then
echo "NOVA_URL=$NOVA_URL" | tee -a $GITHUB_ENV
fi
NOVA_COMMIT=$(echo $BODY | awk -F'[ =]' '{for (i=1; i<=NF; i++) {if ($i ~ /^NOVA_COMMIT/) {print $(i+1) }}}')
if [[ ! -z $NOVA_COMMIT ]]; then
echo "NOVA_COMMIT=$NOVA_COMMIT" | tee -a $GITHUB_ENV
fi
NOVA_TEST_NAME=$(echo $BODY | awk -F'[ =]' '{for (i=1; i<=NF; i++) {if ($i ~ /^NOVA_TEST_NAME/) {print $(i+1) }}}')
if [[ ! -z $NOVA_TEST_NAME ]]; then
echo "NOVA_TEST_NAME=$NOVA_TEST_NAME" | tee -a $GITHUB_ENV
fi
- name: Generate proof and public parameters from commit hash
run: |
python generate_contract_input.py ${{ env.NOVA_URL }} ${{ env.NOVA_COMMIT }} ${{ env.NOVA_TEST_NAME }}
- name: Deploy main contract
run: |
echo "CONTRACT_ADDRESS=$(forge script script/Deployment.s.sol:NovaVerifierDeployer --fork-url $ANVIL_URL --private-key $ANVIL_PRIVATE_KEY --broadcast --non-interactive | sed -n 's/.*Contract Address: //p' | tail -1)" >> $GITHUB_OUTPUT
id: deployment
- name: Load proof and public parameters
run: |
python loader.py vk.json compressed-snark.json ${{steps.deployment.outputs.CONTRACT_ADDRESS}} $ANVIL_URL $ANVIL_PRIVATE_KEY
- name: Check proof verification status
run: |
[[ $(cast call ${{steps.deployment.outputs.CONTRACT_ADDRESS}} "verify(uint32,uint256[],uint256[],bool)(bool)" "3" "[1]" "[0]" "true" --private-key $ANVIL_PRIVATE_KEY --rpc-url $ANVIL_URL) == true ]] && exit 0 || exit 1
- name: Gather status in a single variable
if: steps.tests.outcome == 'success' && steps.gadget-tests.outcome == 'success'
run: echo "status=true" | tee -a $GITHUB_ENV
- name: Comment on successful run
if: success()
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body: |
End-to-end `!test` action succeeded! :rocket:
https://github.com/lurk-lab/solidity-verifier/actions/runs/${{ github.run_id }}
- name: Comment on failing run
if: failure()
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body: |
End-to-end `!test` action failed :x:
https://github.com/lurk-lab/solidity-verifier/actions/runs/${{ github.run_id }}