From 083a1a6961c3580881623b2bdf18533e5fecc75e Mon Sep 17 00:00:00 2001 From: Brian Hechinger Date: Wed, 23 Sep 2026 10:10:24 +0100 Subject: [PATCH] Fix CI and container workflows --- .github/workflows/build.yaml | 28 ++++++++---------- .github/workflows/release.yaml | 50 +++++++++++++++++++++----------- Cargo.lock | 33 +++++++++++++++++++-- Containerfile | 2 +- crates/bootstrap-web/Cargo.toml | 5 ++-- crates/operator/Cargo.toml | 2 +- crates/operator/src/main.rs | 4 +-- crates/operator/src/metrics.rs | 2 +- crates/operator/src/telemetry.rs | 2 +- 9 files changed, 85 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5d14a18..698fc71 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Build and push development +name: Build development images on: pull_request: @@ -8,23 +8,19 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dcarbone/install-jq-action@v2 - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_SECRET_KEY }} - - name: For pull_request get branch name for tag. id: app_version - run: echo "TAG=${{ github.head_ref }}" >> $GITHUB_OUTPUT - - - name: Use that version to do something funny. shell: bash - run: echo "Current app version is ${{ steps.app_version.outputs.TAG }}" + env: + HEAD_REF: ${{ github.head_ref }} + run: | + tag="${HEAD_REF//[^a-zA-Z0-9_.-]/-}" + if [[ ! "$tag" =~ ^[a-zA-Z0-9_] ]]; then tag="pr-$tag"; fi + echo "TAG=${tag:0:128}" >> "$GITHUB_OUTPUT" - - name: Building & Pushing Docker Image + - name: Build container images + env: + TAG: ${{ steps.app_version.outputs.TAG }} run: | - docker build . -f Containerfile --tag quay.io/gevulot/gevulot-operator:${{ steps.app_version.outputs.TAG }} - docker push quay.io/gevulot/gevulot-operator:${{ steps.app_version.outputs.TAG }} + docker build . -f Containerfile --target ipfs-operator --tag "quay.io/gevulot/ipfs-operator:$TAG" + docker build . -f Containerfile --target bootstrap-web --tag "quay.io/gevulot/bootstrap-web:$TAG" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1d427ed..10b41a2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,10 +7,11 @@ on: permissions: contents: write - packages: read jobs: release: + # Unset by default; enable only after Quay credentials and repositories are configured. + if: vars.QUAY_RELEASE_ENABLED == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -22,26 +23,41 @@ jobs: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_SECRET_KEY }} - - name: For push get current rust app version from its Cargo.toml. + - name: Get operator version id: app_version - run: echo "TAG=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "controller") | .version')" >> $GITHUB_OUTPUT + run: echo "TAG=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "ipfs-operator") | .version')" >> "$GITHUB_OUTPUT" - - name: Use that version to do something funny. - shell: bash - run: echo "Current app version is ${{ steps.app_version.outputs.TAG }}" + - name: Build container images + env: + TAG: ${{ steps.app_version.outputs.TAG }} + run: | + docker build . -f Containerfile --target ipfs-operator --tag "quay.io/gevulot/ipfs-operator:$TAG" --tag quay.io/gevulot/ipfs-operator:latest + docker build . -f Containerfile --target bootstrap-web --tag "quay.io/gevulot/bootstrap-web:$TAG" --tag quay.io/gevulot/bootstrap-web:latest + + - name: Push container images + env: + TAG: ${{ steps.app_version.outputs.TAG }} + run: | + docker push "quay.io/gevulot/ipfs-operator:$TAG" + docker push quay.io/gevulot/ipfs-operator:latest + docker push "quay.io/gevulot/bootstrap-web:$TAG" + docker push quay.io/gevulot/bootstrap-web:latest - name: Create tag uses: actions/github-script@v7 + env: + VERSION: ${{ steps.app_version.outputs.TAG }} with: script: | - github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: 'refs/tags/v${{ steps.app_version.outputs.TAG }}', - sha: context.sha - }) - - - name: Building & Pushing Docker Image - run: | - docker build . -f Containerfile --tag quay.io/gevulot/gevulot-operator:${{ steps.app_version.outputs.TAG }} --tag quay.io/gevulot/gevulot-operator:latest - docker push quay.io/gevulot/gevulot-operator:${{ steps.app_version.outputs.TAG }} + const ref = `tags/v${process.env.VERSION}`; + try { + await github.rest.git.getRef({ owner: context.repo.owner, repo: context.repo.repo, ref }); + } catch (error) { + if (error.status !== 404) throw error; + await github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: `refs/${ref}`, + sha: context.sha + }); + } diff --git a/Cargo.lock b/Cargo.lock index c226c9c..2e20173 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -493,6 +493,7 @@ dependencies = [ "prometheus", "serde", "tokio", + "tonic", "tracing", "tracing-opentelemetry", "tracing-subscriber", @@ -1632,6 +1633,15 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -2197,12 +2207,15 @@ checksum = "7e5e5a5c4135864099f3faafbe939eb4d7f9b80ebf68a8448da961b32a7c1275" dependencies = [ "async-trait", "futures-core", + "http 0.2.12", "opentelemetry-proto", "opentelemetry-semantic-conventions", "opentelemetry_api", "opentelemetry_sdk", + "prost 0.11.8", "thiserror 1.0.69", "tokio", + "tonic", ] [[package]] @@ -2213,6 +2226,8 @@ checksum = "b1e3f814aa9f8c905d0ee4bde026afd3b2577a97c10e1699912e3e44f0c4cbeb" dependencies = [ "opentelemetry_api", "opentelemetry_sdk", + "prost 0.11.8", + "tonic", ] [[package]] @@ -2488,6 +2503,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" dependencies = [ "bytes", + "prost-derive 0.11.8", ] [[package]] @@ -2497,7 +2513,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.14.4", +] + +[[package]] +name = "prost-derive" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -2507,7 +2536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" dependencies = [ "anyhow", - "itertools", + "itertools 0.14.0", "proc-macro2", "quote", "syn 2.0.119", diff --git a/Containerfile b/Containerfile index 70b5fae..5d5aec6 100644 --- a/Containerfile +++ b/Containerfile @@ -13,7 +13,7 @@ ARG RUST_TAG=$RUST_VERSION-alpine$ALPINE_TAG # Define stages from base images, so they can be refereced in COPY commands # in the next stages -FROM rust:$RUST_TAG as rust +FROM rust:$RUST_TAG AS rust # Stage 3: full build environment (Rust, Buf, Protobuf code generators) # This stage can be used as a dev environment for zenith-cli (e.g. from dev containers) diff --git a/crates/bootstrap-web/Cargo.toml b/crates/bootstrap-web/Cargo.toml index 9a0a291..6032469 100644 --- a/crates/bootstrap-web/Cargo.toml +++ b/crates/bootstrap-web/Cargo.toml @@ -8,7 +8,7 @@ publish = false [features] default = [] -telemetry = ["opentelemetry-otlp"] +telemetry = ["tonic", "opentelemetry-otlp"] [dependencies] ipfs-operator = { path = "../operator" } @@ -21,7 +21,8 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tracing-subscriber = { workspace = true, features = ["json", "env-filter", "fmt"] } tracing-opentelemetry.workspace = true opentelemetry = { workspace = true, features = ["trace", "rt-tokio"] } -opentelemetry-otlp = { workspace = true, features = ["tokio"], optional = true } +opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "tokio", "trace"], optional = true } +tonic = { workspace = true, optional = true } kube-runtime.workspace = true kube = { workspace = true, features = ["runtime", "client", "derive" ]} k8s-openapi = { workspace = true, features = ["latest"] } diff --git a/crates/operator/Cargo.toml b/crates/operator/Cargo.toml index 4fd5fb3..b58908b 100644 --- a/crates/operator/Cargo.toml +++ b/crates/operator/Cargo.toml @@ -41,7 +41,7 @@ tracing.workspace = true tracing-subscriber = { workspace = true, features = ["json", "env-filter", "fmt"] } tracing-opentelemetry.workspace = true opentelemetry = { workspace = true, features = ["trace", "rt-tokio"] } -opentelemetry-otlp = { workspace = true, features = ["tokio"], optional = true } +opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "tokio", "trace"], optional = true } tonic = { workspace = true, optional = true } thiserror.workspace = true anyhow.workspace = true diff --git a/crates/operator/src/main.rs b/crates/operator/src/main.rs index 692e9e3..c174725 100644 --- a/crates/operator/src/main.rs +++ b/crates/operator/src/main.rs @@ -1,8 +1,8 @@ #![allow(unused_imports, unused_variables)] use actix_web::{ - get, middleware, web::Data, App, HttpRequest, HttpResponse, HttpServer, Responder, + App, HttpRequest, HttpResponse, HttpServer, Responder, get, middleware, web::Data, }; -pub use controller::{self, telemetry, State}; +pub use controller::{self, State, telemetry}; use prometheus::{Encoder, TextEncoder}; #[get("/metrics")] diff --git a/crates/operator/src/metrics.rs b/crates/operator/src/metrics.rs index 5292ca1..c466175 100644 --- a/crates/operator/src/metrics.rs +++ b/crates/operator/src/metrics.rs @@ -1,7 +1,7 @@ use crate::IpfsNode; use kube::ResourceExt; use operator_common::Error; -use prometheus::{histogram_opts, opts, HistogramVec, IntCounter, IntCounterVec, Registry}; +use prometheus::{HistogramVec, IntCounter, IntCounterVec, Registry, histogram_opts, opts}; use tokio::time::Instant; #[derive(Clone)] diff --git a/crates/operator/src/telemetry.rs b/crates/operator/src/telemetry.rs index e699a2f..e9e427b 100644 --- a/crates/operator/src/telemetry.rs +++ b/crates/operator/src/telemetry.rs @@ -1,5 +1,5 @@ use opentelemetry::trace::TraceId; -use tracing_subscriber::{prelude::*, EnvFilter, Registry}; +use tracing_subscriber::{EnvFilter, Registry, prelude::*}; /// Fetch an opentelemetry::trace::TraceId as hex through the full tracing stack pub fn get_trace_id() -> TraceId {