From 6c2e5bfc84a8180db315dea9344e82967b487702 Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Fri, 2 Sep 2022 00:48:59 +0000 Subject: [PATCH] chore(#81): add poc ci config files --- .circleci/config.yml | 177 +++++++++++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 54 +++++++++++++ README.md | 2 + nuxt/package.json | 5 +- 4 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .gitlab-ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..32aef88 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,177 @@ +version: 2.1 + +defaults: &defaults + working_directory: ~/repo + +jobs: + build: + <<: *defaults + + docker: + - image: php:8.1 + + steps: + - checkout + + - run: + name: Install dependencies + command: | + apt-get update -yqq + apt-get install -yqq git libpq-dev libcurl4-gnutls-dev libicu-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev libonig-dev libzip-dev nodejs + + # Install PHP extensions + docker-php-ext-install mbstring pdo_pgsql curl intl gd xml zip bz2 opcache + + # Install Composer + curl -sS https://getcomposer.org/installer | php + + # Install NVM and Yarn + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash + export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use + nvm install && nvm use + npm install --global yarn + + - run: + name: Validate and build composer packages + command: | + cd drupal && php ../composer.phar validate && php ../composer.phar install + + - run: + name: Install and build Nuxt + command: | + . $BASH_ENV + which npm + which nmv + npm --version + nvm --version + cd nuxt && npm install && npm run build + + # - run: + # name: Install Codecov + # command: cd nuxt && yarn add codecov + + - restore_cache: + keys: + - v1-dependencies-{{ checksum "drupal/composer.json" }}-{{ checksum "nuxt/package.json" }} + # fallback to using the latest cache if no exact match is found. + - v1-dependencies- + + - save_cache: + paths: + - drupal/vendor + - nuxt/node_modules + key: v1-dependencies-{{ checksum "drupal/composer.json" }}-{{ checksum "nuxt/package.json" }} + + - persist_to_workspace: + root: ~/repo + paths: + - . + + # lint: + # <<: *defaults + # steps: + # - attach_workspace: + # at: ~/repo + + # - run: + # name: Run lint + # command: yarn lint --format ./node_modules/eslint-junit/index.js + # environment: + # ESLINT_JUNIT_OUTPUT: ./reports/junit/eslint.xml + + # - run: + # name: Renovate config validator + # command: yarn lint:renovate + + # - run: + # name: Bundlewatch + # command: yarn bundlewatch + + # test_unit: + # <<: *defaults + # steps: + # - attach_workspace: + # at: ~/repo + + # - run: + # name: Run unit tests + # command: yarn test:unit --reporters=jest-junit --runInBand + # environment: + # JEST_JUNIT_OUTPUT_DIR: ./reports/junit/ + # NODE_OPTIONS: --max_old_space_size=8192 + + # - run: + # name: Upload coverage report + # command: yarn dlx codecov + + # - store_test_results: + # path: ./reports/junit/ + + # - store_artifacts: + # path: ./reports/junit + + test_e2e: + machine: + image: ubuntu-2004:2022.07.1 + working_directory: ~/repo + environment: + DDEV_NONINTERACTIVE: "true" + steps: + - attach_workspace: + at: ~/repo + + - run: + name: Install ddev + command: | + curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh && bash install_ddev.sh + + - run: + name: Setup .env + command: cp .env.example .env + + - run: + name: Start server running + command: | + cd drupal && ddev start -y + + - run: + name: Install Drupal + command: | + cd drupal && ddev drupal-install + + - run: + name: Install cypress + command: npx cypress install + + - run: + name: Run end-to-end tests + command: cd nuxt && npm run test:e2e + + # - store_artifacts: + # path: ./examples/druxt-site/test/cypress/screenshots + # - store_artifacts: + # path: ./examples/druxt-site/test/cypress/videos + + # - run: + # name: Run DruxtJS.org end-to-end tests + # command: yarn docs:test + # - store_artifacts: + # path: ./docs/nuxt/test/cypress/screenshots + # - store_artifacts: + # path: ./docs/nuxt/test/cypress/videos + +workflows: + version: 2 + + build_test: + jobs: + - build + # - lint: + # requires: + # - build + # - test_unit: + # requires: + # - build + - test_e2e: + requires: + - build diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d6a7dd2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,54 @@ +stages: + - build + - test + +cache: + paths: + - drupal/vendor/ + +build: + stage: build + image: php:7.4 + before_script: + - apt-get update -yqq + - apt-get install -yqq git libpq-dev libcurl4-gnutls-dev libicu-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev libonig-dev libzip-dev nodejs + + # Install PHP extensions + - docker-php-ext-install mbstring pdo_pgsql curl intl gd xml zip bz2 opcache + + # Install Composer + - curl -sS https://getcomposer.org/installer | php + + # Install NVM and Yarn + - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash + - export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use + - nvm install && nvm use + - npm install --global yarn + + script: + # Validate and build composer packages + - cd drupal && php composer.phar validate && php composer.phar install + + # Install and build Nuxt + - cd ../nuxt && npm install && npm run build + artifacts: + paths: + - drupal/web + +test_e2e: + stage: test + image: drud/ddev-gitpod-base:20220817 + dependencies: + - build + services: + - name: docker:dind + alias: dockerdaemon + variables: + DOCKER_HOST: tcp://dockerdaemon:2375/ + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + before_script: + - sudo chown -R gitpod:gitpod . + script: + # Start DDev and install the Drupal backend. + - cd drupal && ddev start -y && ddev drupal-install diff --git a/README.md b/README.md index e56c15c..22d95d8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # DruxtSite quickstart - Drupal +[![CircleCI](https://dl.circleci.com/status-badge/img/gh/druxt/quickstart-druxt-site/tree/develop.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/druxt/quickstart-druxt-site/tree/develop) + > One click, Fully Decoupled Drupal Site starter-kit with Druxt. DruxtSite connects Drupal to Nuxt via JSON:API to provide a framework for building a Fully Decoupled site. diff --git a/nuxt/package.json b/nuxt/package.json index c899aa1..6f0311a 100644 --- a/nuxt/package.json +++ b/nuxt/package.json @@ -3,10 +3,11 @@ "version": "1.0.0", "private": true, "scripts": { - "dev": "nuxt", "build": "nuxt build", + "dev": "nuxt", + "generate": "nuxt generate", "start": "nuxt start", - "generate": "nuxt generate" + "test:e2e": "echo 'test'" }, "dependencies": { "core-js": "3.25.0",