Skip to content

Commit aeb28ca

Browse files
authored
feat: add scheduled e2e tests (#69)
1 parent 5adb4c6 commit aeb28ca

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: ci-run-scheduled-e2e
2+
3+
on:
4+
schedule:
5+
# Every Monday at 09:00 UTC to catch regressions.
6+
- cron: '0 9 * * 1'
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: scheduled-e2e-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
e2e-tests:
15+
name: scheduled-e2e-tests 🔚2️⃣🔚
16+
permissions:
17+
contents: read
18+
issues: write
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 45
21+
steps:
22+
- name: Checkout repo
23+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
24+
25+
- name: Setup Bun
26+
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.0.2
27+
with:
28+
bun-version: '1.3.5'
29+
30+
- name: Install deps
31+
run: bun install --frozen-lockfile
32+
33+
- name: Install Foundry (anvil)
34+
uses: foundry-rs/foundry-toolchain@8b0419c685ef46cb79ec93fbdc131174afceb730 # v1.6.0
35+
with:
36+
version: v1.5.1
37+
38+
- name: Run ZKsync OS (L1-L2)
39+
uses: dutterbutter/zksync-server-action@54ebddef27a0bd7ef30246f94add1c9091ae23be # v0.2.0
40+
with:
41+
version: v0.15.1
42+
protocol_version: v30.2
43+
44+
- name: Compile test contracts
45+
id: compile_contracts
46+
working-directory: tests/contracts
47+
run: |
48+
set -o pipefail
49+
forge build 2>&1 | tee "$RUNNER_TEMP/forge-build.log"
50+
51+
- name: Run ethers e2e
52+
id: ethers_e2e
53+
continue-on-error: true
54+
run: |
55+
set -o pipefail
56+
bun run test:e2e:ethers 2>&1 | tee "$RUNNER_TEMP/ethers-e2e.log"
57+
58+
- name: Run viem e2e
59+
id: viem_e2e
60+
continue-on-error: true
61+
run: |
62+
set -o pipefail
63+
bun run test:e2e:viem 2>&1 | tee "$RUNNER_TEMP/viem-e2e.log"
64+
65+
- name: Fail workflow if any e2e suite failed
66+
if: ${{ always() && steps.compile_contracts.outcome == 'success' }}
67+
run: |
68+
if [ "${{ steps.ethers_e2e.outcome }}" != "success" ] || [ "${{ steps.viem_e2e.outcome }}" != "success" ]; then
69+
echo "One or more e2e suites failed."
70+
exit 1
71+
fi
72+
73+
- name: Open or update failure issue
74+
if: ${{ failure() && github.ref_name == 'main' }}
75+
env:
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
GH_REPO: ${{ github.repository }}
78+
ISSUE_TITLE: Scheduled e2e workflow failing on main
79+
RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
80+
run: |
81+
issue_file="$RUNNER_TEMP/scheduled-e2e-issue.md"
82+
83+
append_log_section() {
84+
local title="$1"
85+
local file="$2"
86+
{
87+
echo "### ${title}"
88+
echo
89+
echo '```text'
90+
if [ -f "$file" ]; then
91+
tail -n 80 "$file"
92+
else
93+
echo "No log file was captured for this step."
94+
fi
95+
echo '```'
96+
echo
97+
} >> "$issue_file"
98+
}
99+
100+
{
101+
echo "## Scheduled e2e workflow failure"
102+
echo
103+
echo "- Workflow: \`${{ github.workflow }}\`"
104+
echo "- Branch: \`${{ github.ref_name }}\`"
105+
echo "- Commit: \`${{ github.sha }}\`"
106+
echo "- Trigger: \`${{ github.event_name }}\`"
107+
echo "- Run: [${{ github.run_id }}](${RUN_URL})"
108+
echo "- Attempt: \`${{ github.run_attempt }}\`"
109+
echo "- Failed at: \`$(date -u +"%Y-%m-%d %H:%M:%S UTC")\`"
110+
echo
111+
echo "## Step results"
112+
echo
113+
echo "| Step | Outcome |"
114+
echo "| --- | --- |"
115+
echo "| Compile test contracts | ${{ steps.compile_contracts.outcome }} |"
116+
echo "| Run ethers e2e | ${{ steps.ethers_e2e.outcome || 'skipped' }} |"
117+
echo "| Run viem e2e | ${{ steps.viem_e2e.outcome || 'skipped' }} |"
118+
echo
119+
echo "<details>"
120+
echo "<summary>Log excerpts</summary>"
121+
echo
122+
} > "$issue_file"
123+
124+
append_log_section "Compile test contracts" "$RUNNER_TEMP/forge-build.log"
125+
append_log_section "Run ethers e2e" "$RUNNER_TEMP/ethers-e2e.log"
126+
append_log_section "Run viem e2e" "$RUNNER_TEMP/viem-e2e.log"
127+
128+
echo "</details>" >> "$issue_file"
129+
130+
existing_issue_number="$(gh issue list --state open --search "\"${ISSUE_TITLE}\" in:title" --limit 1 --json number --jq '.[0].number // empty')"
131+
132+
if [ -n "$existing_issue_number" ]; then
133+
gh issue comment "$existing_issue_number" --body-file "$issue_file"
134+
else
135+
gh issue create --title "$ISSUE_TITLE" --body-file "$issue_file"
136+
fi

0 commit comments

Comments
 (0)