Skip to content

Commit

Permalink
fix(ci): Bump earthly version to 0.8 and use new rust builders from c…
Browse files Browse the repository at this point in the history
…at-ci
  • Loading branch information
stevenj committed May 9, 2024
1 parent 477788a commit d4f4334
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 43 deletions.
17 changes: 10 additions & 7 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
# Set the Earthly version to 0.7
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:fix/improve-rust-builder-sj AS mdlint-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:fix/improve-rust-builder-sj AS cspell-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:fix/improve-rust-builder-sj AS postgresql-ci

VERSION 0.7
FROM debian:stable-slim

# cspell: words livedocs sitedocs

# check-markdown markdown check using catalyst-ci.
check-markdown:
DO github.com/input-output-hk/catalyst-ci/earthly/mdlint:v2.11.1+CHECK
DO mdlint-ci+CHECK

# markdown-check-fix markdown check and fix using catalyst-ci.
markdown-check-fix:
LOCALLY

DO github.com/input-output-hk/catalyst-ci/earthly/mdlint:v2.11.1+MDLINT_LOCALLY --src=$(echo ${PWD}) --fix=--fix
DO mdlint-ci+MDLINT_LOCALLY --src=$(echo ${PWD}) --fix=--fix

# check-spelling Check spelling in this repo inside a container.
check-spelling:
DO github.com/input-output-hk/catalyst-ci/earthly/cspell:v2.11.1+CHECK
DO cspell-ci+CHECK

# check if the sql files are properly formatted and pass lint quality checks.
check-sqlfluff:
FROM github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.11.1+postgres-base
FROM postgresql-ci+postgres-base

COPY . .

DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.11.1+CHECK
DO postgresql-ci+CHECK

repo-docs:
# Create artifacts of extra files we embed inside the documentation when its built.
Expand Down
42 changes: 26 additions & 16 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
VERSION --try --global-cache 0.7
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:fix/improve-rust-builder-sj AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mithril_snapshot:fix/improve-rust-builder-sj AS mithril-snapshot-ci

#cspell: words rustfmt toolsets USERARCH

# Set up our target toolchains, and copy our files.
# builder : Set up our target toolchains, and copy our files.
builder:
DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.11.1+SETUP
DO rust-ci+SETUP

COPY --dir .cargo .config Cargo.* clippy.toml deny.toml rustfmt.toml bin crates .

Expand All @@ -14,39 +17,44 @@ builder:
##
## These targets are discovered and executed automatically by CI.

# Run check using the most efficient host tooling
# check : Run check using the most efficient host tooling
# CI Automated Entry point.
check:
FROM +builder

RUN /scripts/std_checks.py
DO rust-ci+EXECUTE --cmd="/scripts/std_checks.py"

# Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# all-hosts-check : Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# Only used to validate tooling is working across host toolsets.
all-hosts-check:
BUILD --platform=linux/amd64 --platform=linux/arm64 +check

# build : Build the catalyst-gateway service
build:
# Build the service
FROM +builder

TRY
RUN /scripts/std_build.py \
--cov_report="coverage-report.info" \
--bins="cat-gateway/cat-gateway"
FINALLY
SAVE ARTIFACT --if-exists target/nextest/ci/junit.xml AS LOCAL cat-gateway.junit-report.xml
SAVE ARTIFACT --if-exists coverage-report.info AS LOCAL cat-gateway.coverage-report.info
END
DO rust-ci+EXECUTE \
--cmd="/scripts/std_build.py" \
--args1="--bins=cat-gateway/cat-gateway" \
--args2="--verbose" \
--output="target/$TARGETARCH/release/cat-gateway" \
--junit="cat-gateway.junit-report.xml" \
--coverage="cat-gateway.coverage-report.info" \
--docs="true"

# Generate the OpenAPI doc from the cat-gateway executable itself.
RUN ./target/$TARGETARCH/release/cat-gateway docs ./target/$TARGETARCH/doc/cat-gateway-api.json

SAVE ARTIFACT target/$TARGETARCH/doc doc
SAVE ARTIFACT target/$TARGETARCH/release/cat-gateway cat-gateway

# Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# all-hosts-build : Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# Only used to validate tooling is working across host toolsets.
all-hosts-build:
BUILD --platform=linux/amd64 --platform=linux/arm64 +build

# package-cat-gateway : Create a deployable container for catalyst-gateway
package-cat-gateway:
ARG tag="latest"

Expand All @@ -61,13 +69,15 @@ package-cat-gateway:
ENTRYPOINT ./entry.sh
SAVE IMAGE cat-gateway:$tag

# package-cat-gateway : Create a deployable container for catalyst-gateway
# And bundle a Mithril snapshot of cardano preprod
package-cat-gateway-with-preprod-snapshot:
ARG tag="latest"

FROM +package-cat-gateway

