Skip to content

Commit

Permalink
feat: Add end to end tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Apr 30, 2024
1 parent 5b2ad2b commit e774c0e
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,58 @@ jobs:
- name: Run tests
run: cargo test

build-ci-base :
runs-on: ubuntu-22.04
outputs:
output: ${{ steps.docker_build.outputs.image_tag }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
name=ghcr.io/cartesi/rollups-node-ci-base
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: depot/setup-action@v1
- name: Build and push docker image
id: docker_build
uses: depot/bake-action@v1
with:
files: |
./docker-bake.hcl
${{ steps.docker_meta.outputs.bake-file }}
./docker-bake.platforms.hcl
targets: rollups-node-ci-base
push: true
project: ${{ vars.DEPOT_PROJECT }}
workdir: build

- name: Export Image Tag
id : export_tag
run : echo "image_tag=${{steps.docker_meta.outputs.tag}}" >> "$GITHUB_OUTPUT"


test-go:
runs-on: ubuntu-22.04
container:
image: ghcr.io/cartesi/rollups-node-ci-base:${{needs.build-ci-base.outputs.output}}
needs:
- build-ci-base
steps:
- uses: actions/checkout@v4
with:
Expand Down
62 changes: 62 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,65 @@ USER cartesi

# Set the Go supervisor as the command.
CMD [ "cartesi-rollups-node" ]



# STAGE: rollups-ci-base
#
# This stage prepares the base CI image
FROM rust:${RUST_VERSION}-bookworm as rollups-node-ci-base

ARG RUST_VERSION
ARG GO_VERSION
ARG MACHINE_EMULATOR_VERSION

# Install git
RUN apt update && apt install -y git-all

# Install docker
RUN <<EOF
apt update && apt install -y --no-install-recommends ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
EOF


# Install Protoc
RUN su - && apt update && apt install -y protobuf-compiler libprotobuf-dev

# Install Cartesi Machine
RUN <<EOF
ARCH=$(dpkg --print-architecture)
curl -fsSLv https://github.com/cartesi/machine-emulator/releases/download/v${MACHINE_EMULATOR_VERSION}/cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${ARCH}.deb -o ./cartesi-machine.deb
apt-get install -y ./cartesi-machine.deb
EOF

# Set Cargo Sweep
RUN cargo install cargo-sweep
RUN cargo sweep -s

# Install Golang
RUN <<EOF
ARCH=$(dpkg --print-architecture)
curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -o ./golang.tar.gz
tar -C /usr/local -xzf golang.tar.gz
export PATH=$PATH:/usr/local/go/bin
EOF

# Install Rust Code Dependencies
RUN <<EOF
apt update
apt install -y --no-install-recommends \
redis \
redis-tools \
libboost-coroutine1.81.0 \
libboost-context1.81.0 \
libboost-filesystem1.81.0 \
libboost-log1.81.0 \
libcrypto++8 \
procps
EOF
7 changes: 7 additions & 0 deletions build/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ target "rollups-node-devnet" {
inherits = ["common"]
target = "rollups-node-devnet"
}

target "rollups-node-ci-base" {
inherits = ["common"]
target = "rollups-node-ci-base"
dockerfile = "./Dockerfile"
context = "."
}
4 changes: 4 additions & 0 deletions build/docker-bake.override.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ target "rollups-node-snapshot" {
target "rollups-node-devnet" {
tags = ["${DOCKER_ORGANIZATION}/rollups-node-devnet:${TAG}"]
}

target "rollups-node-ci-base" {
tags = ["${DOCKER_ORGANIZATION}/rollups-node-ci-base:${TAG}"]
}

0 comments on commit e774c0e

Please sign in to comment.