Skip to content

Commit f61cd1e

Browse files
andrew/chore/add smoke tests (#1202)
* add smoke tests * remove unused steps * run on pull request & select proper branch * fix loading artifact
1 parent fc94d25 commit f61cd1e

3 files changed

Lines changed: 156 additions & 0 deletions

File tree

.github/workflows/on-master-commit.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ jobs:
3030
name: E2E Tests
3131
uses: ./.github/workflows/test-e2e.yaml
3232

33+
run-smoke-tests:
34+
name: Smoke Tests
35+
uses: ./.github/workflows/test-smoke.yaml
36+
permissions:
37+
contents: read
38+
secrets: inherit
39+
needs: [run-e2e-tests]
40+
3341
run-rosetta-tests:
3442
name: Rosetta Tests
3543
uses: ./.github/workflows/test-rosetta.yaml

.github/workflows/on-pull-request.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ jobs:
3030
name: E2E Tests
3131
uses: ./.github/workflows/test-e2e.yaml
3232

33+
run-smoke-tests:
34+
name: Smoke Tests
35+
uses: ./.github/workflows/test-smoke.yaml
36+
permissions:
37+
contents: read
38+
secrets: inherit
39+
needs: [run-e2e-tests]
40+
3341
run-rosetta-tests:
3442
name: Rosetta Tests
3543
uses: ./.github/workflows/test-rosetta.yaml

.github/workflows/test-smoke.yaml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Smoke Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
draupnir-branch:
7+
type: string
8+
default: 'main'
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build-docker-image:
15+
name: Build Docker image
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Try to download e2e artifact
22+
id: download-artifact
23+
continue-on-error: true
24+
uses: actions/download-artifact@v4
25+
with:
26+
name: vechain-thor-image-${{ github.sha }}
27+
path: /tmp
28+
29+
- name: Set up QEMU
30+
if: steps.download-artifact.outcome == 'failure'
31+
uses: docker/setup-qemu-action@v3
32+
33+
- name: Set up Docker Buildx
34+
if: steps.download-artifact.outcome == 'failure'
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Build and export
38+
if: steps.download-artifact.outcome == 'failure'
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
tags: vechain/thor:${{ github.sha }}
43+
outputs: type=docker,dest=/tmp/vechain-thor.tar
44+
45+
- name: Upload artifact
46+
if: steps.download-artifact.outcome == 'failure'
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: vechain-thor-image-${{ github.sha }}
50+
path: /tmp/vechain-thor.tar
51+
retention-days: 7
52+
53+
run-smoke-tests:
54+
runs-on: ubuntu-latest
55+
needs: build-docker-image
56+
env:
57+
THOR_IMAGE: vechain/thor:${{ github.sha }}
58+
name: Run Smoke Tests
59+
steps:
60+
- name: Set up git credentials
61+
run: |
62+
git config --global url."https://${{ secrets.DRAUPNIR_TOKEN }}@github.com/".insteadOf "https://github.com/"
63+
64+
- name: Set draupnir repo reference
65+
id: set-ref
66+
run: |
67+
# Default fallback commit
68+
DEFAULT_COMMIT="87786521c01be03d7a39cedb3b34d640f9f8632e"
69+
REF="$DEFAULT_COMMIT"
70+
71+
if [ "${{ github.event_name }}" = "pull_request" ]; then
72+
# For pull_request events, we only look at the PR's base branch
73+
if [[ "${{ github.event.pull_request.base.ref }}" == release/* ]]; then
74+
REF="${{ github.event.pull_request.base.ref }}"
75+
fi
76+
else
77+
# For push events, we check the branch or tag that was pushed
78+
if [[ "${{ github.ref_name }}" == release/* ]]; then
79+
REF="${{ github.ref_name }}"
80+
fi
81+
fi
82+
83+
# Verify if branch exists
84+
if ! git ls-remote --heads https://github.com/vechain/draupnir.git $REF; then
85+
echo "Branch does not exist, using default commit"
86+
echo "ref=$DEFAULT_COMMIT" >> "$GITHUB_OUTPUT"
87+
else
88+
echo "ref=$REF" >> "$GITHUB_OUTPUT"
89+
fi
90+
91+
echo "DRAUPNIR REF: $(<$GITHUB_OUTPUT)"
92+
93+
- name: Checkout
94+
uses: actions/checkout@v4
95+
with:
96+
repository: vechain/draupnir
97+
token: ${{ secrets.DRAUPNIR_TOKEN }}
98+
ref: ${{ steps.set-ref.outputs.ref }}
99+
100+
- name: Download artifact
101+
uses: actions/download-artifact@v4
102+
with:
103+
name: vechain-thor-image-${{ github.sha }}
104+
path: /tmp
105+
106+
- name: Load image
107+
run: |
108+
docker load --input /tmp/vechain-thor.tar
109+
docker image ls -a
110+
111+
- name: Setup Go
112+
uses: actions/setup-go@v5
113+
with:
114+
go-version: '1.24.x'
115+
116+
- name: Start Thor Node
117+
run: |
118+
docker run -d --name thor-node \
119+
--network host \
120+
-p 8669:8669 \
121+
vechain/thor:${{ github.sha }} \
122+
solo --gas-limit=40000000 --api-cors="*" --enable-metrics
123+
124+
- name: Wait for Thor to be ready
125+
run: |
126+
timeout 60 bash -c 'until curl -s http://localhost:8669/accounts; do sleep 2; done'
127+
128+
129+
- name: Run Smoke Test Separately
130+
run: |
131+
RUNTESTS=TestSmokeTest,TestGenerateRequests,TestConnectionDiesNoPingResponse,TestConnectionClosedWithoutSubscription \
132+
TEST_NETWORK_ADDR=http://127.0.0.1:8669 \
133+
TEST_PK=99f0500549792796c14fed62011a51081dc5b5e68fe8bd8a13b86be829c4fd36 \
134+
go test --count=1 -v ./tests/smoketest -run TestSmokeTest
135+
136+
- name: Cleanup
137+
if: always()
138+
run: |
139+
docker stop thor-node || true
140+
docker rm thor-node || true

0 commit comments

Comments
 (0)