Skip to content

Commit

Permalink
add Github CI/CD
Browse files Browse the repository at this point in the history
Signed-off-by: Lance-Drane <[email protected]>
  • Loading branch information
Lance-Drane committed Aug 11, 2024
1 parent 1335b38 commit 527dd1a
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 35 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Enforce formatting
run: cargo fmt --all --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Linting
run: cargo clippy --all-features --all-targets -- -Dwarnings

test:
name: Test
runs-on: ubuntu-latest
#services:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test --all-features --all-targets
43 changes: 43 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker

on:
workflow_run:
workflows: ["CI"]
branches: ["main"]
types: ["completed"]

jobs:
docker-release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- build_args: |
BIN_NAME=broker-2-http
app_name: broker-2-http
- build_args: |
BIN_NAME=http-2-broker
app_name: http-2-broker
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Log into registry ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push ${{ matrix.app_name }}
uses: docker/build-push-action@v6
with:
context: .
build-args: ${{ matrix.build_args }}
tags: |
ghcr.io/INTERSECT-SDK/broker-http-proxy/${{ matrix.app_name }}:latest
ghcr.io/INTERSECT-SDK/broker-http-proxy/${{ matrix.app_name }}:${{ github.sha }}
push: true
47 changes: 47 additions & 0 deletions .github/workflows/helm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Helm

on:
workflow_run:
workflows: ["CI"]
branches: ["main"]
types: ["completed"]

jobs:
helm-release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- chart_dir: broker-2-http/chart/
app_name: broker-2-http
- chart_dir: http-2-broker/chart/
app_name: http-2-broker

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Add Helm repo dependencies
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Run chart-releaser for ${{ matrix.app_name }}
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
charts_dir: ${{ matrix.chart_dir }}
18 changes: 9 additions & 9 deletions broker-2-http/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,26 @@ spec:
- name: PROXYAPP_PRODUCTION
value: "true"
- name: PROXYAPP_LOG_LEVEL
value: {{ .Values.app.config.log_level | quote }}
value: {{ .Values.app.log_level | quote }}
- name: PROXYAPP_BROKER__USERNAME
value: {{ .Values.app.config.broker.username | quote }}
value: {{ .Values.app.broker.username | quote }}
- name: PROXYAPP_BROKER__PASSWORD
{{- if .Values.app.config.broker.password.isSecret }}
{{- if .Values.app.broker.password.isSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.app.config.broker.password.secretName }}
key: {{ .Values.app.config.broker.password.secretKey }}
name: {{ .Values.app.broker.password.secretName }}
key: {{ .Values.app.broker.password.secretKey }}
{{- else }}
value: {{ .Values.app.config.broker.password.hardcoded | quote }}
value: {{ .Values.app.broker.password.hardcoded | quote }}
{{- end }}
- name: PROXYAPP_BROKER__HOST
value: {{ .Values.app.config.broker.host | quote }}
value: {{ .Values.app.broker.host | quote }}
- name: PROXYAPP_BROKER__PORT
value: {{ .Values.app.config.broker.port | quote }}
value: {{ .Values.app.broker.port | quote }}
- name: PROXYAPP_APP_PORT
value: {{ .Values.containerPort | quote }}
- name: PROXYAPP_TOPIC_PREFIX
value: {{ required "app.config.topic_prefix not set (i.e. 'organization.facility.system')" .Values.app.config.topic_prefix | quote }}
value: {{ required "app.config.topic_prefix not set (i.e. 'organization.facility.system')" .Values.app.topic_prefix | quote }}
- name: PROXYAPP_APP_USERNAME
value: {{ .Values.app.username | quote }}
- name: PROXYAPP_APP_PASSWORD
Expand Down
12 changes: 5 additions & 7 deletions broker-2-http/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ diagnosticMode:
### Container params ###

