Skip to content

Commit

Permalink
feat: Server with metrics and health check ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Kolstad committed Jan 19, 2023
1 parent f858fea commit 231efc3
Show file tree
Hide file tree
Showing 20 changed files with 2,908 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/notify_pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -e
function script_echo() {
echo "unleash-operator-rs: $1"
}

function generate_buildinfo() {
output=${1}
trigger_event=${2}
self_git_sha=$(git rev-parse --short=7 HEAD)

cat <<EOT > ${output}
{
"commits": [
{
"slug": "Unleash/unleash-edge",
"id": "${self_git_sha}"
}
],
"project": "unleash-edge",
"trigger": {
"type": "commit",
"source": "Unleash/unleash-operator-rs",
"commitIds": ["${self_git_sha}"]
},
"docker": {
"image": "${DOCKER_IMAGE}",
"tag": "sha-${self_git_sha}"
},
"unixTimestamp": "$(date +%s)"
}
EOT
}
generate_buildinfo buildinfo.json
script_echo "$(cat buildinfo.json)"

curl -X POST -H "Content-Type: application/json" https://sandbox.getunleash.io/pipeline/build_info -d @buildinfo.json

46 changes: 45 additions & 1 deletion .github/workflows/clippy.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
---
name: Run Code quality checks on code (reporting to )
name: Clippy

on:
push:
branches:
- main
files:
- '**.rs'
- '**.toml'
pull_request:
branches:
- main
files:
- '**.rs'
- '**.toml'

jobs:
clippy:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile default
rustup show
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Install required cargo packages for reporting format
run: cargo install clippy-sarif sarif-fmt
- name: Run rust-clippy
run: |
cargo clippy --all-features --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
continue-on-error: true
- name: Upload analysis results to Github
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: rust-clippy-results.sarif
category: clippy
wait-for-processing: true
77 changes: 77 additions & 0 deletions .github/workflows/docker_ecr_arch64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Build docker image for aarch64 (ECR)

on:
push:
branches:
- main
files:
- '**.rs'
- '**.toml'
tags:
- 'v*'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile default
rustup show
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Install cross (cross compile)
run: |
cargo install cross
- name: Build release
run: |
cross build --release --target=aarch64-unknown-linux-musl
- name: Setup QEMU (to support multiplatform)
uses: docker/setup-qemu-action@v2
- name: Configure aws credentials
uses: aws/actions/configure-aws-credentials@v1-node16
id: aws-eu-north
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-north-1
- name: Login to ECR
id: login-ecr-eu-north
uses: aws-actions/amazon-ecr-login@v1
- name: Setup docker buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta configuration (set image and tag)
uses: docker/metadata-action@v4
id: meta
with:
images: |
${{ steps.login-ecr-eu-north.outputs.registry }}/unleash-edge
tags: |
type=ref,event=branch
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build tag and push image to Amazon ECR
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
notifypipeline:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: docker
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Send to pipeline
run: |
bash ./.github/notify_pipeline.sh
env:
DOCKER_IMAGE: "726824350591.dkr.ecr.eu-north-1.amazonaws.com/unleash-edge"
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run cargo smart-release

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
inputs:
bump_version:
description: Which type of release would you like to make (patch, minor, major)

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout code
with:
token: ${{ secrets.GH_PUSH_TOKEN }}
- name: setup git config
run: |
git config user.name "Github Release Bot"
git config user.email "<>"
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
rustup show
- uses: Swatinem/rust-cache@v2
- name: Install cargo smart-release
run: |
cargo install cargo-smart-release
- name: Run release
run: |
cargo smart-release -u -b ${{ github.event.inputs.bump_version }} --allow-fully-generated-changelog --no-changelog-preview --execute
4 changes: 2 additions & 2 deletions .github/workflows/test-with-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
rustup show
- uses:
- name: Install required cargo pacakges for reporting test coverage
- uses: Swatinem/rust-cache@v2
- name: Install required cargo packages for reporting test coverage
run: cargo install cargo-tarpaulin
- name: Run Tarpaulin (Reporting to coveralls)
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ debug/
*.iml
*.ipr
*.iws
./vscode

.project
.classpath
Expand Down
Loading

0 comments on commit 231efc3

Please sign in to comment.