Last active
July 5, 2022 07:03
-
-
Save making/ed08b4a2c9d8bf16f8c021141882546f to your computer and use it in GitHub Desktop.
TestContainers on Tekton (privileged required)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: unit-test-pipeline-cache | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 1Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: tekton.dev/v1beta1 | |
kind: PipelineRun | |
metadata: | |
generateName: unit-test-run- | |
spec: | |
pipelineRef: | |
name: unit-test | |
workspaces: | |
- name: cache | |
persistentVolumeClaim: | |
claimName: unit-test-pipeline-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kubectl apply -f unit-test.yaml | |
# kubectl apply -f unit-test-pipeline-cache.yaml | |
# kubectl create -f unit-test-run.yaml | |
--- | |
apiVersion: tekton.dev/v1beta1 | |
kind: Pipeline | |
metadata: | |
name: unit-test | |
spec: | |
workspaces: | |
- name: cache | |
tasks: | |
- name: mvn-test | |
workspaces: | |
- name: cache | |
workspace: cache | |
taskSpec: | |
volumes: | |
- name: dind-certs | |
emptyDir: {} | |
workspaces: | |
- name: cache | |
sidecars: | |
- name: docker | |
image: docker:dind | |
securityContext: | |
privileged: true | |
env: | |
- name: DOCKER_TLS_CERTDIR | |
value: /certs | |
volumeMounts: | |
- mountPath: /certs/client | |
name: dind-certs | |
readinessProbe: | |
periodSeconds: 1 | |
exec: | |
command: ["ls", "/certs/client/ca.pem"] | |
steps: | |
- name: git-clone | |
image: alpine/git | |
workingDir: /workspace | |
script: | | |
#!/usr/bin/env sh | |
git clone https://github.com/categolj/blog-api | |
- name: mvn-test | |
image: eclipse-temurin:17 | |
workingDir: /workspace | |
env: | |
- name: DOCKER_HOST | |
value: tcp://localhost:2376 | |
- name: DOCKER_TLS_VERIFY | |
value: "1" | |
- name: DOCKER_CERT_PATH | |
value: /certs/client | |
volumeMounts: | |
- name: dind-certs | |
mountPath: /certs/client | |
script: | | |
#!/bin/bash | |
set -ex | |
cd blog-api | |
rm -rf ~/.m2 | |
mkdir -p $(workspaces.cache.path)/.m2 | |
ln -fs $(workspaces.cache.path)/.m2 ~/.m2 | |
./mvnw test -V |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment