Skip to content

Commit

Permalink
Switch to make-env for build env managment, add script to run in dock…
Browse files Browse the repository at this point in the history
…erfile
  • Loading branch information
meln5674 committed Jul 23, 2024
1 parent 364756b commit 721712a
Show file tree
Hide file tree
Showing 10 changed files with 722 additions and 235 deletions.
127 changes: 28 additions & 99 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ env:

HELM_REPO: "oci://ghcr.io/${{ github.repository }}/charts"

GO_VERSION: 1.20.4

GOPRIVATE: 'github.com/meln5674/*'

HELM_VERSION: v3.12.0

COSIGN_VERSION: v1.13.0

YQ_VERSION: v4.27.2

jobs:
lint:
# runs-on: ubuntu-latest
Expand All @@ -38,37 +32,19 @@ jobs:
# Checkout
- name: Checkout repository
uses: actions/checkout@v3

# Install deps
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: '${{ env.HELM_VERSION }}'

- uses: actions/setup-go@v4
with:
go-version: '^${{ env.GO_VERSION }}'

- name: Install Dependencies
run: |
make deps
make -j deps all-helm-tools chart-deps
# Run Linter
- name: Lint standalone chart
run: |
cd deploy/helm/mlflow-oidc-proxy
../../../bin/helm dependency build
../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0
- name: Lint omnibus dependencies chart
run: |
cd deploy/helm/mlflow-multitenant-deps
../../../bin/helm lint .
../../../bin/helm template .
- name: Lint omnibus chart
run: |
cd deploy/helm/mlflow-multitenant
../../../bin/helm dependency build
../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0
make helm-hog
test:
# runs-on: ubuntu-latest
Expand All @@ -83,36 +59,25 @@ jobs:
with:
submodules: true


# Install Deps

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

- name: Install Helm
uses: azure/setup-helm@v1
with:
version: '${{ env.HELM_VERSION }}'

- uses: actions/setup-go@v4
with:
go-version: '^${{ env.GO_VERSION }}'
- name: Setup Build Environment
run: |
./build-env.sh echo Done
- name: Install Dependencies
run: |
make deps
bin/helm dependency build deploy/helm/mlflow-oidc-proxy
bin/helm dependency build deploy/helm/mlflow-multitenant
bin/helm dependency build deploy/helm/mlflow-multitenant-deps
./build-env.sh make -j deps all-test-tools all-e2e-tools chart-deps
# Tests
- name: Unit Tests
run: |
make test
./build-env.sh make test
- name: End-to-End Tests
run: |
make e2e IS_CI=1
./build-env.sh make e2e IS_CI=1

docker:
Expand Down Expand Up @@ -148,22 +113,6 @@ jobs:
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

- name: Install Helm
uses: azure/setup-helm@v1
with:
version: '${{ env.HELM_VERSION }}'

- uses: actions/setup-go@v4
with:
go-version: '^${{ env.GO_VERSION }}'

- name: Install Dependencies
run: |
make deps
# Configuration/metdata

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
Expand Down Expand Up @@ -244,54 +193,34 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Setup Build Environment
run: |
./build-env.sh echo Done
# Install Deps
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: '${{ env.HELM_VERSION }}'

