diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4680701..7359d97 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ stages: cache: key: ${CI_JOB_NAME_SLUG}-${CI_COMMIT_REF_SLUG} paths: - - vendor/ + - vendor/ include: # .gitlab-test.yml diff --git a/.gitlab-test.yml b/.gitlab-test.yml new file mode 100644 index 0000000..e6db94c --- /dev/null +++ b/.gitlab-test.yml @@ -0,0 +1,44 @@ +test: + stage: test + + image: ${CI_REGISTRY}/leenooks/php:8.1-fpm-alpine-test + services: + - postgres:15-alpine + + variables: + POSTGRES_PASSWORD: password + POSTGRES_DB: ate + POSTGRES_INITDB_ARGS: "--data-checksums" + + tags: + - x86_64 + + before_script: + - mv .env.testing .env + + # Install Composer and project dependencies. + - mkdir -p /root/.config/composer + - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > /root/.config/composer/auth.json ; fi + - composer install + - npm install + - npm run build + + # Run database migrations. + - php artisan migrate + + # Run database seed + - php artisan db:seed + + # Start steno + # php -S localhost:8080 -t public & + # node_modules/steno/bin/./steno --replay --app http://localhost:8080 --out-port 3000 --scenario-dir /tests/steno & + + script: + # 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 diff --git a/Dockerfile b/Dockerfile index 3c798aa..898e712 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,10 @@ FROM registry.dege.au/leenooks/php:8.1-fpm-alpine COPY . /var/www/html/ -RUN mkdir /var/cache/composer && \ - ([ -r auth.json ] && mv auth.json /var/cache/composer/) || true && \ +RUN mkdir -p ${COMPOSER_HOME} && \ + ([ -r auth.json ] && mv auth.json ${COMPOSER_HOME}) || true && \ touch .composer.refresh && \ mv .env.example .env && \ - FORCE_PERMS=1 /sbin/init && \ - rm -rf /var/cache/composer/* && \ - touch .migrate && chmod g+w database + FORCE_PERMS=1 NGINX_START=FALSE /sbin/init && \ + touch .migrate && \ + rm -rf ${COMPOSER_HOME}/*