Skip to content

Commit 7105187

Browse files
authored
CICD: implement tests in GitHub Actions (#1657)
1 parent f95b13b commit 7105187

File tree

4 files changed

+240
-2
lines changed

4 files changed

+240
-2
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ commands:
173173
command: make test
174174
no_output_timeout: 15m
175175
- run: make test-generate
176-
- run: make fakepackage
177176

178177
run_indexer_vs_algod:
179178
steps:

.github/workflows/ci-nightly.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: CI - Nightly Test Suite
2+
3+
on:
4+
schedule:
5+
- cron: "37 3 * * *" # Run at 3:37 AM UTC daily
6+
workflow_dispatch:
7+
8+
env:
9+
GO_VERSION: "1.23.3"
10+
CI_E2E_FILENAME: "rel-nightly"
11+
CHANNEL: nightly
12+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
13+
14+
jobs:
15+
test_nightly:
16+
runs-on: "ubuntu-24.04"
17+
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
18+
19+
services:
20+
postgres:
21+
image: postgres:13.11-bullseye
22+
env:
23+
POSTGRES_PASSWORD: pgpass
24+
POSTGRES_USER: pguser
25+
POSTGRES_DB: mydb
26+
ports:
27+
- 5555:5432
28+
options: >-
29+
--health-cmd pg_isready
30+
--health-interval 10s
31+
--health-timeout 5s
32+
--health-retries 5
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0 # Fetch full history
39+
- name: Set up Go
40+
uses: actions/setup-go@v4
41+
with:
42+
go-version: ${{ env.GO_VERSION }}
43+
- name: Set up Python
44+
uses: actions/setup-python@v4
45+
with:
46+
python-version: '3.x'
47+
- name: Install dependencies
48+
run: |
49+
sudo apt update
50+
sudo NEEDRESTART_MODE=a apt -y install python3 python3-pip python3-setuptools python3-wheel libboost-math-dev libffi-dev
51+
pip3 install -r misc/requirements.txt
52+
pip3 install e2e_tests/
53+
echo "$HOME/.local/bin" >> $GITHUB_PATH
54+
echo "/usr/local/go/bin" >> $GITHUB_PATH
55+
- name: Install golangci-lint
56+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0
57+
- name: Check formatting
58+
run: test -z "$(go fmt ./...)"
59+
- name: Run linter
60+
run: make lint
61+
- name: Run build check
62+
run: make check
63+
- name: Set up test environment
64+
run: |
65+
echo 'TEST_PG=host=localhost user=pguser password=pgpass dbname=mydb port=5555 sslmode=disable' >> $GITHUB_ENV
66+
echo 'TEST_FLAG=-p 1' >> $GITHUB_ENV
67+
- name: Run tests
68+
run: make test
69+
timeout-minutes: 15
70+
- name: Run test-generate
71+
run: make test-generate
72+
- name: Install go-algorand ${{ env.CHANNEL }} binaries
73+
run: |
74+
wget https://raw.githubusercontent.com/algorand/go-algorand/rel/stable/cmd/updater/update.sh && chmod 744 update.sh
75+
./update.sh -i -c ${{ env.CHANNEL }} -n -d ./ -p /usr/local/go/bin
76+
export GOPATH=/usr/local/go/
77+
- name: Run e2e tests (nightly)
78+
run: |
79+
make e2e
80+
make e2e-filter-test
81+
- name: Upload coverage to Codecov
82+
uses: codecov/codecov-action@v3
83+
with:
84+
file: ./coverage.txt
85+
flags: nightly
86+
name: codecov-nightly
87+
- name: Notify Slack on failure
88+
if: failure() && env.SLACK_WEBHOOK != ''
89+
uses: slackapi/slack-github-action@v2.1.0
90+
with:
91+
webhook: ${{ secrets.SLACK_WEBHOOK }}
92+
webhook-type: webhook-trigger
93+
payload: |
94+
{
95+
"text": "🚨 Indexer Failure Alert",
96+
"blocks": [
97+
{
98+
"type": "section",
99+
"text": {
100+
"type": "mrkdwn",
101+
"text": "test_nightly Job Failure:\n* Branch: `${{ github.ref_name }}`\n* Run URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
102+
}
103+
}
104+
]
105+
}
106+
107+
indexer_vs_algod_nightly:
108+
runs-on: "ubuntu-24.04"
109+
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
110+
111+
steps:
112+
- name: Checkout code
113+
uses: actions/checkout@v4
114+
with:
115+
submodules: recursive
116+
fetch-depth: 0 # Fetch full history
117+
- name: Set up Go
118+
uses: actions/setup-go@v4
119+
with:
120+
go-version: ${{ env.GO_VERSION }}
121+
- name: Set up Python
122+
uses: actions/setup-python@v4
123+
with:
124+
python-version: '3.x'
125+
- name: Install dependencies
126+
run: |
127+
sudo apt update
128+
sudo NEEDRESTART_MODE=a apt -y install python3 python3-pip python3-setuptools python3-wheel libboost-math-dev libffi-dev docker-compose
129+
pip3 install -r misc/requirements.txt
130+
pip3 install e2e_tests/
131+
echo "$HOME/.local/bin" >> $GITHUB_PATH
132+
echo "/usr/local/go/bin" >> $GITHUB_PATH
133+
- name: Run indexer vs algod tests
134+
run: make indexer-v-algod
135+
- name: Notify Slack on failure
136+
if: failure() && env.SLACK_WEBHOOK != ''
137+
uses: slackapi/slack-github-action@v2.1.0
138+
with:
139+
webhook: ${{ secrets.SLACK_WEBHOOK }}
140+
webhook-type: webhook-trigger
141+
payload: |
142+
{
143+
"text": "🚨 Indexer Failure Alert",
144+
"blocks": [
145+
{
146+
"type": "section",
147+
"text": {
148+
"type": "mrkdwn",
149+
"text": "indexer_vs_algod_nightly Job Failure:\n* Branch: `${{ github.ref_name }}`\n* Run URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
150+
}
151+
}
152+
]
153+
}

.github/workflows/ci-pr.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: CI - Test Suite
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
GO_VERSION: "1.23.3"
11+
# A stable environment for PRs.
12+
# Set CHANNEL to nightly and update CI_E2E_FILENAME when adding a new feature.
13+
# Change back to stable once the new feature is released.
14+
CI_E2E_FILENAME: "rel-nightly"
15+
CHANNEL: nightly
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-24.04
20+
21+
services:
22+
postgres:
23+
image: postgres:13.11-bullseye
24+
env:
25+
POSTGRES_PASSWORD: pgpass
26+
POSTGRES_USER: pguser
27+
POSTGRES_DB: mydb
28+
ports:
29+
- 5555:5432
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0 # Fetch full history
41+
- name: Set up Go
42+
uses: actions/setup-go@v4
43+
with:
44+
go-version: ${{ env.GO_VERSION }}
45+
- name: Set up Python
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: '3.x'
49+
- name: Install dependencies
50+
run: |
51+
sudo apt-get update
52+
sudo NEEDRESTART_MODE=a apt-get -y install python3 python3-pip python3-setuptools python3-wheel libboost-math-dev libffi-dev docker-compose
53+
pip3 install -r misc/requirements.txt
54+
pip3 install e2e_tests/
55+
- name: Install golangci-lint
56+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0
57+
- name: Check formatting
58+
run: test -z "$(go fmt ./...)"
59+
- name: Run linter
60+
run: make lint
61+
- name: Run build check
62+
run: make check
63+
- name: Set up test environment
64+
run: |
65+
echo 'TEST_PG=host=localhost user=pguser password=pgpass dbname=mydb port=5555 sslmode=disable' >> $GITHUB_ENV
66+
echo 'TEST_FLAG=-p 1' >> $GITHUB_ENV
67+
- name: Run tests
68+
run: make test
69+
timeout-minutes: 15
70+
- name: Run test-generate
71+
run: make test-generate
72+
- name: Install go-algorand ${{ env.CHANNEL }} binaries
73+
run: |
74+
wget https://raw.githubusercontent.com/algorand/go-algorand/rel/stable/cmd/updater/update.sh && chmod 744 update.sh
75+
./update.sh -i -c ${{ env.CHANNEL }} -n -d ./ -p /usr/local/go/bin
76+
export GOPATH=/usr/local/go/
77+
- name: Run e2e tests
78+
run: |
79+
make e2e
80+
make e2e-filter-test
81+
- name: Upload coverage to Codecov
82+
uses: codecov/codecov-action@v3
83+
with:
84+
file: ./coverage.txt
85+
flags: unittests
86+
name: codecov-umbrella

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ test-generate:
6161
indexer-v-algod:
6262
pytest -sv misc/parity
6363

64-
.PHONY: all test e2e integration fmt lint deploy sign test-package package fakepackage cmd/algorand-indexer/algorand-indexer idb/mocks/IndexerDb.go indexer-v-algod
64+
.PHONY: all test e2e integration fmt lint deploy sign test-package package cmd/algorand-indexer/algorand-indexer idb/mocks/IndexerDb.go indexer-v-algod

0 commit comments

Comments
 (0)