Skip to content

Commit 527dd1a

Browse files
committed
add Github CI/CD
Signed-off-by: Lance-Drane <[email protected]>
1 parent 1335b38 commit 527dd1a

File tree

9 files changed

+170
-35
lines changed

9 files changed

+170
-35
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
fmt:
18+
name: Rustfmt
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: dtolnay/rust-toolchain@stable
23+
with:
24+
components: rustfmt
25+
- name: Enforce formatting
26+
run: cargo fmt --all --check
27+
28+
clippy:
29+
name: Clippy
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: dtolnay/rust-toolchain@stable
34+
with:
35+
components: clippy
36+
- name: Linting
37+
run: cargo clippy --all-features --all-targets -- -Dwarnings
38+
39+
test:
40+
name: Test
41+
runs-on: ubuntu-latest
42+
#services:
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: dtolnay/rust-toolchain@stable
46+
- name: Run tests
47+
run: cargo test --all-features --all-targets

.github/workflows/docker-release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Docker
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
branches: ["main"]
7+
types: ["completed"]
8+
9+
jobs:
10+
docker-release:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
- build_args: |
17+
BIN_NAME=broker-2-http
18+
app_name: broker-2-http
19+
- build_args: |
20+
BIN_NAME=http-2-broker
21+
app_name: http-2-broker
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Log into registry ghcr.io
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Build and push ${{ matrix.app_name }}
36+
uses: docker/build-push-action@v6
37+
with:
38+
context: .
39+
build-args: ${{ matrix.build_args }}
40+
tags: |
41+
ghcr.io/INTERSECT-SDK/broker-http-proxy/${{ matrix.app_name }}:latest
42+
ghcr.io/INTERSECT-SDK/broker-http-proxy/${{ matrix.app_name }}:${{ github.sha }}
43+
push: true

.github/workflows/helm-release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Helm
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
branches: ["main"]
7+
types: ["completed"]
8+
9+
jobs:
10+
helm-release:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
strategy:
16+
matrix:
17+
include:
18+
- chart_dir: broker-2-http/chart/
19+
app_name: broker-2-http
20+
- chart_dir: http-2-broker/chart/
21+
app_name: http-2-broker
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Configure Git
29+
run: |
30+
git config user.name "$GITHUB_ACTOR"
31+
git config user.email "[email protected]"
32+
33+
- name: Install Helm
34+
uses: azure/setup-helm@v4
35+
env:
36+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
37+
38+
- name: Add Helm repo dependencies
39+
run: |
40+
helm repo add bitnami https://charts.bitnami.com/bitnami
41+
42+
- name: Run chart-releaser for ${{ matrix.app_name }}
43+
uses: helm/[email protected]
44+
env:
45+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
46+
with:
47+
charts_dir: ${{ matrix.chart_dir }}

broker-2-http/chart/templates/deployment.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,26 @@ spec:
9494
- name: PROXYAPP_PRODUCTION
9595
value: "true"
9696
- name: PROXYAPP_LOG_LEVEL
97-
value: {{ .Values.app.config.log_level | quote }}
97+
value: {{ .Values.app.log_level | quote }}
9898
- name: PROXYAPP_BROKER__USERNAME
99-
value: {{ .Values.app.config.broker.username | quote }}
99+
value: {{ .Values.app.broker.username | quote }}
100100
- name: PROXYAPP_BROKER__PASSWORD
101-
{{- if .Values.app.config.broker.password.isSecret }}
101+
{{- if .Values.app.broker.password.isSecret }}
102102
valueFrom:
103103
secretKeyRef:
104-
name: {{ .Values.app.config.broker.password.secretName }}
105-
key: {{ .Values.app.config.broker.password.secretKey }}
104+
name: {{ .Values.app.broker.password.secretName }}
105+
key: {{ .Values.app.broker.password.secretKey }}
106106
{{- else }}
107-
value: {{ .Values.app.config.broker.password.hardcoded | quote }}
107+
value: {{ .Values.app.broker.password.hardcoded | quote }}
108108
{{- end }}
109109
- name: PROXYAPP_BROKER__HOST
110-
value: {{ .Values.app.config.broker.host | quote }}
110+
value: {{ .Values.app.broker.host | quote }}
111111
- name: PROXYAPP_BROKER__PORT
112-
value: {{ .Values.app.config.broker.port | quote }}
112+
value: {{ .Values.app.broker.port | quote }}
113113
- name: PROXYAPP_APP_PORT
114114
value: {{ .Values.containerPort | quote }}
115115
- name: PROXYAPP_TOPIC_PREFIX
116-
value: {{ required "app.config.topic_prefix not set (i.e. 'organization.facility.system')" .Values.app.config.topic_prefix | quote }}
116+
value: {{ required "app.config.topic_prefix not set (i.e. 'organization.facility.system')" .Values.app.topic_prefix | quote }}
117117
- name: PROXYAPP_APP_USERNAME
118118
value: {{ .Values.app.username | quote }}
119119
- name: PROXYAPP_APP_PASSWORD

broker-2-http/chart/values.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ diagnosticMode:
2727
### Container params ###
2828

