Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
107 changes: 107 additions & 0 deletions .github/workflows/gha-publish-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ on:
required: true
type: boolean
default: false
publish_gha_runner_scale_set_controller_experimental_chart:
description: "Publish new helm chart for gha-runner-scale-set-controller-experimental"
required: true
type: boolean
default: false
publish_gha_runner_scale_set_chart:
description: "Publish new helm chart for gha-runner-scale-set"
required: true
type: boolean
default: false
publish_gha_runner_scale_set_experimental_chart:
description: "Publish new helm chart for gha-runner-scale-set-experimental"
required: true
type: boolean
default: false

env:
HELM_VERSION: v3.8.0
Expand Down Expand Up @@ -159,6 +169,54 @@ jobs:
echo "- Short SHA: ${{ steps.resolve_parameters.outputs.short_sha }}" >> $GITHUB_STEP_SUMMARY
echo "- gha-runner-scale-set-controller Chart version: ${{ env.GHA_RUNNER_SCALE_SET_CONTROLLER_CHART_VERSION_TAG }}" >> $GITHUB_STEP_SUMMARY

publish-helm-chart-gha-runner-scale-set-controller-experimental:
if: ${{ inputs.publish_gha_runner_scale_set_controller_experimental_chart == true }}
needs: build-push-image
name: Publish Helm chart for gha-runner-scale-set-controller-experimental
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
# If inputs.ref is empty, it'll resolve to the default branch
ref: ${{ inputs.ref }}

- name: Resolve parameters
id: resolve_parameters
run: |
resolvedRef="${{ inputs.ref }}"
if [ -z "$resolvedRef" ]
then
resolvedRef="${{ github.ref }}"
fi
echo "resolved_ref=$resolvedRef" >> $GITHUB_OUTPUT
echo "INFO: Resolving short SHA for $resolvedRef"
echo "short_sha=$(git rev-parse --short $resolvedRef)" >> $GITHUB_OUTPUT
echo "INFO: Normalizing repository name (lowercase)"
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT

- name: Set up Helm
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4
with:
version: ${{ env.HELM_VERSION }}

- name: Publish new helm chart for gha-runner-scale-set-controller-experimental
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
GHA_RUNNER_SCALE_SET_CONTROLLER_CHART_VERSION_TAG=$(cat charts/gha-runner-scale-set-controller-experimental/Chart.yaml | grep version: | cut -d " " -d '"' -f 2)
echo "GHA_RUNNER_SCALE_SET_CONTROLLER_CHART_VERSION_TAG=${GHA_RUNNER_SCALE_SET_CONTROLLER_CHART_VERSION_TAG}" >> $GITHUB_ENV
helm package charts/gha-runner-scale-set-controller-experimental/ --version="${GHA_RUNNER_SCALE_SET_CONTROLLER_CHART_VERSION_TAG}"
helm push gha-runner-scale-set-controller-experimental-"${GHA_RUNNER_SCALE_SET_CONTROLLER_CHART_VERSION_TAG}".tgz oci://ghcr.io/${{ steps.resolve_parameters.outputs.repository_owner }}/actions-runner-controller-charts

- name: Job summary
run: |
echo "New helm chart for gha-runner-scale-set-controller-experimental published successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Parameters:**" >> $GITHUB_STEP_SUMMARY
echo "- Ref: ${{ steps.resolve_parameters.outputs.resolved_ref }}" >> $GITHUB_STEP_SUMMARY
echo "- Short SHA: ${{ steps.resolve_parameters.outputs.short_sha }}" >> $GITHUB_STEP_SUMMARY
echo "- gha-runner-scale-set-controller-experimental Chart version: ${{ env.GHA_RUNNER_SCALE_SET_CONTROLLER_CHART_VERSION_TAG }}" >> $GITHUB_STEP_SUMMARY

publish-helm-chart-gha-runner-scale-set:
if: ${{ inputs.publish_gha_runner_scale_set_chart == true }}
needs: build-push-image
Expand Down Expand Up @@ -206,3 +264,52 @@ jobs:
echo "- Ref: ${{ steps.resolve_parameters.outputs.resolvedRef }}" >> $GITHUB_STEP_SUMMARY
echo "- Short SHA: ${{ steps.resolve_parameters.outputs.short_sha }}" >> $GITHUB_STEP_SUMMARY
echo "- gha-runner-scale-set Chart version: ${{ env.GHA_RUNNER_SCALE_SET_CHART_VERSION_TAG }}" >> $GITHUB_STEP_SUMMARY

