Skip to content

Commit

Permalink
WIP: Add initial KinD implementation for testing jenkins agents (#574)
Browse files Browse the repository at this point in the history
* Add initial KinD implementation for testing jenkins agents

* Address PR comments, additional robustness + CI of CI
  • Loading branch information
pabrahamsson authored May 31, 2022
1 parent 2258c10 commit 8ea9ed0
Show file tree
Hide file tree
Showing 26 changed files with 335 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/jenkins-agent-ansible-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ jobs:
image: ${{ env.image_name }}
oci: true
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-arachni-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-argocd-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
31 changes: 31 additions & 0 deletions .github/workflows/jenkins-agent-ci-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

---
name: jenkins-agent-ci-pr
on:
pull_request:
paths:
- _test/kind/**
- .github/workflows/jenkins-agent-ci-pr.yaml
jobs:
build:
env:
context: jenkins-agents/jenkins-agent-ansible
image_name: jenkins-agent-ansible
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build image
uses: redhat-actions/buildah-build@v2
with:
context: ${{ env.context }}
dockerfiles: |
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-conftest-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-cosign-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-erlang-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-golang-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-graalvm-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-gradle-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-helm-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-hugo-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
4 changes: 2 additions & 2 deletions .github/workflows/jenkins-agent-image-mgmt-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:

- name: Test image
run: |
echo "Running: podman run --entrypoint bash ${image_name}:${{ steps.check_version.outputs.VERSION }} -c \"skopeo --version\""
podman run --entrypoint bash ${image_name}:${{ steps.check_version.outputs.VERSION }} -c "skopeo --version"
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-mongodb-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-mvn-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-npm-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
6 changes: 2 additions & 4 deletions .github/workflows/jenkins-agent-python-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ jobs:

- name: Test image
run: |
echo "Running: podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} python --version"
podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} python --version
echo "Running: podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} pip --version"
podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} pip --version
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-ruby-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-rust-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
7 changes: 6 additions & 1 deletion .github/workflows/jenkins-agent-zap-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ jobs:
./${{ env.context }}/Dockerfile
image: ${{ env.image_name }}
oci: true
tags: "latest"
tags: "latest"

- name: Test image
run: |
echo "Testing ${{ env.image_name }}"
./_test/kind/setup.sh ${{ env.image_name }}
18 changes: 18 additions & 0 deletions _test/kind/jenkins-casc-config-scripts-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
controller:
JCasC:
configScripts:
seed-jobs: |
jobs:
- script: >
folder('containers-quickstarts')
- script: >
pipelineJob('containers-quickstarts/${JENKINS_AGENT}') {
definition {
cps {
script('''
${JENKINSFILE}
'''.stripIndent())
sandbox()
}
}
}
12 changes: 12 additions & 0 deletions _test/kind/jenkins-podtemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
agent:
podTemplates:
jenkins-agent: |
- name: ${JENKINS_AGENT}
label: ${JENKINS_AGENT}
serviceAccount: jenkins
yamlMergeStrategy: override
containers:
- name: jnlp
args: "^${computer.jnlpmac} ^${computer.name}"
image: ${JENKINS_AGENT}:latest
workingDir: /tmp
11 changes: 11 additions & 0 deletions _test/kind/jenkins-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
controller:
additionalPlugins:
- job-dsl:1.78.3
ingress:
enabled: true
persistence:
enabled: false
rbac:
readSecrets: true
serviceAccount:
create: true
17 changes: 17 additions & 0 deletions _test/kind/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
Loading

0 comments on commit 8ea9ed0

Please sign in to comment.