From 66409c6688b507e0d657b044e4e32a5b205882f7 Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 30 Jan 2023 22:54:16 +1100 Subject: [PATCH] Fixes to CI/CD now that we use osixia/openldap --- .env.testing | 5 +++-- .gitlab-ci.yml | 12 +++++----- .gitlab-docker-x86_64.yml | 41 +++++++++++++++------------------- .gitlab-test.yml | 47 +++++++++++++++++++++------------------ 4 files changed, 52 insertions(+), 53 deletions(-) diff --git a/.env.testing b/.env.testing index a5bf2f4..34bbb3e 100644 --- a/.env.testing +++ b/.env.testing @@ -46,5 +46,6 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" LDAP_HOST=ldap LDAP_PORT=389 LDAP_BASE_DN="dc=Test" -LDAP_USERNAME= -LDAP_PASSWORD= +LDAP_USERNAME="cn=admin,dc=Test" +LDAP_PASSWORD="test" +LDAP_CACHE=false diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b4631f2..34d272e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,14 @@ stages: - - test - - build +- test +- build # This folder is cached between builds # http://docs.gitlab.com/ce/ci/yaml/README.html#cache cache: - key: ${CI_COMMIT_REF_SLUG} + key: ${CI_JOB_NAME_SLUG}-${CI_COMMIT_REF_SLUG} paths: - - vendor/ + - vendor/ include: - - .gitlab-test.yml - - .gitlab-docker-x86_64.yml +- .gitlab-test.yml +- .gitlab-docker-x86_64.yml diff --git a/.gitlab-docker-x86_64.yml b/.gitlab-docker-x86_64.yml index c0c71bf..c5bca19 100644 --- a/.gitlab-docker-x86_64.yml +++ b/.gitlab-docker-x86_64.yml @@ -1,32 +1,27 @@ docker: - image: docker:latest + variables: + VERSION: latest + DOCKER_HOST: tcp://docker:2375 stage: build + image: docker:latest services: - - docker:dind - - variables: - VERSION: latest - CACHETAG: build-${VERSION} - DOCKER_HOST: tcp://docker:2375 - - tags: - - docker - - x86_64 - only: - - BRANCH-2.0 + - docker:dind before_script: - - docker info - - docker version - - echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin - - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi + - docker info && docker version + - echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin + - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi script: - - if [ -f init ]; then chmod 500 init; fi - - ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || echo "true" - - echo -n ${CI_COMMIT_SHORT_SHA} > VERSION - - docker build -f docker/Dockerfile --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} . - - docker push ${CI_REGISTRY_IMAGE}:${VERSION} - - docker push ${CI_REGISTRY_IMAGE}:${CACHETAG} + - if [ -f init ]; then chmod 500 init; fi + - echo -n ${CI_COMMIT_SHORT_SHA} > VERSION + - rm -rf vendor/ database/schema database/seeders database/factories/* + - docker build -f docker/Dockerfile -t ${CI_REGISTRY_IMAGE}:${VERSION} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSION} + tags: + - docker + - x86_64 + only: + - BRANCH-2.0 diff --git a/.gitlab-test.yml b/.gitlab-test.yml index cc15968..197572f 100644 --- a/.gitlab-test.yml +++ b/.gitlab-test.yml @@ -1,46 +1,49 @@ test: - image: ${CI_REGISTRY}/leenooks/php:8.0-fpm-latest-test + image: ${CI_REGISTRY}/leenooks/php:8.1-fpm-alpine-ldap-test stage: test # NOTE: This service is dependant on project file configuration, which is not there if the cache was deleted # resulting in the testing to fail on the first run. services: - - name: osixia/openldap:latest - alias: ldap - command: ["--loglevel","debug"] + - name: osixia/openldap:latest + alias: ldap + command: ["--loglevel","debug"] variables: - LDAP_SEED_INTERNAL_LDIF_PATH: "${CI_PROJECT_DIR}/tests/server/openldap/ldif" + LDAP_SEED_INTERNAL_LDIF_PATH: "${CI_PROJECT_DIR}/tests/server/openldap/data" + LDAP_SEED_INTERNAL_SCHEMA_PATH: "${CI_PROJECT_DIR}/tests/server/openldap/schema" LDAP_BASE_DN: "dc=Test" LDAP_DOMAIN: "Test" LDAP_ADMIN_PASSWORD: test -# LDAP_SEED_INTERNAL_SCHEMA_PATH: "${CI_PROJECT_DIR}/tests/server/openldap/schema" LDAP_HOST: ldap LDAP_PORT: 389 + #CI_DEBUG_SERVICES: "true" tags: - - php + - php only: - - BRANCH-2.0 + - BRANCH-2.0 before_script: - - mv .env.testing .env + - mv .env.testing .env - # Install Composer and project dependencies. - - mkdir -p /root/.composer - - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > /root/.composer/auth.json ; fi - - composer install + # Install Composer and project dependencies. + - mkdir -p ${COMPOSER_HOME} + - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > ${COMPOSER_HOME}/auth.json; fi + - composer install - # Generate an application key. Re-cache. - - php artisan key:generate + # Generate an application key. Re-cache. + - php artisan key:generate script: - # run laravel tests - - XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never + # Sleep if we need to, in case we want to jump in and see what is going on during the test + - if [ -n "$DEBUG_PAUSE" ]; then echo "Pausing for $DEBUG_PAUSE seconds, so you can jump into the containers"; sleep $DEBUG_PAUSE; fi + # run laravel tests + - XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never - # run frontend tests - # if you have any task for testing frontend - # set it in your package.json script - # comment this out if you don't have a frontend test - # npm test + # run frontend tests + # if you have any task for testing frontend + # set it in your package.json script + # comment this out if you don't have a frontend test + # npm test