2929
image:
30-
registry: code.ornl.gov:4567
31-
#registry: ghcr.io
32-
repository: broker-2-http
33-
# TODO this tag should be something like "broker-2-http-0.1.0" or "http-2-broker-0.1.0"
34-
tag: "0.1.0"
30+
registry: ghcr.io
31+
repository: INTERSECT-SDK/broker-http-proxy/broker-2-http
32+
tag: "latest"
3533
digest: ""
3634
pullPolicy: ""
3735
pullSecrets: []
@@ -163,8 +161,8 @@ serviceAccount:
163161
app:
164162
logLevel: "info"
165163
topic_prefix: "" # http-2-broker only, i.e. "organization.facility.system", you should consciously set this value
166-
username: ""
167-
password: ""
164+
username: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
165+
password: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
168166
broker:
169167
host: "127.0.0.1"
170168
port: "5672"

http-2-broker/chart/templates/deployment.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,28 @@ spec:
9191
- name: PROXYAPP_PRODUCTION
9292
value: "true"
9393
- name: PROXYAPP_LOG_LEVEL
94-
value: {{ .Values.app.config.log_level | quote }}
94+
value: {{ .Values.app.log_level | quote }}
9595
- name: PROXYAPP_BROKER__USERNAME
96-
value: {{ .Values.app.config.broker.username | quote }}
96+
value: {{ .Values.app.broker.username | quote }}
9797
- name: PROXYAPP_BROKER__PASSWORD
98-
{{- if .Values.app.config.broker.password.isSecret }}
98+
{{- if .Values.app.broker.password.isSecret }}
9999
valueFrom:
100100
secretKeyRef:
101-
name: {{ .Values.app.config.broker.password.secretName }}
102-
key: {{ .Values.app.config.broker.password.secretKey }}
101+
name: {{ .Values.app.broker.password.secretName }}
102+
key: {{ .Values.app.broker.password.secretKey }}
103103
{{- else }}
104-
value: {{ .Values.app.config.broker.password.hardcoded | quote }}
104+
value: {{ .Values.app.broker.password.hardcoded | quote }}
105105
{{- end }}
106106
- name: PROXYAPP_BROKER__HOST
107-
value: {{ .Values.app.config.broker.host | quote }}
107+
value: {{ .Values.app.broker.host | quote }}
108108
- name: PROXYAPP_BROKER__PORT
109-
value: {{ .Values.app.config.broker.port | quote }}
109+
value: {{ .Values.app.broker.port | quote }}
110110
- name: PROXYAPP_OTHER_PROXY__URL
111-
value: {{ .Values.app.config.other_proxy.url | quote }}
111+
value: {{ .Values.app.other_proxy.url | quote }}
112112
- name: PROXYAPP_OTHER_PROXY__USERNAME
113-
value: {{ .Values.app.config.other_proxy.username | quote }}
113+
value: {{ .Values.app.other_proxy.username | quote }}
114114
- name: PROXYAPP_OTHER_PROXY__PASSWORD
115-
value: {{ .Values.app.config.other_proxy.password | quote }}
115+
value: {{ .Values.app.other_proxy.password | quote }}
116116
envFrom:
117117
{{- if .Values.extraEnvVarsCM }}
118118
- configMapRef:

http-2-broker/chart/values.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ diagnosticMode:
2727
### Container params ###
2828

2929
image:
30-
registry: code.ornl.gov:4567
31-
#registry: ghcr.io
32-
repository: http-2-broker
33-
# TODO this tag should be something like "broker-2-http-0.1.0" or "http-2-broker-0.1.0"
34-
tag: "0.1.0"
30+
registry: ghcr.io
31+
repository: INTERSECT-SDK/broker-http-proxy/http-2-broker
32+
tag: "latest"
3533
digest: ""
3634
pullPolicy: ""
3735
pullSecrets: []
@@ -132,8 +130,8 @@ app:
132130
logLevel: "info"
133131
other_proxy:
134132
url: "" # this should be the complete URL
135-
username: ""
136-
password: ""
133+
username: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
134+
password: "" # needed credential for clients calling HTTP endpoints other than /healthcheck
137135
broker:
138136
host: "127.0.0.1"
139137
port: "5672"

http-2-broker/src/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use intersect_ingress_proxy_common::configuration::{BrokerSettings, LogLevel};
21
/// FOR DEVOPS USERS:
32
/// 1) The root struct is "Settings", follow logic from there
43
/// 2) integers can be provided as a string in config files or environment variables
54
/// 3) if using environment variables, see comment in "get_configuration()" as an example of how nesting works
65
/// 4) if using ONLY a file variable, this is determined from the APP_CONFIG_FILE environment variable (environment variables have higher precedence)
76
/// 5) Additional logic can be found in shared-deps/src/configuration.rs
7+
use intersect_ingress_proxy_common::configuration::{BrokerSettings, LogLevel};
88
use secrecy::Secret;
99

1010
#[derive(serde::Deserialize, Clone)]

shared-deps/src/configuration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/// FOR DEVOPS USERS:
2+
/// This file represents common configuration structures used across both applications.
3+
/// Implementation details are in the "get_configuration" function.
24
use std::{fmt::Display, str::FromStr};
35

46
use secrecy::Secret;

0 commit comments

Comments
 (0)