Skip to content

Commit

Permalink
feat: add goss checks and build on 24.04
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabello committed Dec 13, 2024
1 parent f2780d7 commit 33e4e72
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/rock-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Update rock
on:
workflow_dispatch: {}
schedule:
- cron: '0 0,4,8,12,16,20 * * *'
- cron: '0 0 * * *'

jobs:
build:
Expand All @@ -21,3 +21,4 @@ jobs:
node_version="\$(sed -En 's|\s*"@types/node":\s*"\^*([0-9]+)(\.[0-9])+.*",|\1|p' \$application_src/web/ui/package.json)"
yq -i 'del(.parts.prometheus.build-snaps.[] | select(. == "node/*"))' "\$rockcraft_yaml"
ver="\$node_version" yq -i '.parts.prometheus.build-snaps += "node/"+strenv(ver)+"/stable"' "\$rockcraft_yaml"
secrets: inherit
3 changes: 1 addition & 2 deletions 2.52.0/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: prometheus
summary: Prometheus in a rock.
description: "Prometheus is time-series database for metrics collection and query, driven by either API or a web ui"
version: "2.52.0"
base: ubuntu:22.04
build-base: ubuntu:22.04
base: ubuntu@24.04
license: Apache-2.0
services:
prometheus:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ This repository holds all the necessary files to build rocks for the upstream ve

The rocks on this repository are built with [OCI Factory](https://github.com/canonical/oci-factory/), which also takes care of periodically rebuilding the images.

```
∮ just
Available recipes:
clean version # `rockcraft clean` for a specific version
pack version # Pack a rock of a specific version
run version=latest_version # Run a rock and open a shell into it with `kgoss`
test version=latest_version # Test the rock with `kgoss`
```

Automation takes care of:
* validating PRs, by simply trying to build the rock;
* pulling upstream releases, creating a PR with the necessary files to be manually reviewed;
* on PRs, validate the added (or modified) rocks by running `kgoss`;
* releasing to GHCR at [ghcr.io/canonical/prometheus:dev](https://ghcr.io/canonical/prometheus:dev), when merging to main, for development purposes.

13 changes: 13 additions & 0 deletions goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
process:
prometheus:
running: true
http:
config:
status: 200
url: http://localhost:9090/api/v1/status/config
buildinfo:
status: 200
url: http://localhost:9090/api/v1/status/buildinfo
targets :
status: 200
url: http://localhost:9090/api/v1/targets
33 changes: 33 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set quiet # Recipes are silent by default
set export # Just variables are exported to environment variables

rock_name := `echo ${PWD##*/} | sed 's/-rock//'`
latest_version := `find . -maxdepth 1 -type d | sort -V | tail -n1 | sed 's@./@@'`

[private]
default:
just --list

# Push an OCI image to a local registry
[private]
push-to-registry version:
echo "Pushing $rock_name $version to local registry"
rockcraft.skopeo --insecure-policy copy --dest-tls-verify=false \
"oci-archive:${version}/${rock_name}_${version}_amd64.rock" \
"docker://localhost:32000/${rock_name}-dev:${version}"

# Pack a rock of a specific version
pack version:
cd "$version" && rockcraft pack

# `rockcraft clean` for a specific version
clean version:
cd "$version" && rockcraft clean

# Run a rock and open a shell into it with `kgoss`
run version=latest_version: (push-to-registry version)
kgoss edit -i localhost:32000/${rock_name}-dev:${version}

# Test the rock with `kgoss`
test version=latest_version: (push-to-registry version)
GOSS_OPTS="--retry-timeout 60s" kgoss run -i localhost:32000/${rock_name}-dev:${version}

0 comments on commit 33e4e72

Please # to comment.