Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push development
name: Build development images

on:
pull_request:
Expand All @@ -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"
50 changes: 33 additions & 17 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
});
}
33 changes: 31 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions crates/bootstrap-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false

[features]
default = []
telemetry = ["opentelemetry-otlp"]
telemetry = ["tonic", "opentelemetry-otlp"]

[dependencies]
ipfs-operator = { path = "../operator" }
Expand All @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/operator/src/main.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion crates/operator/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/operator/src/telemetry.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading