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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push Cauldron GitHub Consumer
name: GitHub Consumer (build-push)

on:
workflow_dispatch:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push Cauldron GitHub Group Consumer
name: GitHub Group Consumer (build-push)

on:
workflow_dispatch:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/build-push-cauldron-gitlab-consumer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: GitLab Consumer (build-push)

on:
workflow_dispatch:

jobs:
build-image:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push to GitHub Container Registry
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.gitlab-consumer
platforms: linux/amd64
push: true
provenance: false
tags: ghcr.io/${{ github.repository }}/cauldron-gitlab-consumer:latest
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion .github/workflows/build-push-cauldron-migrator.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push Cauldron Migrator
name: Migrator (build-push)

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-push-cauldron-webhookserver.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push Cauldron Webhook Server
name: Cauldron (build-push)

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stg-cauldron-github-consumer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Staging - Build and push Cauldron GitHub Consumer
name: Staging - GitHub Consumer (build-push)

on:
workflow_dispatch:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/stg-cauldron-gitlab-consumer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Staging - GitLab Consumer (build-push)

on:
workflow_dispatch:

jobs:
build-image:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push to GitHub Container Registry
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.gitlab-consumer
platforms: linux/amd64
push: true
provenance: false
tags: ghcr.io/${{ github.repository }}/cauldron-stg-gitlab-consumer:latest
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion .github/workflows/stg-cauldron-migrator.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Staging - Build and push Cauldron Migrator
name: Staging - Migrator (build-push)

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stg-cauldron-webhookserver.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Staging - Build and push Cauldron Webhook Server
name: Staging - Cauldron (build-push)

on:
workflow_dispatch:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: golangci-lint
- id: golangci-lint-mod
- id: go-mod-tidy
- id: go-unit-tests
- id: go-test-mod

- repo: https://github.com/rubocop-hq/rubocop
rev: v1.70.0
Expand Down
31 changes: 31 additions & 0 deletions Dockerfile.gitlab-consumer
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:1.25-alpine AS builder

WORKDIR /build
COPY . .

ARG GOOS
ARG GOARCH
RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o consumer cmd/gitlabconsumer/main.go

FROM alpine:latest AS certs
RUN apk add --update --no-cache ca-certificates

FROM busybox:latest
Comment on lines +10 to +13

Copilot AI Jan 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Dockerfile uses unpinned base images alpine:latest and busybox:latest, which are mutable tags and introduce a supply-chain risk if the upstream images are compromised. Because the GitLab consumer container will be built and run with access to Kafka and database credentials, a malicious update to those tags could silently run attacker-controlled code inside your deployment. Pin these images to immutable digests or at least specific version tags to ensure you only run trusted image content.

Copilot uses AI. Check for mistakes.
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
USER appuser
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /build/consumer /consumer

ENTRYPOINT ["/consumer"]

