Skip to content

Commit

Permalink
Small workflow updates (#5)
Browse files Browse the repository at this point in the history
* Small workflow updates

* use variable

* fix code-rabbit suggestion

* Add documentation

* Remove node 21
  • Loading branch information
ausias-armesto authored Sep 17, 2024
1 parent 470726e commit a8a894f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 30 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# GitHub Workflows

This document describes the GitHub workflows used in this project.

## Build

Builds, Lint, Test on different node versions

Publishes the docker image with version `x.y.z-pr.<PR_NUMBER>`

## Merge PR

Publishes the docker image with `latest`

## Close release

This is a workflow triggered manually from Github Actions [Close Release](https://github.com/hoprnet/uHTTP-latency-monitor/actions/workflows/release.yaml). The tasks performed by this workflow include:

- Publishes the docker image with `x.y.z`
- Create a Github release
- Tag code
- Changelog is autogenerated by commit linear history of the release
- Bumps the new version by opening a new PR
- Sends a Zulip notification
47 changes: 29 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,20 @@ concurrency:
cancel-in-progress: true

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

strategy:
matrix:
node-version: [20.x, 22.x]
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
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
node-version: ${{ matrix.node-version }}

- name: Building
run: yarn build
Expand All @@ -45,14 +36,34 @@ jobs:
- name: Testing
run: yarn test

publish:
name: Publish
runs-on: self-hosted-hoprnet-small
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4

- 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: Get PR version
id: variables
run: |
PR_VERSION=$(node -p "require('./package.json').version")-pr.${{ github.event.pull_request.number }}
PR_VERSION=$(jq -r '.version' ./package.json)-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:${{ steps.variables.outputs.PR_VERSION }}
push: true
tags: ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.variables.outputs.PR_VERSION }}
8 changes: 4 additions & 4 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: 20
node-version: ${{ vars.NODE_VERSION }}

- name: Setup GCP
id: gcp
Expand All @@ -36,10 +36,10 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: kubernetes
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
push: true
tags: ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}:latest
15 changes: 7 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: 20
node-version: ${{ vars.NODE_VERSION }}

- name: Setup GCP
id: gcp
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: kubernetes
driver: kubernetes

- name: Building
run: yarn build
Expand All @@ -64,15 +64,14 @@ jobs:
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: 'uhttp-latency-monitor - v${{ steps.environment.outputs.release_version }}'
name: '${{ vars.DOCKER_IMAGE_NAME }} - 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 }}
push: true
tags: ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.environment.outputs.release_version }}

- name: Bump Version
id: bump
Expand All @@ -93,7 +92,7 @@ jobs:
delete-branch: true
assignees: ${{ github.actor }}
reviewers: 'esterlus'
team-reviewers: '@hoprnet/hopr-devops'
team-reviewers: '@hoprnet/hopr-products-team'

- name: Notify new release
uses: zulip/github-actions-zulip/send-message@v1
Expand All @@ -105,4 +104,4 @@ jobs:
to: 'Releases'
topic: 'main'
content: |
I'm thrilled to inform the new **uhttp-latency-monitor** version **${{ steps.environment.outputs.release_version }}** has been released.
I'm thrilled to inform the new **${{ vars.DOCKER_IMAGE_NAME }}** version **${{ steps.environment.outputs.release_version }}** has been released.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ Measure roundtrip latency through uHTTP network.

- Build container with `docker build -t uhttp-latency-monitor .`
- Run container with `docker run --env-file .env --platform linux/amd64 uhttp-latency-monitor`

## Deployment process

To contribute to this repository you will need to create a pull request. More information about the existing automated workflows can be found in [GitHub Actions](./.github/workflows/README.md)

0 comments on commit a8a894f

Please sign in to comment.