Skip to content

Commit

Permalink
Fix deploying latency monitor (#2)
Browse files Browse the repository at this point in the history
* Adding sample push gateway url

* Using public reusable tasks

* Scape generated files

* setup driver kubernetes

* Add input to reusable action

* Fix metrics instantiation and labels

* Fix build

* Adding the other workflows

* Apply ronny PR comments

* Fix formatting

* Add error as a counter

* Use push instead of PushAdd

* change jobname

* keep process.env access bundles together

* fixed env resolution

* Add metric labels globally

* adding labels gloabally

---------

Co-authored-by: Ronny Esterluss <ronny.esterluss@hoprnet.org>
  • Loading branch information
ausias-armesto and esterlus authored Sep 13, 2024
1 parent d273083 commit cd6b01c
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 69 deletions.
8 changes: 7 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ UHTTP_LM_ZERO_HOP=true
UHTTP_LM_DISCOVERY_PLATFORM=https://discovery.rpch.tech
UHTTP_LM_INTERVAL_MS=60000
UHTTP_LM_OFFSET_MS=11111
UHTTP_LM_PUSH_GATEWAY=
UHTTP_LM_PUSH_GATEWAY=https://prometheus-pushgateway.staging.hoprnet.link
UHTTP_LM_METRIC_INSTANCE=latency-monitor-green-zurich-1
UHTTP_LM_METRIC_REGION=europe-west6
UHTTP_LM_METRIC_ZONE=europe-west6-a
UHTTP_LM_METRIC_LOCATION=Zurich-Switzerland
UHTTP_LM_METRIC_LATITUDE=47.3668389
UHTTP_LM_METRIC_LONGITUDE=8.5339821
DEBUG=latency-monitor:*
25 changes: 17 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,28 @@ concurrency:

jobs:
build-and-publish:
name: Build and Publish
name: Build and Push
runs-on: self-hosted-hoprnet-small

steps:
- name: Setup uhttp repository
id: setup
uses: hoprnet/products-ci/.github/actions/setup@main
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: 20

- name: Setup GCP
uses: hoprnet/hopr-workflows/actions/setup-gcp@master
with:
google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }}
login-artifact-registry: 'true'

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

- name: Building
run: yarn build
Expand All @@ -36,14 +48,11 @@ jobs:
- name: Get PR version
id: variables
run: |
BUILD_DATE=$(date +%Y%m%d%H%M%S)
PR_VERSION=$(node -p "require('./package.json').version")-pr.${{ github.event.pull_request.number }}
echo "PR_VERSION=${PR_VERSION}" >> $GITHUB_OUTPUT
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
push: true
tags: |
europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:latest
europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:${{ steps.variables.outputs.PR_VERSION }}
tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:${{ steps.variables.outputs.PR_VERSION }}
45 changes: 45 additions & 0 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Merge PR

on:
pull_request:
types:
- closed
branches:
- main

concurrency:
group: merge
cancel-in-progress: false

jobs:
merge:
name: Merge PR
runs-on: self-hosted-hoprnet-small
if: github.event.pull_request.merged == true

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: 20

- name: Setup GCP
id: gcp
uses: hoprnet/hopr-workflows/actions/setup-gcp@master
with:
google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }}
login-artifact-registry: 'true'

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

- name: Build and push docker image
uses: docker/build-push-action@v4
with:
push: true
tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:latest
108 changes: 108 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Close release

on:
workflow_dispatch:
inputs:
release_type:
description: 'Next version type'
required: true
type: choice
default: 'patch'
options:
- patch
- minor
- major

concurrency:
group: release
cancel-in-progress: false

jobs:
release:
name: Close release
runs-on: self-hosted-hoprnet-small

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: 20

- name: Setup GCP
id: gcp
uses: hoprnet/hopr-workflows/actions/setup-gcp@master
with:
google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }}
login-artifact-registry: 'true'

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

- name: Building
run: yarn build

- name: Linting
run: yarn lint:ci

- name: Formatting
run: yarn format:ci

- name: Testing
run: yarn test

- name: Setup environment variables
id: environment
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "release_version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body_path: changelog.md
name: 'uhttp-latency-monitor - v${{ steps.environment.outputs.release_version }}'
tag_name: v${{ steps.environment.outputs.release_version }}


- name: Build and push docker image
uses: docker/build-push-action@v4
with:
push: true
tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:${{ steps.environment.outputs.release_version }}

- name: Bump Version
id: bump
run: |
npm version ${{ inputs.release_type }} --no-git-tag-version
BUMP_VERSION=$(node -p "require('./package.json').version")
echo "bump_version=${BUMP_VERSION}" >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_RUNNER_TOKEN }}
commit-message: 'Bump to version ${{ steps.bump.outputs.bump_version }}'
base: main
title: 'Open release ${{ steps.bump.outputs.bump_version }}'
body: 'The scope of this PR is to bump the new release ${{ steps.bump.outputs.bump_version }}'
branch: bot/open-${{ inputs.release_type }}-${{ steps.bump.outputs.bump_version }}
delete-branch: true
assignees: ${{ github.actor }}
team-reviewers: '@hoprnet/hopr-products-team'

- name: Notify new release
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_API_KEY }}
email: ${{ secrets.ZULIP_EMAIL }}
organization-url: 'https://hopr.zulipchat.com'
type: 'stream'
to: 'Releases'
topic: 'main'
content: |
I'm thrilled to inform the new **uhttp-latency-monitor** version **${{ steps.environment.outputs.current_version }}** has been released.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ coverage/

# dependencies
node_modules/
.vscode/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Created by github pipeline
gha-creds-*.json
Loading

0 comments on commit cd6b01c

Please sign in to comment.