Skip to content

Mlflow Release Pipeline #14

Mlflow Release Pipeline

Mlflow Release Pipeline #14

Workflow file for this run

name: MLflow CI
on:
pull_request:
paths:
- 'applications/mlflow/charts/**'
- 'applications/mlflow/kots/**'
- '.github/workflows/mlflow-ci.yml'
push:
branches:
- main
paths:
- 'applications/mlflow/charts/**'
- 'applications/mlflow/kots/**'
- '.github/workflows/mlflow-ci.yml'
env:
APP_SLUG: diamon-mlflow
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.13.3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (lint)
run: ct lint --config applications/mlflow/ct.yaml --chart-dirs applications/mlflow/charts --charts applications/mlflow/charts/mlflow applications/mlflow/charts/infra
helm-install-test-no-sdk:
runs-on: ubuntu-22.04
needs: [lint]
strategy:
fail-fast: false
matrix:
cluster:
- distribution: kind
version: 1.32
#- distribution: kind
# version: 1.31
#- distribution: kind
# version: 1.30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.13.3
- name: Set up chart-testing
uses: helm/[email protected]
- name: Create Cluster
id: create-cluster
uses: replicatedhq/replicated-actions/[email protected]
with:
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
kubernetes-distribution: ${{ matrix.cluster.distribution }}
kubernetes-version: ${{ matrix.cluster.version }}
cluster-name: mlflow-ci-${{ github.run_id }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
ttl: 1h
export-kubeconfig: true
# Add required Helm repositories
- name: Add Helm repositories
run: |
helm repo add cnpg https://cloudnative-pg.github.io/charts
helm repo add minio-operator https://operator.min.io
helm repo update
echo "Helm repositories added successfully"
- name: Install Infra Chart
run: ct install --config applications/mlflow/ct.yaml --chart-dirs applications/mlflow/charts --charts applications/mlflow/charts/infra --skip-clean-up --namespace default
- name: Install Mlflow Chart
run: ct install --config applications/mlflow/ct.yaml --chart-dirs applications/mlflow/charts --charts applications/mlflow/charts/mlflow --skip-clean-up --namespace default
- name: Install troubleshoot
run: curl -L https://github.com/replicatedhq/troubleshoot/releases/latest/download/support-bundle_linux_amd64.tar.gz | tar xzvf -
if: failure()
- name: Collect bundle
run: ./support-bundle --kubeconfig=${{ steps.create-cluster.outputs.cluster-kubeconfig }} --interactive=false -o ci-bundle-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }} https://raw.githubusercontent.com/replicatedhq/troubleshoot-specs/main/in-cluster/default.yaml
if: failure()
- name: Upload support bundle artifact
uses: actions/upload-artifact@v4
if: failure()
with:
name: mlflow-bundle-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
path: 'ci-bundle-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}.tar.gz'
- name: Remove Cluster
uses: replicatedhq/replicated-actions/[email protected]
if: ${{ always() && steps.create-cluster.outputs.cluster-id != '' }}
with:
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
create-release:
runs-on: ubuntu-22.04
needs: [lint, helm-install-test-no-sdk]
outputs:
license-id: ${{ steps.create-customer.outputs.license-id }}
customer-id: ${{ steps.create-customer.outputs.customer-id }}
channel-slug: ${{ steps.create-release.outputs.channel-slug }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.13.3
# Add required Helm repositories
- name: Add Helm repositories
run: |
helm repo add cnpg https://cloudnative-pg.github.io/charts
helm repo add minio-operator https://operator.min.io
helm repo update
echo "Helm repositories added successfully"
- name: Package infra chart
run: |
helm package applications/mlflow/charts/infra -d applications/mlflow/kots/ -u
if [ ! -f applications/mlflow/kots/infra-*.tgz ]; then
echo "Error: Infra chart packaging failed"
exit 1
fi
- name: Package mlflow chart
run: |
helm package applications/mlflow/charts/mlflow -d applications/mlflow/kots/ -u
if [ ! -f applications/mlflow/kots/mlflow-*.tgz ]; then
echo "Error: MLflow chart packaging failed"
exit 1
fi
# The following steps implement our versioning strategy:
# 1. We extract the chart version from mlflow-chart.yaml
# 2. We use this version for the Replicated release
# This ensures that the Replicated release version always matches the MLflow chart version
- name: Extract MLflow chart version
id: chart-version
run: |
CHART_VERSION=$(grep 'chartVersion:' applications/mlflow/kots/mlflow-chart.yaml | awk '{print $2}')
echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT
echo "Using MLflow chart version: $CHART_VERSION"
- name: Create release
id: create-release
uses: replicatedhq/replicated-actions/[email protected]
with:
app-slug: ${{ env.APP_SLUG }}
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
yaml-dir: applications/mlflow/kots/
promote-channel: ci-automation-${{ github.run_id }}
version: ${{ steps.chart-version.outputs.chart_version }}
- name: Create customer
id: create-customer
uses: replicatedhq/replicated-actions/create-customer@main
with:
app-slug: ${{ env.APP_SLUG }}
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
customer-name: automated-${{ github.run_id }}
customer-email: [email protected]
license-type: dev
channel-slug: ${{ steps.create-release.outputs.channel-slug }}
is-kots-install-enabled: "true"
kots-install-test:
runs-on: ubuntu-22.04
needs: [create-release]
env:
LICENSE_ID: ${{ needs.create-release.outputs.license-id }}
CHANNEL_SLUG: ${{ needs.create-release.outputs.channel-slug }}
strategy:
fail-fast: false
matrix:
cluster:
- distribution: kind
version: 1.32
#- distribution: kind
# version: 1.31
#- distribution: kind
# version: 1.30
#- distribution: aks
# version: 1.31
#- distribution: aks
# version: 1.30
#- distribution: gke
# version: 1.32
#- distribution: gke
# version: 1.31
#- distribution: gke
# version: 1.30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Cluster
id: create-cluster
uses: replicatedhq/replicated-actions/[email protected]
with:
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
kubernetes-distribution: ${{ matrix.cluster.distribution }}
kubernetes-version: ${{ matrix.cluster.version }}
cluster-name: mlflow-kots-${{ github.run_id }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
ttl: 1h
export-kubeconfig: true
# The following step extracts the chart version to use it for the KOTS installation
- name: Extract MLflow chart version
id: chart-version
run: |
CHART_VERSION=$(grep 'chartVersion:' applications/mlflow/kots/mlflow-chart.yaml | awk '{print $2}')
echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT
echo "Using MLflow chart version: $CHART_VERSION"
# Download license using Replicated vendor-cli Docker container
- name: Download license
id: download-license
run: |
# Create a temporary file to store the license
mkdir -p /tmp/replicated
# Run the vendor-cli command and capture its output
docker run --rm \
-e REPLICATED_API_TOKEN=${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} \
-e REPLICATED_APP=${{ env.APP_SLUG }} \
replicated/vendor-cli:latest \
customer download-license --customer ${{ needs.create-release.outputs.customer-id }} > /tmp/replicated/license.yaml
# Read the license and set it as an output
LICENSE_CONTENT=$(cat /tmp/replicated/license.yaml)
# Use EOF delimiter for multi-line output
echo "license<<EOF" >> $GITHUB_OUTPUT
echo "$LICENSE_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Install using KOTS
- name: KOTS Install
uses: replicatedhq/replicated-actions/[email protected]
with:
kubeconfig: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
kots-version: latest
app-slug: ${{ env.APP_SLUG }}/ci-automation-${{ github.run_id }}
app-version-label: ${{ steps.chart-version.outputs.chart_version }}
license-file: ${{ steps.download-license.outputs.license }}
namespace: default
wait-duration: 10m
shared-password: 'replicatedmlflow'
- name: Install troubleshoot
run: curl -L https://github.com/replicatedhq/troubleshoot/releases/latest/download/support-bundle_linux_amd64.tar.gz | tar xzvf -
if: failure()
- name: Collect bundle
run: ./support-bundle --kubeconfig=${{ steps.create-cluster.outputs.cluster-kubeconfig }} --interactive=false -o kots-ci-bundle-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }} https://raw.githubusercontent.com/replicatedhq/troubleshoot-specs/main/in-cluster/default.yaml
if: failure()
- name: Upload support bundle artifact
uses: actions/upload-artifact@v4
if: failure()
with:
name: mlflow-kots-bundle-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
path: 'kots-ci-bundle-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}.tar.gz'
- name: Remove Cluster
uses: replicatedhq/replicated-actions/[email protected]
if: ${{ always() && steps.create-cluster.outputs.cluster-id != '' }}
with:
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
cleanup-test-release:
runs-on: ubuntu-22.04
needs: [helm-install-test-no-sdk, create-release, kots-install-test]
steps:
- name: Archive Customer
if: ${{ needs.create-release.outputs.customer-id != '' }}
uses: replicatedhq/replicated-actions/[email protected]
with:
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
customer-id: ${{ needs.create-release.outputs.customer-id }}
- name: Archive Channel
if: ${{ needs.create-release.outputs.channel-slug != '' }}
uses: replicatedhq/replicated-actions/[email protected]
with:
app-slug: ${{ env.APP_SLUG }}
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
channel-slug: ${{ needs.create-release.outputs.channel-slug }}