Skip to content

Commit

Permalink
feat: Added Renovate configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kvanzuijlen committed Jan 31, 2024
1 parent fb9052c commit fc6d514
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 122 deletions.
6 changes: 0 additions & 6 deletions .github/dependabot.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/renovate-config.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
onboarding: false,
requireConfig: "ignored",
platform: "github",
repositories: ["jenkinsci/helm-charts"],
allowedPostUpgradeCommands: ["^\.github\/renovate-postupgrade\.sh {{{depName}}} {{{newVersion}}}$"],
prConcurrentLimit: 0,
semanticCommits: "enabled",
enabledManagers: [
"helm-values",
"github-actions",
"regex",
],
packageRules: [
{
matchDepNames: ["jenkins/inbound-agent"],
versioning: "regex:^(?<major>\\d+)?\\.(?<minor>\\w+?)?_(?<patch>\\w+)?-(?<build>\\d+)?$",
},
{
matchDepNames: ["jenkins/jenkins"],
versioning: "regex:^(?<major>\\d+?)\\.(?<minor>\\d+?)\\.(?<patch>\\d+?)(-(?<compatibility>\\w+))?$",
},
{
matchFileNames: ["charts/jenkins/**"],
postUpgradeTasks: {
commands: [
".github/renovate-postupgrade.sh {{{depName}}} {{{newVersion}}}",
],
fileFilters: ["charts/jenkins/**"],
executionMode: "branch",
},
},
],
customManagers: [
{
customType: "regex",
fileMatch: ["(^|/)\\.github/workflows/[^/]+\\.ya?ml$", "(^|/)\\.github/[^/]+\\.sh$"],
matchStrings: [
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s+?[\\w\\s-]*?version:? (?<currentValue>.*)\\s",
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sENV .*?_VERSION=(?<currentValue>.*)\\s",
],
},
{
customType: "regex",
fileMatch: [
"^charts/jenkins/Chart.yaml$",
"^charts/jenkins/values.yaml$",
],
matchStrings: [
"appVersion: (?<currentValue>.*?)\\s",
'repository: \\"jenkins/jenkins\\"\\s*?# tag: \\"(?<currentValue>.*?)\\"',
],
depNameTemplate: "jenkins/jenkins",
datasourceTemplate: "docker",
},
{
customType: "regex",
fileMatch: ["^charts/jenkins/values.yaml$"],
matchStringsStrategy: "recursive",
matchStrings: [
"installPlugins:[\\s\\w:.-]*?(?:\\r*\\n){2}",
"- (?<depName>.*?):(?<currentValue>.*?)\\s",
],
datasourceTemplate: "jenkins-plugins",
versioningTemplate: "regex:^(?<major>\\d+)?\\.(?<minor>\\w+?)?(\\.(?<patch>\\d+?))?$",
},
{
customType: "regex",
fileMatch: ["^charts/jenkins/Chart.yaml$"],
matchStringsStrategy: "recursive",
matchStrings: [
"artifacthub\\.io\\/images: \\|[\\s\\w:.\\/-]*(?:artifacthub)",
"image: (?<depName>.*?):(?<currentValue>.*?)\\s",
],
datasourceTemplate: "docker",
versioningTemplate: "regex:^(?<major>\\d+)?\\.(?<minor>\\w+?)?(_|\\.)(?<patch>\\w+)?(-(?<build>\\d+))?.*",
},
],
}
34 changes: 34 additions & 0 deletions .github/renovate-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# renovate: datasource=github-tags depName=mikefarah/yq
export YQ_VERSION=v4.40.5

# renovate: datasource=github-tags depName=helm/helm
export HELM_VERSION=v3.14.0

# renovate: datasource=github-tags depName=helm-unittest/helm-unittest
export HELM_UNITTEST_VERSION=v0.3.6

# renovate: datasource=github-tags depName=jenkins-x-plugins/jx-release-version
export JENKINS_JX_VERSION=v2.7.3

apt update

apt install -y curl git

curl -fsSL -o /tmp/helm.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz
mkdir -p /tmp/helm && tar -xf /tmp/helm.tar.gz -C /tmp/helm
mv /tmp/helm/linux-amd64/helm /usr/local/bin/helm
chmod a+x /usr/local/bin/helm

runuser -u ubuntu -- helm plugin install https://github.com/helm-unittest/helm-unittest --version ${HELM_UNITTEST_VERSION}

curl -fsSL -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64
chmod a+x /usr/local/bin/yq

curl -fsSL -o /tmp/jx-release.tar.gz https://github.com/jenkins-x-plugins/jx-release-version/releases/download/${JENKINS_JX_VERSION}/jx-release-version-linux-amd64.tar.gz
mkdir -p /tmp/jx && tar -xf /tmp/jx-release.tar.gz -C /tmp/jx
mv /tmp/jx/jx-release-version /usr/local/bin/jx-release-version
chmod a+x /usr/local/bin/jx-release-version

runuser -u ubuntu renovate
10 changes: 10 additions & 0 deletions .github/renovate-postupgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

CHARTVERSION="$(jx-release-version -previous-version=from-file:charts/jenkins/Chart.yaml)"
export CHARTVERSION
export DEPNAME="$1"
export NEWVERSION="$2"

