Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions CI and Release Workflows #4

Merged
merged 9 commits into from
Jun 9, 2024
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
Binary file added .github/assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
111 changes: 84 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,88 @@
---
name: ci
on:
- push
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
name: ci
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
go-version: 1.22
- run: go test -v ./... -covermode=atomic -coverprofile=coverage.out
- uses: codecov/codecov-action@v4.0.1
with:
version: v1.58
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.22
- run: go test -v ./... -covermode=atomic -coverprofile=coverage.out
- uses: codecov/[email protected]
with:
files: coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
slug: snapp-incubator/nats-blackbox-exporter
files: coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
slug: snapp-incubator/nats-blackbox-exporter
build-push:
name: Build & Push
runs-on: ubuntu-latest
needs:
- lint
- test
strategy:
matrix:
command: [janus, ion-sfu]
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.22.x

- name: Checks out our project source code
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/metadata-action@v3
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.REPOSITORY }}-${{ matrix.command }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- uses: docker/build-push-action@v2
with:
file: "build/Dockerfile"
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: release
on:
push:
tags:
- '*'
jobs:
goreleaser:
name: release
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v4
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: '~> v1'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
# config
config.yaml

.DS_Store
.DS_Store
dist/
25 changes: 25 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
project_name: nats-blackbox-exporter

release:
github:
owner: snapp-incubator
name: nats-blackbox-exporter

checksum: {}

builds:
- binary: gosimac
goos:
- linux
- darwin
- windows
goarch:
- amd64
main: ./cmd/nats-blackbox-exporter/main.go

archives:
- id: binary
format: binary
- id: default
format: tar.gz
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# nats-blackbox-exporter
<h1 align="center"> NATS Blackbox Exporter </h1>

<p align="center">
<img src="./.github/assets/image.png" height="250px">
</p>

<p align="center">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/snapp-incubator/nats-blackbox-exporter/ci.yaml?logo=github&style=for-the-badge">
<img alt="Codecov" src="https://img.shields.io/codecov/c/github/snapp-incubator/nats-blackbox-exporter?logo=codecov&style=for-the-badge">
<img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/snapp-incubator/nats-blackbox-exporter?logo=github&style=for-the-badge">
<img alt="GitHub tag (with filter)" src="https://img.shields.io/github/v/tag/snapp-incubator/nats-blackbox-exporter?style=for-the-badge&logo=git">
<img alt="GitHub go.mod Go version (subdirectory of monorepo)" src="https://img.shields.io/github/go-mod/go-version/snapp-incubator/nats-blackbox-exporter?style=for-the-badge&logo=go">
</p>

## Introduction

Each probe publishes a message over Jetstream NATS and then waits to receive it through a subscription. By measuring the time taken for this process, you can monitor the status of your NATS cluster. At Snapp!, we use this to detect the status of our NATS clusters from the client perspective.

You can track the following metrics:
- **Connection**: A `prometheus.CounterVec` that counts disconnections and connections.
- **Latency**: A `prometheus.Histogram` that measures the latency between publishing and subscribing.
- **SuccessCounter**: A `prometheus.CounterVec` that counts successful publishes and consumes.

This setup helps ensure that your NATS clusters are functioning optimally and provides insights into any issues from the client side.
File renamed without changes.
Loading