doc et unit-test

This commit is contained in:
Matthieu Lamalle 2024-01-29 14:49:38 +01:00
parent b04135f9cc
commit 2c186f813c
6 changed files with 129 additions and 27 deletions

View File

@ -29,14 +29,14 @@ setup-cluster:
kubectl apply -k kind/cluster/lb --server-side
ssh-secret:
cp kustomization/overlays/dev/resources/tekton/secret/secret.yaml.distkustomization/overlays/dev/resources/tekton/secret/secret.yaml
cp kustomization/base/tekton/secret/secret.yaml.dist kustomization/base/tekton/secret/secret.yaml
docker-secret:
docker login reg.cadoles.com
mkdir -p kustomization/base/tekton/secret/dockerconfig
docker --config kustomization/base/tekton/secret/dockerconfig login reg.cadoles.com
# mv kustomization/base/tekton/secret/dockerconfig/config.json kustomization/base/tekton/secret/dockerconfig/.dockerconfigjson
kubectl create secret generic regcred --from-file=config.json=kustomization/base/tekton/secret/dockerconfig/config.json
kubectl create secret generic regcred --from-file=config.json=kustomization/base/tekton/secret/dockerconfig/config.json -n tekton
deploy-dev: ## Déploie le projet dans le cluster (nécessite la variable $HARBOR_USER_NAME)
skaffold dev -p dev --cleanup=false --default-repo reg.cadoles.com/${HARBOR_USER_NAME}

View File

@ -2,14 +2,22 @@
CI du projet MSE
[Documentation](doc/tekton.md)
### Lancement de l'environnement
Lancer l'environnement
```
make create-cluster
skaffold dev
```
Préparer les secrets
```
make ssh-secret
make docker-secret
```
Editer le fichier `kustomization/base/tekton/secret/secret.yaml` avec les identifiants git
### Lancement d'un pipeline
[Documentation](doc/tekton.md)

View File

@ -9,6 +9,9 @@ spec:
- name: repo-url
type: string
description: The git repo URL to clone from.
- name: revision
type: string
description: The git repo branch to checkout.
- name: image
type: string
description: Full name of image repo.
@ -33,6 +36,10 @@ spec:
params:
- name: url
value: $(params.repo-url)
- name: revision
value: $(params.revision)
- name: submodules
value: 'false'
# Lecture du readme du projet
- name: show-readme
runAfter: ["fetch-source"]
@ -68,30 +75,45 @@ spec:
- name: config
workspace: config
- name: kaniko-build
taskRef:
name: kaniko
params:
- name: IMAGE
value: $(params.image)
- name: DOCKERFILE
value: $(params.dockerfile)
- name: EXTRA_ARGS
value:
- --skip-tls-verify
- --insecure
workspaces:
- name: source
workspace: shared-data
- name: dockerconfig
workspace: docker-credentials
# Execution des tests unitaires avec une BDD en sidecar
- name: php-unit-test
runAfter:
- fetch-source
# - php-cs-fixer
# - phpstan
# - php-security-check
retries: 3
taskRef:
name: php-unit-test
workspaces:
- name: source
workspace: shared-data
# - name: kaniko-build
# taskRef:
# name: kaniko
# params:
# - name: IMAGE
# value: $(params.image)
# - name: DOCKERFILE
# value: $(params.dockerfile)
# - name: BUILDER_IMAGE
# value: gcr.io/kaniko-project/executor:v1.20.0
# - name: EXTRA_ARGS
# value:
# - --skip-tls-verify
# - --insecure
# - --ignore-path=/product_uuid
# workspaces:
# - name: source
# workspace: shared-data
# - name: dockerconfig
# workspace: docker-credentials
# runAfter:
# - fetch-source
# # - php-cs-fixer
# # - phpstan
# # - php-security-check
# retries: 3
#

View File

@ -2,6 +2,7 @@ apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: symfonyapp-run-
namespace: tekton
spec:
serviceAccountName: build-bot
pipelineRef:
@ -26,7 +27,9 @@ spec:
secretName: regcred
params:
- name: repo-url
value: https://forge.cadoles.com/Cadoles/hydra-dispatcher.git
value: https://forge.cadoles.com/CNOUS/mse.git
- name: revision
value: k8s
- name: image
value: reg.cadoles.com/mlamalle/testtekton
- name: dockerfile

View File

@ -7,3 +7,4 @@ resources:
- task/php-cs-fixer.yaml
- task/php-security-check.yaml
- task/phpstan.yaml
- task/php-unit-test.yaml

View File

@ -0,0 +1,68 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: php-unit-test
spec:
description: PHP unit test with bdd sidecar
workspaces:
- name: source
sidecars:
- name: database
image: postgres:16
env:
- name: POSTGRES_PASSWORD
value: not_so_secret
- name: POSTGRES_HOST_AUTH_METHOD
value: trust
- name: redis
image: redis:4.0
steps:
- name: exec
image: reg.cadoles.com/cadoles/symfony:alpine-php-7.4-base-20230926
env:
- name: PHP_FPM_MEMORY_LIMIT
value: 512m
- name: MSE_DATABASE_DRIVER
value: pdo_pgsql
- name: MSE_DATABASE_HOST
value: localhost
- name: MSE_DATABASE_PORT
value: '5432'
- name: MSE_DATABASE_NAME
value: postgres
- name: MSE_DATABASE_USER
value: postgres
- name: MSE_DATABASE_PASSWORD
value: not_so_secret
- name: MSE_REDIS_SERVER
value: localhost
- name: MSE_REDIS_PORT
value: '6379'
command:
- /bin/sh
args:
- '-c'
- |
set -ex
apk add bash=5.1.16-r0 \
postgresql-client \
php7-gd=7.4.33-r1 \
php7-xsl=7.4.33-r1 \
php7-pdo=7.4.33-r1 \
php7-pgsql=7.4.33-r1 \
php7-pdo_pgsql=7.4.33-r1 \
php7-soap=7.4.33-r1 \
php7-ldap=7.4.33-r1 \
php7-pdo_mysql=7.4.33-r1 \
php7-bcmath=7.4.33-r1 \
php7-intl=7.4.33-r1 \
php7-fileinfo=7.4.33-r1 \
php7-iconv=7.4.33-r1 \
php7-pecl-amqp=1.11.0-r0 \
php7-pecl-redis=5.3.6-r0
cd $(workspaces.source.path)
app/console doctrine:migrations:migrate -n
./scripts/run-php-tests.sh --group unit --stderr --testdox -d memory_limit=512M