Skip to content

Commit

Permalink
Merge pull request #26 from druxt/upstream
Browse files Browse the repository at this point in the history
chore: rebase from upstream
  • Loading branch information
Decipher authored Sep 29, 2022
2 parents 432e5a9 + 2abc900 commit 8d999d3
Show file tree
Hide file tree
Showing 36 changed files with 26,582 additions and 9,787 deletions.
174 changes: 174 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
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
# @TODO - Circle not seeing NPM
# - run:
# name: Install and build Nuxt
# command: |
# which npm
# cd nuxt && npm install && NUXT_TELEMETRY_DISABLED=1 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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BASE_URL=http://quickstart-druxtsite-tome.ddev.site
OAUTH_CLIENT_ID=2de21d20-7bca-4e31-a3d0-9f0445a79782
100 changes: 100 additions & 0 deletions .github/workflows/test-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: test-preview

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
test_preview:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [16]

steps:
- name: Checkout 🛎
uses: actions/checkout@master

- name: Setup node env 🏗
uses: actions/setup-node@v3.4.1
with:
node-version: ${{ matrix.node }}
check-latest: true

- name: Update npm 🏗
run: |
npm install -g npm
npm --version
- name: Cache node_modules 📦
uses: actions/cache@v3.0.8
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install frontend dependencies 👨🏻‍💻
run: cd nuxt && npm install

- name: Lint code 👀
run: cd nuxt && npm run lint

- name: Create .env 👨🏻‍💻
run: cp .env.example .env
- name: Setup ddev
uses: jonaseberle/github-action-setup-ddev@v1
with:
autostart: false
- name: Start ddev
run: cd drupal && ddev start
- name: Install Drupal 👨🏻‍💻
run: cd drupal && ddev drupal-install

- name: Run unit tests 🧪
run: cd nuxt && npm run test:unit

- name: Generate dist 👨🏻‍💻
run: cd nuxt && NUXT_TARGET=static NUXT_TELEMETRY_DISABLED=1 npm run generate

- name: Run end-to-end tests 🧪
run: cd nuxt && npm run test:e2e

- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v1.2
with:
publish-dir: './nuxt/dist'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: true
enable-commit-comment: true
overwrites-pull-request-comment: true
github-deployment-environment: ${{ github.head_ref }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1

- uses: actions/upload-artifact@v3
with:
name: cypress-videos
path: nuxt/cypress/videos
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: nuxt/cypress/screenshots

- uses: codecov/codecov-action@v3
with:
files: ./nuxt/coverage/clover.xml
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
54 changes: 54 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 25 additions & 8 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,32 @@ image:

tasks:
- init: |
# Installing DDev and Drupal backend.
.gitpod/scripts/ddev-download-images.sh
.gitpod/scripts/ddev-setup.sh
.gitpod/scripts/drupal-setup.sh
# Installing Nuxt/Druxt frontend.
.gitpod/scripts/nuxt-setup.sh
# Setup Gitpod .env
$GITPOD_REPO_ROOT/.gitpod/scripts/env-setup.sh
# Setup DDev
$GITPOD_REPO_ROOT/.gitpod/scripts/ddev-download-images.sh
$GITPOD_REPO_ROOT/.gitpod/scripts/ddev-setup.sh
# Install Drupal
$GITPOD_REPO_ROOT/.gitpod/scripts/drupal-setup.sh
# Installing Nuxt
$GITPOD_REPO_ROOT/.gitpod/scripts/nuxt-setup.sh
command: |
.gitpod/scripts/ddev-setup.sh
.gitpod/scripts/nuxt-setup.sh
# Setup Gitpod .env
$GITPOD_REPO_ROOT/.gitpod/scripts/env-setup.sh
# Start DDev
$GITPOD_REPO_ROOT/.gitpod/scripts/ddev-setup.sh
# Add OAuth2 consumer
cd $GITPOD_REPO_ROOT/drupal && ddev druxt-add-consumer
# Setup Nuxt
$GITPOD_REPO_ROOT/.gitpod/scripts/nuxt-setup.sh
# Start Nuxt
cd $GITPOD_REPO_ROOT/nuxt && NUXT_TELEMETRY_DISABLED=1 npm run dev
# VScode xdebug extension
Expand Down
7 changes: 6 additions & 1 deletion .gitpod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ SHELL ["/bin/bash", "-c"]

RUN sudo apt-get -qq update

# Install cypress dependencies
RUN sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb

# Install ddev
RUN brew update && brew install drud/ddev/ddev

# Install latest composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN sudo php composer-setup.php --install-dir /usr/bin --filename composer
RUN php -r "unlink('composer-setup.php');"

# Install latest npm
RUN npm install -g npm

# Install cypress
RUN npx cypress install
Loading

1 comment on commit 8d999d3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.