publish-helm-chart-gha-runner-scale-set-experimental:
if: ${{ inputs.publish_gha_runner_scale_set_experimental_chart == true }}
needs: build-push-image
name: Publish Helm chart for gha-runner-scale-set-experimental
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
# If inputs.ref is empty, it'll resolve to the default branch
ref: ${{ inputs.ref }}

- name: Resolve parameters
id: resolve_parameters
run: |
resolvedRef="${{ inputs.ref }}"
if [ -z "$resolvedRef" ]
then
resolvedRef="${{ github.ref }}"
fi
echo "resolved_ref=$resolvedRef" >> $GITHUB_OUTPUT
echo "INFO: Resolving short SHA for $resolvedRef"
echo "short_sha=$(git rev-parse --short $resolvedRef)" >> $GITHUB_OUTPUT
echo "INFO: Normalizing repository name (lowercase)"
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT

- name: Set up Helm
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4
with:
version: ${{ env.HELM_VERSION }}

- name: Publish new helm chart for gha-runner-scale-set-experimental
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin

GHA_RUNNER_SCALE_SET_CHART_VERSION_TAG=$(cat charts/gha-runner-scale-set-experimental/Chart.yaml | grep version: | cut -d " " -d '"' -f 2)
echo "GHA_RUNNER_SCALE_SET_CHART_VERSION_TAG=${GHA_RUNNER_SCALE_SET_CHART_VERSION_TAG}" >> $GITHUB_ENV
helm package charts/gha-runner-scale-set-experimental/ --version="${GHA_RUNNER_SCALE_SET_CHART_VERSION_TAG}"
helm push gha-runner-scale-set-experimental-"${GHA_RUNNER_SCALE_SET_CHART_VERSION_TAG}".tgz oci://ghcr.io/${{ steps.resolve_parameters.outputs.repository_owner }}/actions-runner-controller-charts

- name: Job summary
run: |
echo "New helm chart for gha-runner-scale-set-experimental published successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Parameters:**" >> $GITHUB_STEP_SUMMARY
echo "- Ref: ${{ steps.resolve_parameters.outputs.resolved_ref }}" >> $GITHUB_STEP_SUMMARY
echo "- Short SHA: ${{ steps.resolve_parameters.outputs.short_sha }}" >> $GITHUB_STEP_SUMMARY
echo "- gha-runner-scale-set-experimental Chart version: ${{ env.GHA_RUNNER_SCALE_SET_CHART_VERSION_TAG }}" >> $GITHUB_STEP_SUMMARY
4 changes: 4 additions & 0 deletions .github/workflows/gha-validate-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,7 @@ jobs:
run: go test ./charts/gha-runner-scale-set/...
- name: Test gha-runner-scale-set-controller
run: go test ./charts/gha-runner-scale-set-controller/...
- name: Test gha-runner-scale-set-experimental
run: go test ./charts/gha-runner-scale-set-experimental/...
- name: Test gha-runner-scale-set-controller-experimental
run: go test ./charts/gha-runner-scale-set-controller-experimental/...
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.13.1
version: 0.14.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.13.1"
appVersion: "0.14.0"

home: https://github.com/actions/actions-runner-controller

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package tests

import (
"os"
"path/filepath"
"strings"
"testing"

"github.com/gruntwork-io/terratest/modules/helm"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/logger"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"
appsv1 "k8s.io/api/apps/v1"
)

type Chart struct {
Version string `yaml:"version"`
AppVersion string `yaml:"appVersion"`
}

func TestTemplate_RenderedDeployment_UsesChartMetadataLabels(t *testing.T) {
t.Parallel()

helmChartPath, err := filepath.Abs("../../gha-runner-scale-set-controller-experimental")
require.NoError(t, err)

chartContent, err := os.ReadFile(filepath.Join(helmChartPath, "Chart.yaml"))
require.NoError(t, err)

chart := new(Chart)
err = yaml.Unmarshal(chartContent, chart)
require.NoError(t, err)

releaseName := "test-arc"
namespaceName := "test-" + strings.ToLower(random.UniqueId())

options := &helm.Options{
Logger: logger.Discard,
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}

output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/deployment.yaml"})

var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(t, output, &deployment)

assert.Equal(t, "gha-rs-controller-"+chart.Version, deployment.Labels["helm.sh/chart"])
assert.Equal(t, chart.AppVersion, deployment.Labels["app.kubernetes.io/version"])
}
4 changes: 2 additions & 2 deletions charts/gha-runner-scale-set-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.13.1
version: 0.14.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.13.1"
appVersion: "0.14.0"