helm unittest --strict -f 'unittests/*.yaml' charts/jenkins -u
yq eval '.version = env(CHARTVERSION)' -i charts/jenkins/Chart.yaml
sed -i "/git commit to be able to get more details./a \\\n## ${CHARTVERSION}\n\nUpdate \`${DEPNAME}\` to version \`${NEWVERSION}\`" charts/jenkins/CHANGELOG.md
64 changes: 0 additions & 64 deletions .github/renovate.json5

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'
run: |
helm env
helm plugin install https://github.com/helm-unittest/helm-unittest --version 0.3.6
# renovate: datasource=github-tags depName=helm-unittest/helm-unittest
helm plugin install https://github.com/helm-unittest/helm-unittest --version v0.3.6
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml
Expand Down
37 changes: 6 additions & 31 deletions .github/workflows/renovate.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Renovate
on:
schedule:
- cron: "0 * * * 3"
- cron: "0/15 * * * *"
workflow_dispatch:

jobs:
Expand All @@ -18,37 +18,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: 🏗 Set up yq
uses: frenck/[email protected]

- name: next release version
id: nextversion
uses: jenkins-x-plugins/[email protected]
with:
previous-version: from-file:charts/jenkins/Chart.yaml

- name: Set up Helm
id: helm
uses: azure/setup-helm@v3
with:
# renovate: datasource=github-tags depName=helm/helm
version: v3.12.0

- name: install helm unittests
run: |
helm env
helm plugin install https://github.com/helm-unittest/helm-unittest --version 0.3.6
- name: Self-hosted Renovate
uses: renovatebot/github-action@v39.2.4
uses: renovatebot/github-action@v40.0.0
with:
token: "${{ steps.get_token.outputs.token }}"
docker-volumes: |
/tmp:/tmp ;
${{ steps.helm.outputs.helm-path }}:/usr/bin/helm ;
${{ env.HELM_PLUGINS }}/helm-unittest:/usr/bin/helm-plugins/helm-unittest ;
${{ env.RUNNER_TEMP }}/yq/yq:/usr/bin/yq ;
env-regex: "^(?:RENOVATE_\\w+|LOG_LEVEL|GITHUB_COM_TOKEN|NODE_OPTIONS|HELM_PLUGINS|NEXT_VERSION)$"
docker-cmd-file: .github/renovate-entrypoint.sh
docker-user: root
configurationFile: .github/renovate-config.json5
env:
HELM_PLUGINS: "/bin/helm-plugins"
NEXT_VERSION: ${{ steps.nextversion.outputs.version }}
LOG_LEVEL: 'debug'
Empty file removed .github/workflows/sync-lts.yaml
Empty file.
15 changes: 15 additions & 0 deletions charts/jenkins/unittests/__snapshot__/config-test.yaml.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
additional plugins config:
1: |
|-
kubernetes:4174.v4230d0ccd951
workflow-aggregator:596.v8c21c963d92d
git:5.1.0
configuration-as-code:1670.v564dc8b_982d0
kubernetes-credentials-provider
default config:
1: |
|-
kubernetes:4174.v4230d0ccd951
workflow-aggregator:596.v8c21c963d92d
git:5.1.0
configuration-as-code:1670.v564dc8b_982d0
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
configure empty image tag label:
1: |
docker.io/jenkins/jenkins:2.426.2
docker.io/jenkins/jenkins:2.426.3
configure image tag label:
1: |
docker.io/jenkins/jenkins:2.426.2-alpine
docker.io/jenkins/jenkins:2.426.3-alpine
default values:
1: |
replicas: 1
Expand Down Expand Up @@ -40,7 +40,7 @@ default values:
value: "50000"
- name: CASC_JENKINS_CONFIG
value: /var/jenkins_home/casc_configs
image: docker.io/jenkins/jenkins:2.426.2-jdk17
image: docker.io/jenkins/jenkins:2.426.3-jdk17
imagePullPolicy: Always
livenessProbe:
failureThreshold: 5
Expand Down Expand Up @@ -158,7 +158,7 @@ default values:
- command:
- sh
- /var/jenkins_config/apply_config.sh
image: docker.io/jenkins/jenkins:2.426.2-jdk17
image: docker.io/jenkins/jenkins:2.426.3-jdk17
imagePullPolicy: Always
name: init
resources:
Expand Down
15 changes: 2 additions & 13 deletions charts/jenkins/unittests/config-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ tests:
# Copy plugins to shared volume
yes n | cp -i /usr/share/jenkins/ref/plugins/* /var/jenkins_plugins/;
echo "finished initialization"
- equal:
- matchSnapshot:
path: data["plugins.txt"]
value: |-
kubernetes:4174.v4230d0ccd951
workflow-aggregator:596.v8c21c963d92d
git:5.1.0
configuration-as-code:1670.v564dc8b_982d0
- it: no plugins
set:
controller.installPlugins: []
Expand All @@ -66,14 +61,8 @@ tests:
additionalPlugins:
- kubernetes-credentials-provider
asserts:
- equal:
- matchSnapshot:
path: data["plugins.txt"]
value: |-
kubernetes:4174.v4230d0ccd951
workflow-aggregator:596.v8c21c963d92d
git:5.1.0
configuration-as-code:1670.v564dc8b_982d0
kubernetes-credentials-provider
- it: install latest plugins
set:
controller.installLatestPlugins: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ tests:
- it: configure image tag
template: jenkins-controller-statefulset.yaml
set:
controller.image.tag: 2.426.3-slim
controller.image.tag: slim
controller.image.pullPolicy: IfNotPresent
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: jenkins/jenkins:2.426.3-slim
value: docker.io/jenkins/jenkins:slim
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: IfNotPresent
Expand Down Expand Up @@ -186,7 +186,7 @@ tests:
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: registry/image:my-tag
value: docker.io/registry/image:my-tag
- contains:
path: spec.template.spec.containers[0].env
content:
Expand Down

0 comments on commit fc6d514

Please sign in to comment.