Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup integration tests environment #58

Merged
merged 11 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
run: |
cd ./listener
go build -a -installsuffix cgo -o bin/listener ./cmd/listener

- name: Setup Integration Test Environment
run: |
docker compose -f docker-compose-ci.yml up --build -d
- name: Test
run: |
cd ./listener
Expand Down
11 changes: 11 additions & 0 deletions ci.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MONGO_INITDB_ROOT_USERNAME=dappnode
MONGO_INITDB_ROOT_PASSWORD=dappnode
MONGO_DB_API_PORT=27017
API_PORT=8080
LOG_LEVEL=DEBUG
MAX_ENTRIES_PER_BSON=30
BEACON_NODE_URL_MAINNET=http://172.33.0.27:3500
BEACON_NODE_URL_HOLESKY=http://172.33.0.27:3500
BEACON_NODE_URL_GNOSIS=http://172.33.0.27:3500
BEACON_NODE_URL_LUKSO=http://172.33.0.27:3500
JWT_USERS_FILE=users.json.example
39 changes: 39 additions & 0 deletions docker-compose-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.9"

networks:
listener-net-ci:
driver: bridge

volumes:
mongo_data_ci: {}

services:
listener:
build:
context: listener
dockerfile: Dockerfile
env_file:
- ci.env
environment:
MONGO_DB_URI: "mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongo:${MONGO_DB_API_PORT}"
depends_on:
- mongo
container_name: listener
restart: always
volumes:
- ./jwt:/app/jwt ## listener expects /app/jwt to exist, careful when changing this path
networks:
- listener-net-ci

mongo:
build:
context: mongo
volumes:
- mongo_data_ci:/data/db
env_file:
- ci.env
command: ["mongod", "--config", "/etc/mongo/mongod.conf"]
container_name: mongo
restart: always
networks:
- listener-net-ci
4 changes: 2 additions & 2 deletions listener/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Start from the latest golang base image
FROM golang:1.22.0-alpine3.19 as builder
FROM golang:1.22.3 as builder

# Set the Current Working Directory inside the container.
WORKDIR /app
Expand All @@ -14,7 +14,7 @@ COPY internal/ ./internal/
COPY cmd/ ./cmd/

# Build the application, outputting the executable to /bin directory.
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /bin/listener ./cmd/listener/main.go
RUN CGO_ENABLED=1 GOOS=linux go build -v -o /bin/listener ./cmd/listener/main.go

# Use a Docker multi-stage build to create a lean production image.
# # build-essential required by dependency github.com/herumi/bls-eth-go-binary
Expand Down
Loading