home: https://github.com/actions/actions-runner-controller

Expand Down
4 changes: 2 additions & 2 deletions charts/gha-runner-scale-set-experimental/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "0.13.1"
version: "0.14.0"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.13.1"
appVersion: "0.14.0"

home: https://github.com/actions/actions-runner-controller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ tests:
release:
name: "test-name"
namespace: "test-namespace"
chart:
appVersion: "0.13.1"
asserts:
- equal:
path: metadata.labels["helm.sh/chart"]
value: "gha-rs-0.13.1"
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: "test-name"
Expand All @@ -33,9 +28,9 @@ tests:
- equal:
path: metadata.labels["app.kubernetes.io/part-of"]
value: "gha-rs"
- equal:
- notEqual:
path: metadata.labels["app.kubernetes.io/version"]
value: "0.13.1"
value: ""
- equal:
path: metadata.labels["actions.github.com/scale-set-name"]
value: "test-name"
Expand Down Expand Up @@ -66,9 +61,6 @@ tests:
- equal:
path: metadata.labels["environment"]
value: "production"
- equal:
path: metadata.labels["helm.sh/chart"]
value: "gha-rs-0.13.1"
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: "test-name"
Expand All @@ -84,9 +76,9 @@ tests:
- equal:
path: metadata.labels["app.kubernetes.io/part-of"]
value: "gha-rs"
- equal:
- notEqual:
path: metadata.labels["app.kubernetes.io/version"]
value: "0.13.1"
value: ""
- equal:
path: metadata.labels["actions.github.com/scale-set-name"]
value: "test-name"
Expand Down Expand Up @@ -117,9 +109,6 @@ tests:
- equal:
path: metadata.labels["owner"]
value: "devops"
- equal:
path: metadata.labels["helm.sh/chart"]
value: "gha-rs-0.13.1"
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: "test-name"
Expand All @@ -135,9 +124,9 @@ tests:
- equal:
path: metadata.labels["app.kubernetes.io/part-of"]
value: "gha-rs"
- equal:
- notEqual:
path: metadata.labels["app.kubernetes.io/version"]
value: "0.13.1"
value: ""
- equal:
path: metadata.labels["actions.github.com/scale-set-name"]
value: "test-name"
Expand Down Expand Up @@ -176,9 +165,6 @@ tests:
- equal:
path: metadata.labels["environment"]
value: "staging"
- equal:
path: metadata.labels["helm.sh/chart"]
value: "gha-rs-0.13.1"
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: "test-name"
Expand All @@ -194,9 +180,9 @@ tests:
- equal:
path: metadata.labels["app.kubernetes.io/part-of"]
value: "gha-rs"
- equal:
- notEqual:
path: metadata.labels["app.kubernetes.io/version"]
value: "0.13.1"
value: ""
- equal:
path: metadata.labels["actions.github.com/scale-set-name"]
value: "test-name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@ tests:
release:
name: "test-name"
namespace: "test-namespace"
chart:
appVersion: "0.13.1"
asserts:
- equal:
path: spec.template.metadata.labels["purpose"]
value: "ci"
- equal:
path: spec.template.metadata.labels["team"]
value: "platform"
- equal:
path: spec.template.metadata.labels["helm.sh/chart"]
value: "gha-rs-0.13.1"
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/name"]
value: "test-name"
- notEqual:
path: spec.template.metadata.labels["app.kubernetes.io/version"]
value: ""
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/managed-by"]
value: "Helm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ tests:
release:
name: "test-name"
namespace: "test-namespace"
chart:
appVersion: "0.13.1"
asserts:
- equal:
path: metadata.labels["helm.sh/chart"]
value: "gha-rs-0.13.1"
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: "test-name"
Expand All @@ -31,9 +26,9 @@ tests:
- equal:
path: metadata.labels["app.kubernetes.io/part-of"]
value: "gha-rs"
- equal:
- notEqual:
path: metadata.labels["app.kubernetes.io/version"]
value: "0.13.1"
value: ""
- equal:
path: metadata.labels["actions.github.com/scale-set-name"]
value: "test-name"
Expand Down Expand Up @@ -109,9 +104,9 @@ tests:
name: "test-name"
namespace: "test-namespace"
asserts:
- equal:
- notEqual:
path: metadata.labels["helm.sh/chart"]
value: "gha-rs-0.13.1"
value: "bad"
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: "test-name"
Expand Down
Loading
Loading