Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Oct 19, 2024
0 parents commit 7e6e83b
Show file tree
Hide file tree
Showing 32 changed files with 2,182 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
33 changes: 33 additions & 0 deletions .github/workflows/check-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Check make fmt
on:
push:
branches:
- master
pull_request:

permissions:
contents: read

jobs:
check-make-fmt:
name: Check make fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: install go1.21
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Run make fmt
run: make fmt

- name: Check if make fmt generated changes that should be committed
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Error: make fmt generated changes that should be committed. Please run 'make fmt' and commit the changes."
git diff
git status
exit 1
fi
29 changes: 29 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: lint

on:
push:
branches:
- master
pull_request:

jobs:
Lint:
name: Lint
env:
GO_VERSION: '1.21'
GOPRIVATE: 'github.com/Layr-Labs/cerberus-api'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Configure Git for private modules
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global url."https://${{ github.token }}:[email protected]/".insteadOf "https://github.com/"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow uses gorelaser to both build a github release containing binaries for mac, windows, and linux, and to push the docker images to ghcr.io.
name: goreleaser

on:
push:
# run only against tags
tags:
- "*"

permissions:
contents: write
packages: write
# issues: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: tests

on:
push:
branches:
- master
pull_request:

jobs:
Test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Unit Test
run: make tests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data/

bin/
61 changes: 61 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# ref. https://goreleaser.com/customization/build/
version: 2

project_name: cerberus

builds:
- id: cerberus
main: ./cmd/cerberus/main.go
binary: cerberus
flags:
- -v
ldflags:
- -X 'main.version={{ .Version }}'
# contains linux and darwin
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64

release:
# Repo in which the release will be created.
# Default is extracted from the origin remote URL or empty if its private hosted.
github:
owner: layr-labs
name: cerberus

draft: true

dockers:
- image_templates:
- ghcr.io/layr-labs/{{ .ProjectName }}:latest-amd64
- ghcr.io/layr-labs/{{ .ProjectName }}:{{.Version}}-amd64
use: buildx
dockerfile: Dockerfile
build_flag_templates:
- "--platform=linux/amd64"
- "--build-arg=APP_VERSION={{ .Version }}"
goarch: amd64
- image_templates:
- ghcr.io/layr-labs/{{ .ProjectName }}:latest-arm64
- ghcr.io/layr-labs/{{ .ProjectName }}:{{.Version}}-arm64
use: buildx
dockerfile: Dockerfile
build_flag_templates:
- "--platform=linux/arm64"
- "--build-arg=APP_VERSION={{ .Version }}"
goarch: arm64

docker_manifests:
- name_template: ghcr.io/layr-labs/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/layr-labs/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/layr-labs/{{ .ProjectName }}:{{ .Version }}-arm64
- name_template: ghcr.io/layr-labs/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/layr-labs/{{ .ProjectName }}:latest-amd64
- ghcr.io/layr-labs/{{ .ProjectName }}:latest-arm64
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#FROM golang:1.21 AS build
#
#WORKDIR /usr/src/app
#
#COPY go.mod go.sum ./
#
#RUN go mod download && go mod tidy && go mod verify
#
#COPY . .
#
#ARG APP_VERSION
#RUN go build -ldflags "-X main.version=$APP_VERSION" -v -o bin/cerberus cmd/cerberus/main.go

FROM debian:latest
COPY cerberus /cerberus

ENTRYPOINT [ "/cerberus"]
105 changes: 105 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
Business Source License 1.1

License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
"Business Source License" is a trademark of MariaDB Corporation Ab.

-----------------------------------------------------------------------------

Parameters

Licensor: Eigen Labs, Inc.

Licensed Work: cerberus
The Licensed Work is (c) 2024 Eigen Labs, Inc.

Additional Use Grant:

You may additionally use any of the software included in the following repositories here, https://docs.google.com/spreadsheets/d/1PlJRow5C0GMqXZlIxRm5CEnkhH-gMV1wIdq1pCfbZco/edit?gid=0#gid=0, ("Additional Use Grant Software") for production commercial uses, but only if such uses are (i) built on or using the EigenLayer Protocol or EigenDA, and (ii) not Competing Uses.

"Competing Use" means any use of the Additional Use Grant Software in any product, protocol, application or service that is made available to third parties and that (i) substitutes for use of EigenLayer Protocol or EigenDA, (i) offers the same or substantially similar functionality as the EigenLayer Protocol or EigenDA or (ili) is built on or using a protocol with substantially similar functionality as the EigenLayer Protocol.

EigenLayer Protocol means the restaking protocol as further described in the documentation here, https://docs.eigenlayer.xyz, as updated from time to time.
EigenDA means the data availability protocol built on top of the EigenLayer Protocol as further described in the documentation here, https://docs.eigenlayer.xyz, as updated from time to time.


Change Date: 2026-10-20

Change License: MIT
-----------------------------------------------------------------------------

Terms

The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.

Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.

If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.

All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.

You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.

Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.

This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).

TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.

MariaDB hereby grants you permission to use this License’s text to license
your works, and to refer to it using the trademark "Business Source License",
as long as you comply with the Covenants of Licensor below.

-----------------------------------------------------------------------------

Covenants of Licensor

In consideration of the right to use this License’s text and the "Business
Source License" name and trademark, Licensor covenants to MariaDB, and to all
other recipients of the licensed work to be provided by Licensor:

1. To specify as the Change License the GPL Version 2.0 or any later version,
or a license that is compatible with GPL Version 2.0 or a later version,
where "compatible" means that software provided under the Change License can
be included in a program with software provided under GPL Version 2.0 or a
later version. Licensor may specify additional Change Licenses without
limitation.

2. To either: (a) specify an additional grant of rights to use that does not
impose any additional restriction on the right granted in this License, as
the Additional Use Grant; or (b) insert the text "None".

3. To specify a Change Date.

4. Not to modify this License in any other way.

-----------------------------------------------------------------------------

Notice

The Business Source License (this document, or the "License") is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
APP_NAME=cerberus
GO_LINES_IGNORED_DIRS=
GO_PACKAGES=./internal/... ./cmd/...
GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")

.PHONY: build
build:
@echo "Building..."
go build -o bin/$(APP_NAME) cmd/$(APP_NAME)/main.go
@echo "Done"

.PHONY: start
start:
make build
./bin/$(APP_NAME) --log-level=debug

.PHONY: fmt
fmt: ## formats all go files
go fmt ./...
make format-lines

.PHONY: format-lines
format-lines: ## formats all go files with golines
go install github.com/segmentio/golines@latest
golines -w -m 100 --ignore-generated --shorten-comments --ignored-dirs=${GO_LINES_IGNORED_DIRS} ${GO_FOLDERS}

.PHONY: lint
lint: ## runs all linters
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run ./...

.PHONY: tests
tests: ## runs all tests
go test ./... -covermode=atomic
Loading

0 comments on commit 7e6e83b

Please sign in to comment.