- name: Install YQ
uses: chrisdickinson/setup-yq@latest
with:
yq-version: '${{ env.YQ_VERSION }}'
- name: Install Dependencies
run: |
./build-env.sh make -j all-helm-tools
./build-env.sh helm repo add jetstack https://charts.jetstack.io
./build-env.sh helm repo add zalando https://opensource.zalando.com/postgres-operator/charts/postgres-operator
./build-env.sh make -j chart-deps
- name: Log into Registry
run: |
./build-env.sh helm registry login "${REGISTRY}" -u "${GITHUB_ACTOR}" -p "${GITHUB_TOKEN}"
- name: Package Charts
env:
GIT_TAG: '${{ steps.tagName.outputs.tag }}'
run: |
./build-env.sh ./set-chart-versions "${HELM_REPO}" "${GIT_TAG}" "${GITHUB_SHA}"
./build-env.sh make -j charts
# Release charts
- name: Push Charts
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
run: |
set -x
helm registry login "${REGISTRY}" -u "${GITHUB_ACTOR}" -p "${GITHUB_TOKEN}"
GIT_TAG="${{ steps.tagName.outputs.tag }}"
CHART_APPVERSION="${GIT_TAG:-${GITHUB_SHA}}"
if [ -n "${GIT_TAG}" ]; then
NEW_VERSION_EXPR='"'"${GIT_TAG}"'"'
else
NEW_VERSION_EXPR='.version + "-'"${GITHUB_SHA}"'"'
fi
mkdir -p deploy/helm
for chart in mlflow-oidc-proxy mlflow-multitenant-deps mlflow-multitenant; do
yq -i '.version = '"${NEW_VERSION_EXPR}"'' "deploy/helm/${chart}/Chart.yaml"
for chart in bin/charts/*.tgz ; do
helm push "${chart}" "${HELM_REPO}"
done
yq -i '.appVersion = "'"${CHART_APPVERSION}"'"' "deploy/helm/mlflow-oidc-proxy/Chart.yaml"
STANDALONE_CHART_VERSION="$(yq '.version' 'deploy/helm/mlflow-oidc-proxy/Chart.yaml')"
yq -i '(.dependencies[] | select(.name == "mlflow-oidc-proxy")).version |= "'"${STANDALONE_CHART_VERSION}"'"' 'deploy/helm/mlflow-multitenant/Chart.yaml'
yq -i '(.dependencies[] | select(.name == "mlflow-oidc-proxy")).repository |= "'"${HELM_REPO}"'"' 'deploy/helm/mlflow-multitenant/Chart.yaml'
helm repo add jetstack https://charts.jetstack.io
helm repo add zalando https://opensource.zalando.com/postgres-operator/charts/postgres-operator
helm dependency build deploy/helm/mlflow-multitenant-deps
helm package deploy/helm/mlflow-oidc-proxy/ --destination bin
helm package deploy/helm/mlflow-multitenant-deps/ --destination bin
helm push bin/mlflow-oidc-proxy-*.tgz "${HELM_REPO}"
helm push bin/mlflow-multitenant-deps-*.tgz "${HELM_REPO}"
rm -rf bin/*.tgz # The wildcard below matches the deps chart, this is a hack-y workaround
helm dependency build deploy/helm/mlflow-multitenant
helm package deploy/helm/mlflow-multitenant/ --destination bin
helm push bin/mlflow-multitenant-*.tgz "${HELM_REPO}"
60 changes: 14 additions & 46 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ env:

HELM_REPO: "oci://ghcr.io/${{ github.repository }}/charts"

GO_VERSION: 1.20.4

GOPRIVATE: 'github.com/meln5674/*'

HELM_VERSION: v3.12.0

COSIGN_VERSION: v1.13.0

YQ_VERSION: v4.27.2

jobs:
lint:
# runs-on: ubuntu-latest
Expand All @@ -40,36 +34,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

# Install deps
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: '${{ env.HELM_VERSION }}'

- uses: actions/setup-go@v4
with:
go-version: '^${{ env.GO_VERSION }}'
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

- name: Setup Build Environment
run: |
./build-env.sh echo Done
- name: Install Dependencies
run: |
make deps
./build-env.sh make -j deps all-helm-tools chart-deps
# Run Linter
- name: Lint standalone chart
run: |
cd deploy/helm/mlflow-oidc-proxy
../../../bin/helm dependency build
../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0
- name: Lint omnibus dependencies chart
run: |
cd deploy/helm/mlflow-multitenant-deps
../../../bin/helm lint .
../../../bin/helm template .
- name: Lint omnibus chart
run: |
cd deploy/helm/mlflow-multitenant
../../../bin/helm dependency build
../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0
./build-env.sh make helm-hog
test:
# runs-on: ubuntu-latest
Expand All @@ -84,33 +63,22 @@ jobs:
with:
submodules: true


# Install Deps

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

- name: Install Helm
uses: azure/setup-helm@v1
with:
version: '${{ env.HELM_VERSION }}'

- uses: actions/setup-go@v4
with:
go-version: '^${{ env.GO_VERSION }}'
- name: Setup Build Environment
run: |
./build-env.sh echo Done
- name: Install Dependencies
run: |
make deps
bin/helm dependency build deploy/helm/mlflow-oidc-proxy
bin/helm dependency build deploy/helm/mlflow-multitenant
bin/helm dependency build deploy/helm/mlflow-multitenant-deps
./build-env.sh make -j deps all-test-tools all-e2e-tools chart-deps
# Tests
- name: Unit Tests
run: |
make test
./build-env.sh make test
- name: End-to-End Tests
run: |
make e2e IS_CI=1
./build-env.sh make e2e IS_CI=1
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ FROM golang:1.18 AS build

WORKDIR /usr/src/mlflow-oidc-proxy

COPY main.go go.mod go.sum ./
COPY pkg ./pkg
COPY go.mod go.sum ./
RUN go mod download

COPY main.go ./
COPY pkg ./pkg
RUN GCO_ENABLED=0 GOOS=linux go build -a -ldflags="-w -extldflags "-static"" -tags netgo main.go

FROM alpine:3.16 AS certs
Expand Down
Loading

0 comments on commit 721712a

Please sign in to comment.