LABEL org.opencontainers.image.authors="Uğur vigo Özyılmazel <vigo@devchain.network>"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/devchain-network/cauldron"
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
![Version](https://img.shields.io/badge/version-0.2.0-orange.svg)
![Go](https://img.shields.io/github/go-mod/go-version/devchain-network/cauldron)
[![codecov](https://codecov.io/github/devchain-network/cauldron/graph/badge.svg?token=LAUHZBW12F)](https://codecov.io/github/devchain-network/cauldron)
[![Go Report Card](https://goreportcard.com/badge/github.com/devchain-network/cauldron)](https://goreportcard.com/report/github.com/devchain-network/cauldron)

[![Build and push Cauldron Webhook Server](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-webhookserver.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-webhookserver.yml)
[![Build and push Cauldron Migrator](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-migrator.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-migrator.yml)
[![Build and push Cauldron GitHub Consumer](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-consumer.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-consumer.yml)
[![Build and push Cauldron GitHub Group Consumer](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-group-consumer.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-group-consumer.yml)
[![Cauldron Migrator](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-migrator.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-migrator.yml)
[![Cauldron Webhook Server](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-webhookserver.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-webhookserver.yml)
[![Cauldron GitHub Consumer](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-consumer.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-consumer.yml)
[![Cauldron GitHub Group Consumer](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-group-consumer.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/build-push-cauldron-github-group-consumer.yml)

[![Go Report Card](https://goreportcard.com/badge/github.com/devchain-network/cauldron)](https://goreportcard.com/report/github.com/devchain-network/cauldron)
[![Staging - Cauldron Migrator](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-migrator.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-migrator.yml)
[![Staging - Cauldron Webhook Server](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-webhookserver.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-webhookserver.yml)
[![Staging - Cauldron GitHub Consumer](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-github-consumer.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-github-consumer.yml)
[![Staging - Cauldron GitLab Consumer](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-gitlab-consumer.yml/badge.svg)](https://github.com/devchain-network/cauldron/actions/workflows/stg-cauldron-gitlab-consumer.yml)

# cauldron

Expand All @@ -21,6 +25,16 @@ development.

---

## Supported Git Providers

- [x] GitHub
- [x] GitLab (*staging*)
- [ ] Gitea
- [ ] Codeberg
- [ ] BitBucket

---

## License

This project is licensed under MIT.
Expand Down
2 changes: 1 addition & 1 deletion cmd/githubconsumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func storeMessage(strg storage.PingStorer) kafkaconsumer.ProcessMessageFunc {
}
}

// Run runs kafa github consumer.
// Run runs kafka github consumer.
func Run() error {
logLevel := getenv.String("LOG_LEVEL", slogger.DefaultLogLevel)
brokersList := getenv.String("KCP_BROKERS", kafkacp.DefaultKafkaBrokers)
Expand Down
2 changes: 1 addition & 1 deletion cmd/githubconsumergroup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func storeMessage(strg storage.PingStorer) kafkaconsumergroup.ProcessMessageFunc
}
}

// Run runs kafa github consumer group.
// Run runs kafka github consumer group.
func Run() error {
logLevel := getenv.String("LOG_LEVEL", slogger.DefaultLogLevel)
brokersList := getenv.String("KCP_BROKERS", kafkacp.DefaultKafkaBrokers)
Expand Down
101 changes: 101 additions & 0 deletions cmd/gitlabconsumer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package main

import (
"context"
"fmt"
"log"

"github.com/IBM/sarama"
"github.com/devchain-network/cauldron/internal/kafkacp"
"github.com/devchain-network/cauldron/internal/kafkacp/kafkaconsumer"
"github.com/devchain-network/cauldron/internal/slogger"
"github.com/devchain-network/cauldron/internal/storage"
"github.com/devchain-network/cauldron/internal/storage/gitlabstorage"
"github.com/vigo/getenv"
)

func storeMessage(strg storage.PingStorer) kafkaconsumer.ProcessMessageFunc {
return func(ctx context.Context, msg *sarama.ConsumerMessage) error {
if err := strg.MessageStore(ctx, msg); err != nil {
return fmt.Errorf("message store error: [%w]", err)
}

return nil
}
}

// Run runs kafka gitlab consumer.
func Run() error {
logLevel := getenv.String("LOG_LEVEL", slogger.DefaultLogLevel)
brokersList := getenv.String("KCP_BROKERS", kafkacp.DefaultKafkaBrokers)

kafkaTopic := getenv.String("KC_TOPIC_GITLAB", "")
kafkaPartition := getenv.Int("KC_PARTITION", kafkaconsumer.DefaultPartition)
kafkaDialTimeout := getenv.Duration("KC_DIAL_TIMEOUT", kafkaconsumer.DefaultDialTimeout)
kafkaReadTimeout := getenv.Duration("KC_READ_TIMEOUT", kafkaconsumer.DefaultReadTimeout)
kafkaWriteTimeout := getenv.Duration("KC_WRITE_TIMEOUT", kafkaconsumer.DefaultWriteTimeout)
kafkaBackoff := getenv.Duration("KC_BACKOFF", kafkaconsumer.DefaultBackoff)
kafkaMaxRetries := getenv.Int("KC_MAX_RETRIES", kafkaconsumer.DefaultMaxRetries)

databaseURL := getenv.String("DATABASE_URL", "")
if err := getenv.Parse(); err != nil {
return fmt.Errorf("environment variable parse error: [%w]", err)
}

logger, err := slogger.New(
slogger.WithLogLevelName(*logLevel),
)
if err != nil {
return fmt.Errorf("logger instantiate error: [%w]", err)
}

ctx, cancel := context.WithTimeout(context.Background(), storage.DefaultDBPingTimeout)
defer cancel()

db, err := gitlabstorage.New(
ctx,
gitlabstorage.WithDatabaseDSN(*databaseURL),
gitlabstorage.WithLogger(logger),
)
if err != nil {
return fmt.Errorf("gitlab storage instantiate error: [%w]", err)
}

if err = db.Ping(ctx, storage.DefaultDBPingMaxRetries, storage.DefaultDBPingBackoff); err != nil {
return fmt.Errorf("gitlab storage ping error: [%w]", err)
}
defer func() {
logger.Info("gitlab storage - closing pgx pool")
db.Pool.Close()
}()

kafkaGitLabConsumer, err := kafkaconsumer.New(
kafkaconsumer.WithLogger(logger),
kafkaconsumer.WithProcessMessageFunc(storeMessage(db)),
kafkaconsumer.WithKafkaBrokers(*brokersList),
kafkaconsumer.WithDialTimeout(*kafkaDialTimeout),
kafkaconsumer.WithReadTimeout(*kafkaReadTimeout),
kafkaconsumer.WithWriteTimeout(*kafkaWriteTimeout),
kafkaconsumer.WithBackoff(*kafkaBackoff),
kafkaconsumer.WithMaxRetries(*kafkaMaxRetries),
kafkaconsumer.WithTopic(*kafkaTopic),
kafkaconsumer.WithPartition(*kafkaPartition),
)
if err != nil {
return fmt.Errorf("gitlab kafka consumer instantiate error: [%w]", err)
}

defer func() { _ = kafkaGitLabConsumer.SaramaConsumer.Close() }()

if err = kafkaGitLabConsumer.Consume(); err != nil {
return fmt.Errorf("gitlab kafka consumer consume error: [%w]", err)
}

return nil
}

func main() {
if err := Run(); err != nil {
log.Fatal(err)
}
}
Loading