Skip to content

Commit

Permalink
fix: fix the CI make-generate to use an image with the cartesi machine
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura authored and renan061 committed Aug 30, 2024
1 parent ec9e7dc commit 0a74856
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 48 deletions.
118 changes: 70 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,51 @@ permissions:
contents: write

jobs:
build-ci-base:
runs-on: ubuntu-22.04
outputs:
output: ${{ steps.export_tag.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
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
push: true
project: ${{ vars.DEPOT_PROJECT }}
workdir: build

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

do-basic-checks:
runs-on: ubuntu-22.04
steps:
Expand All @@ -40,16 +85,38 @@ jobs:
path: ./
config: .github/license-check/config.json

- name: Check auto generated files
run: make check-generate

- name: Lint Markdown docs
uses: DavidAnson/markdownlint-cli2-action@v16
with:
globs: |
*.md
docs/*.md
check-generated-files:
runs-on: ubuntu-22.04
container:
image: ghcr.io/cartesi/rollups-node-ci:${{needs.build-ci-base.outputs.output}}
needs:
- build-ci-base
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Fix VCS Issue
run : git config --global --add safe.directory /__w/rollups-node/rollups-node

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Check auto generated files
run: make check-generate


test-rust:
runs-on: ubuntu-22.04
env:
Expand Down Expand Up @@ -126,51 +193,6 @@ jobs:
- name: Run tests
run: cargo test

build-ci-base:
runs-on: ubuntu-22.04
outputs:
output: ${{ steps.export_tag.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
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
push: true
project: ${{ vars.DEPOT_PROJECT }}
workdir: build

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

test-go:
runs-on: ubuntu-22.04
container:
Expand Down
36 changes: 36 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,42 @@ ARG GO_BUILD_PATH
ARG ROLLUPS_NODE_VERSION
WORKDIR ${GO_BUILD_PATH}

ARG MACHINE_EMULATOR_VERSION
ARG DEBIAN_FRONTEND=noninteractive

# Install ca-certificates and curl (setup).
RUN <<EOF
set -e
apt-get update
apt-get install -y --no-install-recommends ca-certificates curl
EOF

# Install the cartesi-machine (cartesi/machine-emulator).
RUN <<EOF
set -e
URL=https://github.com/cartesi/machine-emulator/releases/download
VERSION=v${MACHINE_EMULATOR_VERSION}
ARCH=$(dpkg --print-architecture)
ARTIFACT=cartesi-machine-${VERSION}_${ARCH}.deb
curl -fsSL ${URL}/${VERSION}/${ARTIFACT} -o ./cartesi-machine.deb
apt-get install -y ./cartesi-machine.deb
rm ./cartesi-machine.deb
EOF

# Configure cartesi user and cartesi group.
RUN <<EOF
set -e
addgroup --system --gid 102 cartesi
adduser --system --uid 102 \
--disabled-login \
--gecos "cartesi user" \
--home /nonexistent \
--ingroup cartesi \
--no-create-home \
--shell /bin/false \
cartesi
EOF

# Download external dependencies.
COPY go.mod .
COPY go.sum .
Expand Down

0 comments on commit 0a74856

Please sign in to comment.