image:
registry: code.ornl.gov:4567
#registry: ghcr.io
repository: broker-2-http
# TODO this tag should be something like "broker-2-http-0.1.0" or "http-2-broker-0.1.0"
tag: "0.1.0"
registry: ghcr.io
repository: INTERSECT-SDK/broker-http-proxy/broker-2-http
tag: "latest"
digest: ""
pullPolicy: ""
pullSecrets: []
Expand Down Expand Up @@ -163,8 +161,8 @@ serviceAccount:
app:
logLevel: "info"
topic_prefix: "" # http-2-broker only, i.e. "organization.facility.system", you should consciously set this value
username: ""
password: ""
username: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
password: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
broker:
host: "127.0.0.1"
port: "5672"
Expand Down
22 changes: 11 additions & 11 deletions http-2-broker/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,28 @@ spec:
- name: PROXYAPP_PRODUCTION
value: "true"
- name: PROXYAPP_LOG_LEVEL
value: {{ .Values.app.config.log_level | quote }}
value: {{ .Values.app.log_level | quote }}
- name: PROXYAPP_BROKER__USERNAME
value: {{ .Values.app.config.broker.username | quote }}
value: {{ .Values.app.broker.username | quote }}
- name: PROXYAPP_BROKER__PASSWORD
{{- if .Values.app.config.broker.password.isSecret }}
{{- if .Values.app.broker.password.isSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.app.config.broker.password.secretName }}
key: {{ .Values.app.config.broker.password.secretKey }}
name: {{ .Values.app.broker.password.secretName }}
key: {{ .Values.app.broker.password.secretKey }}
{{- else }}
value: {{ .Values.app.config.broker.password.hardcoded | quote }}
value: {{ .Values.app.broker.password.hardcoded | quote }}
{{- end }}
- name: PROXYAPP_BROKER__HOST
value: {{ .Values.app.config.broker.host | quote }}
value: {{ .Values.app.broker.host | quote }}
- name: PROXYAPP_BROKER__PORT
value: {{ .Values.app.config.broker.port | quote }}
value: {{ .Values.app.broker.port | quote }}
- name: PROXYAPP_OTHER_PROXY__URL
value: {{ .Values.app.config.other_proxy.url | quote }}
value: {{ .Values.app.other_proxy.url | quote }}
- name: PROXYAPP_OTHER_PROXY__USERNAME
value: {{ .Values.app.config.other_proxy.username | quote }}
value: {{ .Values.app.other_proxy.username | quote }}
- name: PROXYAPP_OTHER_PROXY__PASSWORD
value: {{ .Values.app.config.other_proxy.password | quote }}
value: {{ .Values.app.other_proxy.password | quote }}
envFrom:
{{- if .Values.extraEnvVarsCM }}
- configMapRef:
Expand Down
12 changes: 5 additions & 7 deletions http-2-broker/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ diagnosticMode:
### Container params ###

image:
registry: code.ornl.gov:4567
#registry: ghcr.io
repository: http-2-broker
# TODO this tag should be something like "broker-2-http-0.1.0" or "http-2-broker-0.1.0"
tag: "0.1.0"
registry: ghcr.io
repository: INTERSECT-SDK/broker-http-proxy/http-2-broker
tag: "latest"
digest: ""
pullPolicy: ""
pullSecrets: []
Expand Down Expand Up @@ -132,8 +130,8 @@ app:
logLevel: "info"
other_proxy:
url: "" # this should be the complete URL
username: ""
password: ""
username: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
password: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
broker:
host: "127.0.0.1"
port: "5672"
Expand Down
2 changes: 1 addition & 1 deletion http-2-broker/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use intersect_ingress_proxy_common::configuration::{BrokerSettings, LogLevel};
/// FOR DEVOPS USERS:
/// 1) The root struct is "Settings", follow logic from there
/// 2) integers can be provided as a string in config files or environment variables
/// 3) if using environment variables, see comment in "get_configuration()" as an example of how nesting works
/// 4) if using ONLY a file variable, this is determined from the APP_CONFIG_FILE environment variable (environment variables have higher precedence)
/// 5) Additional logic can be found in shared-deps/src/configuration.rs
use intersect_ingress_proxy_common::configuration::{BrokerSettings, LogLevel};
use secrecy::Secret;

#[derive(serde::Deserialize, Clone)]
Expand Down
2 changes: 2 additions & 0 deletions shared-deps/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// FOR DEVOPS USERS:
/// This file represents common configuration structures used across both applications.
/// Implementation details are in the "get_configuration" function.
use std::{fmt::Display, str::FromStr};

use secrecy::Secret;
Expand Down

0 comments on commit 527dd1a

Please sign in to comment.