Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows #6

Merged
merged 26 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 69 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: ci
name: Lint, Test, Image Build and Chart release

on:
push:
Expand All @@ -13,53 +13,100 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
- run: go test -v ./... -covermode=atomic -coverprofile=coverage.out
- uses: codecov/codecov-action@v3
with:
files: coverage.out
build:

build-main:
name: build
runs-on: ubuntu-latest
needs:
- lint
- test
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v3
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/build-push-action@v2
- uses: docker/build-push-action@v5
with:
file: "Dockerfile"
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

build-clients:
name: build
runs-on: ubuntu-latest
needs:
- lint
- test
strategy:
matrix:
dir: ["clients/proxy-client", "clients/harbor-client"]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
file: "${{ matrix.dir }}/Dockerfile"
context: ${{ matrix.dir }}
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository }}/${{ matrix.dir }}:${{ github.sha }}

release:
name: release
runs-on: ubuntu-latest
needs:
- build-main
- build-clients
strategy:
matrix:
dir: ["deploymant", "clients/proxy-client", "clients/harbor-client"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Install Helm
uses: azure/setup-helm@v3

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: ${{ matrix.dir }}
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
28 changes: 0 additions & 28 deletions .github/workflows/harbor-realese.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/image.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: snappcloud-harbor-client
description: A Helm chart for Kubernetes
description: A Helm chart for snappcloud-harbor-client

type: application
version: 0.1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 1

image:
repository: ghcr.io/snapp-incubator/snappcloud-status-backend
repository: ghcr.io/snapp-incubator/snappcloud-status-backend/clients/harbor-client
pullPolicy: Always
tag: "0.0.1"

Expand Down
19 changes: 19 additions & 0 deletions clients/proxy-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:alpine AS builder

WORKDIR /go/src/app

COPY . .

RUN go build -o app

FROM alpine:latest

WORKDIR /app

COPY --from=builder /go/src/app/app .

ENV PROXY_URL="The proxy URL goes here."

EXPOSE 8080

CMD ["./app"]
7 changes: 7 additions & 0 deletions clients/proxy-client/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: snappcloud-proxy-client
description: A Helm chart for snappcloud-proxy-client

type: application
version: 0.1.0
appVersion: "0.0.1"
46 changes: 46 additions & 0 deletions clients/proxy-client/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "snappcloud-proxy-client.fullname" . }}
labels:
{{- include "snappcloud-proxy-client.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "snappcloud-proxy-client.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "snappcloud-proxy-client.selectorLabels" . | nindent 8 }}
annotations:
{{- .Values.podAnnotations | toYaml | nindent 8 }}
spec:
serviceAccountName: {{ include "snappcloud-proxy-client.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- name: PROXY_URL
valueFrom:
secretKeyRef:
name: {{ .Values.configSecretName }}
key: PROXY_URL
{{ .Values.nodeSelector | toYaml | nindent 8 }}
tolerations:
{{- with .Values.tolerations }}
{{- toYaml . | nindent 8 }}
{{- end }}
affinity:
{{- with .Values.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
9 changes: 9 additions & 0 deletions clients/proxy-client/charts/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.configSecretName }}
labels:
{{- include "snappcloud-proxy-client.labels" . | nindent 4 }}
type: Opaque
stringData:
PROXY_URL: "The proxy address."
14 changes: 14 additions & 0 deletions clients/proxy-client/charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "snappcloud-proxy-client.fullname" . }}
labels:
{{- include "snappcloud-proxy-client.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
selector:
{{- include "snappcloud-proxy-client.selectorLabels" . | nindent 4 }}
37 changes: 37 additions & 0 deletions clients/proxy-client/charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
replicaCount: 1

image:
repository: ghcr.io/snapp-incubator/snappcloud-status-backend/clients/proxy-client
pullPolicy: Always
tag: "0.0.1"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
create: false
automount: true
annotations: {}
name: ""

service:
type: ClusterIP
port: 8080

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

configSecretName: spcld-proxy-health-client
16 changes: 16 additions & 0 deletions clients/proxy-client/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/snapp-incubator/snappcloud-status-backend/clients/proxy-client

go 1.21.0

require github.com/prometheus/client_golang v1.18.0

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
golang.org/x/sys v0.15.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
26 changes: 26 additions & 0 deletions clients/proxy-client/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
Loading
Loading