Skip to content

Commit

Permalink
chore(ci): Bump Rust Versions & Alpine Versions, add ADR for rust-ver…
Browse files Browse the repository at this point in the history
…sions (#180)

* chore(cat-ci): Bup rust tooling dependencies, and add wit-bindgen-cli as a tool to the rust base image

* chore(cat-ci): Bump all possible alpine container versions to 3.19

* fix(docs): Fix CIP header in docs.

* docs(ADR): Add adr about rust-version

* docs(ADR): Add scope section to ADR to show they apply to all subordinate repos, unless otherwise defined.

* fix(rust): Fix wit-bindgen-cli binary name in install

* docs(cspell): fix spelling

* fix(postgresql): sqlfluff not a standard alpine package, but still install system wide.

* fix(rust): Fix command lines for `cargo modules` due to tool version changes.

* fix(postgresql): fix string concat generating rust build graphs

* docs(cspell): fix spelling

* feat(rust): Allow BSD-2-Clause license in dependencies for Rust
  • Loading branch information
stevenj authored Jan 31, 2024
1 parent 45ff406 commit b764187
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 42 deletions.
3 changes: 1 addition & 2 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ check-spelling:

# check-bash - test all bash files lint properly according to shellcheck.
check-bash:
FROM alpine:3.18
FROM alpine:3.19

DO ./earthly/bash+SHELLCHECK --src=.

# Internal: Reference to our repo root documentation used by docs builder.
repo-docs:
# Create artifacts of extra files we embed inside the documentation when its built.
FROM scratch
#FROM alpine:3.18

WORKDIR /repo
COPY --dir *.md LICENSE-APACHE LICENSE-MIT .
Expand Down
2 changes: 1 addition & 1 deletion cli/Earthfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION --global-cache 0.7
FROM golang:1.20-alpine3.18
FROM golang:1.21-alpine3.19

# cspell: words onsi ldflags extldflags

Expand Down
6 changes: 3 additions & 3 deletions docs/src/appendix/earthly.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ VERSION --global-cache 0.7 # This defines the "schema version" that this Earthf
deps:
# A target can be thought of as a group of container image layers (think of Docker multi-stage builds)
# For this target, we start by deriving from an image which contains the Go tooling we need
FROM golang:1.20-alpine3.18
FROM golang:1.21-alpine3.19
# Earthly has a 1:1 relationship with most Dockerfile commands, but there are a few exceptions
WORKDIR /work
Expand All @@ -107,7 +107,7 @@ Each target then specifies one or more commands that create the image layers ass
VERSION --global-cache 0.7
deps:
FROM golang:1.20-alpine3.18
FROM golang:1.21-alpine3.19
WORKDIR /work
# These commands work identical to their Dockerfile equivalent
Expand Down Expand Up @@ -182,7 +182,7 @@ build:
docker:
# Here we inherit from a "fresh" minimal alpine version
FROM alpine:3.18
FROM alpine:3.19
WORKDIR /app
# By default, we'll output this image with the 'latest' tag, but this can be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ If we don't:
* Difficult to ensure the necessary information is captured.
* Difficult to iterate and be agile.

## Scope

This ADR applies to all projects which consume `Catalyst-CI` unless they define an ADR specific to that project.

## More Information

* [arc42]
Expand Down
4 changes: 4 additions & 0 deletions docs/src/architecture/09_architecture_decisions/0002-adr.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ This risk can be mitigated because the plugin is simple, and it would be easy fo
* ADR become easier for people to author.
* This should assist in making the team more pro-active in their creation and maintenance.

## Scope

This ADR applies to all projects which consume `Catalyst-CI` unless they define an ADR specific to that project.

## More Information

* [arc42]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ and considerations of the audience for the project the primary language of the p

Having a uniform language for the project makes it easier for people to interact on a common basis.

## Scope

This ADR applies to all projects which consume `Catalyst-CI` unless they define an ADR specific to that project.

## More Information

* [Why English is the Lingua Franca of Programming](https://ystudios.com/insights-passion/codelanguage)
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ By using automation we ensure this consistency, regardless of a contributors pro

`cspell`

## Scope

This ADR applies to all projects which consume `Catalyst-CI` unless they define an ADR specific to that project.

## More Information

* [CSpell]
Expand Down
4 changes: 4 additions & 0 deletions docs/src/architecture/09_architecture_decisions/0005-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ make it a compelling choice for backend systems programming.
The language emphasizes backward compatibility and provides a strong commitment to avoiding breaking changes.
This ensures that code written in Rust today will continue to work in the future.

## Scope

This ADR applies to all projects which consume `Catalyst-CI` unless they define an ADR specific to that project.

## More Information

* [Rust](https://www.rust-lang.org/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
adr:
author: Steven Johnson
created: 09-Jan-2024
status: draft
status: accepted
extends:
- 0005-rust
tags:
Expand Down Expand Up @@ -38,6 +38,10 @@ We forget to introduce `cargo.lock` on our binaries when we approach release.

This should make it a little easier to iterate with less issues caused by out of date `cargo.lock` files finding there way into CI.

## Scope

This ADR applies to all projects which consume `Catalyst-CI` unless they define an ADR specific to that project.

## More Information

* [Cargo/toml vs Cargo.lock]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: 0007 Rust Version configuration in `cargo.toml`
adr:
author: Steven Johnson
created: 21-Jan-2024
status: accepted
extends:
- 0005-rust
tags:
- Rust
---

## Context

In the Rust`cargo.toml` it is possible to specify a minimum version of Rust supported by a Crate/Application.
This rust projects which consume crates to ensure they or on a supported version.
There should be a policy about How many old versions of Rust is supported by our project.

## Assumptions

This ADR is deliberately limited to the initial bring up phase of our projects, and subject to review.

## Decision

We will not use the `rust-version` feature of `cargo.toml` during initial bring up.
We have not defined a maximum range of valid Rust versions, and always build ONLY with the version defined in `rust-toolchain.toml`.

Currently the ONLY supported rust version is the one specified by `rust-toolchain.toml`.

If at a later time, a range of rust versions is decided to be supported then:

* This ADR will be obsoleted by a new one which defines that range of supported versions.
* The allowable range will need to be enforced in CI to ensure a `Cargo.toml` file does not specify the wrong thing.
* All Rust versions in that range will need to be tested in CI to ensure they are properly supported.

## Risks

None, this decision is subject to review at any time.

## Consequences

Development should be easier, and CI faster as we are specifically locked to a single Rust toolchain version.

## Scope

This ADR applies to all projects which consume `Catalyst-CI` unless they define an ADR specific to that project.

## More Information

* [`rust-version` field](https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field)
4 changes: 2 additions & 2 deletions docs/src/guides/languages/bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ All that needs to happen is the following be added to the `Earthfile` in the roo
```Earthfile
# Internal: shell-check - test all bash files against our shell check rules.
shell-check:
FROM alpine:3.18
FROM alpine:3.19
DO github.com/input-output-hk/catalyst-ci/earthly/bash:vx.y.z+SHELLCHECK --src=.
# check all repo wide checks are run from here
check:
FROM alpine:3.18
FROM alpine:3.19
# Lint all bash files.
BUILD +shell-check
Expand Down
4 changes: 2 additions & 2 deletions docs/src/guides/languages/go.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ VERSION --global-cache 0.7
deps:
# This target is used to install external Go dependencies.
FROM golang:1.20-alpine3.18
FROM golang:1.21-alpine3.19
WORKDIR /work
# Any build dependencies should also be captured in this target.
Expand Down Expand Up @@ -192,7 +192,7 @@ publish-example:
# This target is called by CI when publishing images. It should use the
# `SAVE IMAGE` command to save the image which is then picked up by the CI.
# Note that we start from a "fresh" base image.
FROM alpine:3.18
FROM alpine:3.19
WORKDIR /app
ARG tag=latest # Prefer to use `latest` by default, the CI will override this.
Expand Down
2 changes: 1 addition & 1 deletion earthly/bash/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VERSION --global-cache --use-function-keyword 0.7

# Internal: builder creates a container we can use to execute shellcheck
builder:
FROM alpine:3.18
FROM alpine:3.19

RUN apk add --no-cache \
bash \
Expand Down
1 change: 0 additions & 1 deletion earthly/docs/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ deps:
# Documentation files used across all documentation builds.
common:
FROM scratch
#FROM alpine:3.18

COPY --dir common/includes common/macros common/overrides common/std-theme.yml /std

Expand Down
8 changes: 4 additions & 4 deletions earthly/docs/common/overrides/cip.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
Authors: {{ page.meta.Authors }} <br/>
{% endif %}
{% if page.meta.Implementors %}
Status: {{ page.meta.Implementors }} <br/>
Implementors: {{ page.meta.Implementors }} <br/>
{% endif %}
{% if page.meta.Discussions %}
Status: {{ page.meta.Discussions }} <br/>
Discussions: {{ page.meta.Discussions }} <br/>
{% endif %}
{% if page.meta.Created %}
Status: {{ page.meta.Created }} <br/>
Created: {{ page.meta.Created }} <br/>
{% endif %}
{% if page.meta.License %}
Status: {{ page.meta.License }} <br/>
License: {{ page.meta.License }} <br/>
{% endif %}
<br/>
{% endif %}
Expand Down
5 changes: 3 additions & 2 deletions earthly/postgresql/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VERSION --global-cache --use-function-keyword 0.7
# cspell: words colordiff psycopg dbviz

postgres-base:
FROM postgres:16.0-alpine3.18
FROM postgres:16.1-alpine3.19

WORKDIR /root

Expand All @@ -28,7 +28,8 @@ postgres-base:
RUN fc-cache -f

# Install SQLFluff
RUN pip3 install sqlfluff==2.3.5
# Not provided by Alpine, so we force pip3 to install it system wide (--break-system-packages)
RUN pip3 install sqlfluff==2.3.5 --break-system-packages
RUN sqlfluff version

# Get refinery
Expand Down
2 changes: 1 addition & 1 deletion earthly/python/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VERSION --global-cache --use-function-keyword 0.7
# cspell: words libgcc

python-base:
FROM python:3.12-alpine3.18
FROM python:3.12-alpine3.19

# Install extra packages we will need to support plugins.
RUN apk add --no-cache \
Expand Down
20 changes: 11 additions & 9 deletions earthly/rust/Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Common Rust UDCs and Builders.
VERSION --global-cache --use-function-keyword 0.7

# cspell: words rustup miri ripgrep colordiff stdcfgs toolset depgraph lcov psycopg
# cspell: words rustup miri ripgrep colordiff stdcfgs toolset depgraph lcov psycopg bindgen
# cspell: words TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT USERPLATFORM USEROS USERARCH USERVARIANT

# Base Rustup build container.
Expand All @@ -21,7 +21,7 @@ rust-base:
# The ACTUAL version of rust that will be used, and available targets
# is controlled by a `rust-toolchain.toml` file when the `SETUP` UDC is run.
# HOWEVER, It is enforced that the rust version in `rust-toolchain.toml` MUST match this version.
FROM rust:1.75-alpine3.18
FROM rust:1.75-alpine3.19

RUN echo "TARGETPLATFORM = $TARGETPLATFORM"; \
echo "TARGETOS = $TARGETOS"; \
Expand Down Expand Up @@ -69,14 +69,16 @@ rust-base:
# Install tools we use commonly with `cargo`.
# Note, we disable static compiles for tools, specifically, as its not required.
# These tools are not artifacts and we do not use them in production.
RUN cargo install cargo-nextest --version=0.9.59 && \
RUN cargo install cargo-nextest --version=0.9.67 && \
cargo install cargo-machete --version=0.6.0 && \
cargo install refinery_cli --version=0.8.11 && \
cargo install cargo-deny --version=0.14.3 && \
cargo install cargo-modules --version=0.10.2 && \
cargo install cargo-depgraph --version=1.5.0 && \
cargo install cargo-llvm-cov --version=0.5.39 && \
cargo install --git https://github.com/bytecodealliance/wasmtime --tag v16.0.0 verify-component-adapter
cargo install refinery_cli --version=0.8.12 && \
cargo install cargo-deny --version=0.14.10 && \
cargo install cargo-modules --version=0.13.5 && \
cargo install cargo-depgraph --version=1.6.0 && \
cargo install cargo-llvm-cov --version=0.6.4 && \
cargo install wasm-tools --version=1.0.57 && \
cargo install --git https://github.com/bytecodealliance/wasmtime --tag v17.0.0 verify-component-adapter && \
cargo install --git https://github.com/bytecodealliance/wit-bindgen --rev 442f005 wit-bindgen-cli

SAVE ARTIFACT $CARGO_HOME/bin/refinery refinery

Expand Down
Loading

0 comments on commit b764187

Please sign in to comment.