# copy preprod mithril snapshot to /tmp/preprod dir
COPY github.com/input-output-hk/catalyst-ci/earthly/mithril_snapshot:v2.11.1+package-preprod-snapshot/snapshot /tmp/preprod
COPY mithril-snapshot-ci+package-preprod-snapshot/snapshot /tmp/preprod

SAVE IMAGE cat-gateway:$tag

Expand Down
9 changes: 5 additions & 4 deletions catalyst-gateway/event-db/Earthfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# This is a Dockerfile for building a container image for the Catalyst Event Database.
# The container image is built from scratch and includes the necessary files for running
# the database and its associated software.
VERSION 0.8

VERSION 0.7
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:fix/improve-rust-builder-sj AS postgresql-ci

# cspell: words

# Internal: builder is our Event db builder target. Prepares all necessary artifacts.
# CI target : dependency
builder:
DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.11.1+BUILDER
DO postgresql-ci+BUILDER

# override setup-db.sql
COPY setup-db.sql /sql/
Expand All @@ -21,8 +22,8 @@ builder:
build:
FROM +builder

DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.11.1+BUILD --image_name=event-db
DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.11.1+DOCS --image_name=event-db
DO postgresql-ci+BUILD --image_name=event-db
DO postgresql-ci+DOCS --image_name=event-db

# test the event db database schema
# CI target : true
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/tests/Earthfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION 0.7
VERSION 0.8

package-schemathesis:
FROM python:3.12-alpine3.19
Expand All @@ -12,7 +12,7 @@ package-schemathesis:
ARG openapi_spec

RUN apk add --no-cache gcc musl-dev
RUN python -m pip install schemathesis
RUN python -m pip install schemathesis==3.27.1
RUN mkdir /results

VOLUME /results
Expand Down
9 changes: 6 additions & 3 deletions catalyst-gateway/tests/api_tests/Earthfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
VERSION --global-cache 0.7
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:fix/improve-rust-builder-sj AS python-ci

# builder :
builder:
FROM github.com/input-output-hk/catalyst-ci/earthly/python:v2.11.1+python-base
FROM python-ci+python-base

# prepare tests
COPY --dir ./api_tests .
COPY ./snapshot_tool-56364174.json .
DO github.com/input-output-hk/catalyst-ci/earthly/python:v2.11.1+BUILDER
DO python-ci+BUILDER

test:
FROM +builder
Expand Down
6 changes: 4 additions & 2 deletions catalyst_voices/Earthfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
VERSION --try --global-cache --arg-scope-and-set 0.7
VERSION 0.8

IMPORT ../catalyst-gateway AS catalyst-gateway

# If running this target with a local ssh agent active, set the environment
# variable EARTHLY_SSH_AUTH_SOCK='' to make the `+deps` target work. Earthly
Expand Down Expand Up @@ -43,7 +45,7 @@ code-generator:

FROM +src
WORKDIR /frontend/catalyst_voices/packages/catalyst_voices_services
COPY ../catalyst-gateway+build/doc/cat-gateway-api.json openapi/cat-gateway-api.json
COPY catalyst-gateway+build/doc/cat-gateway-api.json openapi/cat-gateway-api.json
RUN flutter pub get
RUN dart run build_runner build --delete-conflicting-outputs

Expand Down
6 changes: 4 additions & 2 deletions catalyst_voices/test_driver/Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
VERSION --try --global-cache --arg-scope-and-set 0.7
VERSION 0.8

IMPORT ../ AS catalyst-voices

integration-test-web:
FROM ../+build
FROM catalyst-voices+build
ARG TARGETARCH
ARG browser
LET driver_port = 4444
Expand Down
17 changes: 11 additions & 6 deletions docs/Earthfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# Set the Earthly version to 0.7
VERSION 0.7
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:fix/improve-rust-builder-sj AS docs-ci

IMPORT .. AS repo
IMPORT ../catalyst-gateway AS catalyst-gateway
IMPORT ../catalyst-gateway/event-db AS event-db

# cspell: words mkdocs runable

# Copy all the source we need to build the docs
src:
# Common src setup
DO github.com/input-output-hk/catalyst-ci/earthly/docs:v2.11.1+SRC
DO docs-ci+SRC

# Now copy into that any artifacts we pull from the builds.
COPY --dir ../+repo-docs/repo /docs/includes
COPY --dir repo+repo-docs/repo /docs/includes
# copy Rust docs
COPY ./../catalyst-gateway+build/doc /docs/src/api/cat-gateway/rust-docs
COPY catalyst-gateway+build/doc /docs/src/api/cat-gateway/rust-docs

# Copy docs we build in the postgres example.
COPY --dir ../catalyst-gateway/event-db+build/docs src/architecture/08_concepts/event_db
COPY --dir event-db+build/docs src/architecture/08_concepts/event_db


# Build the docs here.
Expand Down
2 changes: 1 addition & 1 deletion utilities/wallet-tester/Earthfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION --try --global-cache 0.7
VERSION 0.8

# builder - Installs node packages.
builder:
Expand Down

0 comments on commit d4f4334

Please sign in to comment.