Skip to content

Commit c455d71

Browse files
authored
chore: add github actions (#83)
* chore: add nvm config * chore(#81): add poc ci config files * chore: add github workflow * chore: update project * chore: target static * chore: remove lint job * chore: add .env step * chore: disable tests * chore: update .env.example * chore: disable nuxt install in circle * chore: add linting * chore: add unit tests * chore: add end-to-end tests * chore: disable circle e2e job * chore(#81): cypress for gitpod * chore(#81): update nuxt config and tests * chore(#81): add cypress install to dockerfile
1 parent f790a66 commit c455d71

File tree

25 files changed

+23530
-8626
lines changed

25 files changed

+23530
-8626
lines changed

.circleci/config.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
version: 2.1
2+
3+
defaults: &defaults
4+
working_directory: ~/repo
5+
6+
jobs:
7+
build:
8+
<<: *defaults
9+
10+
docker:
11+
- image: php:8.1
12+
13+
steps:
14+
- checkout
15+
16+
- run:
17+
name: Install dependencies
18+
command: |
19+
apt-get update -yqq
20+
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
21+
22+
# Install PHP extensions
23+
docker-php-ext-install mbstring pdo_pgsql curl intl gd xml zip bz2 opcache
24+
25+
# Install Composer
26+
curl -sS https://getcomposer.org/installer | php
27+
28+
# Install NVM and Yarn
29+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
30+
export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use
31+
nvm install && nvm use
32+
npm install --global yarn
33+
34+
- run:
35+
name: Validate and build composer packages
36+
command: |
37+
cd drupal && php ../composer.phar validate && php ../composer.phar install
38+
39+
# @TODO - Circle not seeing NPM
40+
# - run:
41+
# name: Install and build Nuxt
42+
# command: |
43+
# which npm
44+
# cd nuxt && npm install && NUXT_TELEMETRY_DISABLED=1 npm run build
45+
46+
# - run:
47+
# name: Install Codecov
48+
# command: cd nuxt && yarn add codecov
49+
50+
- restore_cache:
51+
keys:
52+
- v1-dependencies-{{ checksum "drupal/composer.json" }}-{{ checksum "nuxt/package.json" }}
53+
# fallback to using the latest cache if no exact match is found.
54+
- v1-dependencies-
55+
56+
# - save_cache:
57+
# paths:
58+
# - drupal/vendor
59+
# - nuxt/node_modules
60+
# key: v1-dependencies-{{ checksum "drupal/composer.json" }}-{{ checksum "nuxt/package.json" }}
61+
62+
- persist_to_workspace:
63+
root: ~/repo
64+
paths:
65+
- .
66+
67+
# lint:
68+
# <<: *defaults
69+
# steps:
70+
# - attach_workspace:
71+
# at: ~/repo
72+
73+
# - run:
74+
# name: Run lint
75+
# command: yarn lint --format ./node_modules/eslint-junit/index.js
76+
# environment:
77+
# ESLINT_JUNIT_OUTPUT: ./reports/junit/eslint.xml
78+
79+
# - run:
80+
# name: Renovate config validator
81+
# command: yarn lint:renovate
82+
83+
# - run:
84+
# name: Bundlewatch
85+
# command: yarn bundlewatch
86+
87+
# test_unit:
88+
# <<: *defaults
89+
# steps:
90+
# - attach_workspace:
91+
# at: ~/repo
92+
93+
# - run:
94+
# name: Run unit tests
95+
# command: yarn test:unit --reporters=jest-junit --runInBand
96+
# environment:
97+
# JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
98+
# NODE_OPTIONS: --max_old_space_size=8192
99+
100+
# - run:
101+
# name: Upload coverage report
102+
# command: yarn dlx codecov
103+
104+
# - store_test_results:
105+
# path: ./reports/junit/
106+
107+
# - store_artifacts:
108+
# path: ./reports/junit
109+
110+
test_e2e:
111+
machine:
112+
image: ubuntu-2004:2022.07.1
113+
working_directory: ~/repo
114+
environment:
115+
DDEV_NONINTERACTIVE: "true"
116+
steps:
117+
- attach_workspace:
118+
at: ~/repo
119+
120+
- run:
121+
name: Install ddev
122+
command: |
123+
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh && bash install_ddev.sh
124+
125+
- run:
126+
name: Setup .env
127+
command: cp .env.example .env
128+
129+
- run:
130+
name: Start server running
131+
command: |
132+
cd drupal && ddev start -y
133+
134+
- run:
135+
name: Install Drupal
136+
command: |
137+
cd drupal && ddev drupal-install
138+
139+
- run:
140+
name: Install cypress
141+
command: npx cypress install
142+
143+
- run:
144+
name: Run end-to-end tests
145+
command: cd nuxt && npm run test:e2e
146+
147+
# - store_artifacts:
148+
# path: ./examples/druxt-site/test/cypress/screenshots
149+
# - store_artifacts:
150+
# path: ./examples/druxt-site/test/cypress/videos
151+
152+
# - run:
153+
# name: Run DruxtJS.org end-to-end tests
154+
# command: yarn docs:test
155+
# - store_artifacts:
156+
# path: ./docs/nuxt/test/cypress/screenshots
157+
# - store_artifacts:
158+
# path: ./docs/nuxt/test/cypress/videos
159+
160+
workflows:
161+
version: 2
162+
163+
build_test:
164+
jobs:
165+
- build
166+
# - lint:
167+
# requires:
168+
# - build
169+
# - test_unit:
170+
# requires:
171+
# - build
172+
# - test_e2e:
173+
# requires:
174+
# - build

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BASE_URL=http://drupal.ddev.site
1+
BASE_URL=http://quickstart-druxtsite.ddev.site
22
OAUTH_CLIENT_ID=2de21d20-7bca-4e31-a3d0-9f0445a79782

.github/workflows/test-preview.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: test-preview
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
13+
jobs:
14+
test_preview:
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest]
20+
node: [16]
21+
22+
steps:
23+
- name: Checkout 🛎
24+
uses: actions/checkout@master
25+
26+
- name: Setup node env 🏗
27+
uses: actions/[email protected]
28+
with:
29+
node-version: ${{ matrix.node }}
30+
check-latest: true
31+
32+
- name: Update npm 🏗
33+
run: |
34+
npm install -g npm
35+
npm --version
36+
- name: Cache node_modules 📦
37+
uses: actions/[email protected]
38+
with:
39+
path: ~/.npm
40+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
41+
restore-keys: |
42+
${{ runner.os }}-node-
43+
- name: Install frontend dependencies 👨🏻‍💻
44+
run: cd nuxt && npm install
45+
46+
- name: Lint code 👀
47+
run: cd nuxt && npm run lint
48+
49+
- name: Create .env 👨🏻‍💻
50+
run: cp .env.example .env
51+
- name: Setup ddev
52+
uses: jonaseberle/github-action-setup-ddev@v1
53+
with:
54+
autostart: false
55+
- name: Start ddev
56+
run: cd drupal && ddev start
57+
- name: Install Drupal 👨🏻‍💻
58+
run: cd drupal && ddev drupal-install
59+
60+
- name: Run unit tests 🧪
61+
run: cd nuxt && npm run test:unit
62+
63+
- name: Generate dist 👨🏻‍💻
64+
run: cd nuxt && NUXT_TARGET=static NUXT_TELEMETRY_DISABLED=1 npm run generate
65+
66+
- name: Run end-to-end tests 🧪
67+
run: cd nuxt && npm run test:e2e
68+
69+
- name: Deploy to Netlify
70+
uses: nwtgck/[email protected]
71+
with:
72+
publish-dir: './nuxt/dist'
73+
production-branch: main
74+
github-token: ${{ secrets.GITHUB_TOKEN }}
75+
deploy-message: "Deploy from GitHub Actions"
76+
enable-pull-request-comment: true
77+
enable-commit-comment: true
78+
overwrites-pull-request-comment: true
79+
github-deployment-environment: ${{ github.head_ref }}
80+
env:
81+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
82+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
83+
timeout-minutes: 1
84+
85+
- uses: actions/upload-artifact@v3
86+
with:
87+
name: cypress-videos
88+
path: nuxt/cypress/videos
89+
- uses: actions/upload-artifact@v3
90+
if: failure()
91+
with:
92+
name: cypress-screenshots
93+
path: nuxt/cypress/screenshots
94+
95+
- uses: codecov/codecov-action@v3
96+
with:
97+
files: ./nuxt/coverage/clover.xml
98+
name: codecov-umbrella
99+
fail_ci_if_error: true
100+
verbose: true

.gitlab-ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
stages:
2+
- build
3+
- test
4+
5+
cache:
6+
paths:
7+
- drupal/vendor/
8+
9+
build:
10+
stage: build
11+
image: php:7.4
12+
before_script:
13+
- apt-get update -yqq
14+
- 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
15+
16+
# Install PHP extensions
17+
- docker-php-ext-install mbstring pdo_pgsql curl intl gd xml zip bz2 opcache
18+
19+
# Install Composer
20+
- curl -sS https://getcomposer.org/installer | php
21+
22+
# Install NVM and Yarn
23+
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
24+
- export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use
25+
- nvm install && nvm use
26+
- npm install --global yarn
27+
28+
script:
29+
# Validate and build composer packages
30+
- cd drupal && php composer.phar validate && php composer.phar install
31+
32+
# Install and build Nuxt
33+
- cd ../nuxt && npm install && npm run build
34+
artifacts:
35+
paths:
36+
- drupal/web
37+
38+
test_e2e:
39+
stage: test
40+
image: drud/ddev-gitpod-base:20220817
41+
dependencies:
42+
- build
43+
services:
44+
- name: docker:dind
45+
alias: dockerdaemon
46+
variables:
47+
DOCKER_HOST: tcp://dockerdaemon:2375/
48+
DOCKER_DRIVER: overlay2
49+
DOCKER_TLS_CERTDIR: ""
50+
before_script:
51+
- sudo chown -R gitpod:gitpod .
52+
script:
53+
# Start DDev and install the Drupal backend.
54+
- cd drupal && ddev start -y && ddev drupal-install

.gitpod/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ SHELL ["/bin/bash", "-c"]
33

44
RUN sudo apt-get -qq update
55

6+
# Install cypress dependencies
7+
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
8+
69
# Install ddev
710
RUN brew update && brew install drud/ddev/ddev
811

912
# Install latest composer
1013
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
11-
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;"
1214
RUN sudo php composer-setup.php --install-dir /usr/bin --filename composer
1315
RUN php -r "unlink('composer-setup.php');"
1416

1517
# Install latest npm
1618
RUN npm install -g npm
19+
20+
# Install cypress
21+
RUN npx cypress install

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16.17.0

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# DruxtSite quickstart - Drupal
22

3+
[![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)
4+
35
> One click, Fully Decoupled Drupal Site starter-kit with Druxt.
46
57
DruxtSite connects Drupal to Nuxt via JSON:API to provide a framework for building a Fully Decoupled site.

drupal/.ddev/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: drupal
1+
name: quickstart-druxtsite
22
type: drupal9
33
docroot: web
4-
php_version: "7.4"
4+
php_version: "8.1"
55
webserver_type: nginx-fpm
66
router_http_port: "80"
77
router_https_port: "443"
@@ -82,7 +82,7 @@ web_environment: []
8282
# Please take care with this because it can cause great confusion.
8383

8484
# upload_dir: custom/upload/dir
85-
# would set the destination path for ddev import-files to <docroot>/custom/upload/dir
85+
# would set the destination path for ddev import-files to <docroot>/custom/upload/dir
8686

8787
# working_dir:
8888
# web: /var/www/html

drupal/web/.htaccess

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ AddEncoding gzip svgz
3232
php_value assert.active 0
3333
</IfModule>
3434

35+
# PHP 8, Apache 1 and 2.
36+
<IfModule mod_php.c>
37+
php_value assert.active 0
38+
</IfModule>
39+
3540
# Requires mod_expires to be enabled.
3641
<IfModule mod_expires.c>
3742
# Enable expirations.

0 commit comments

Comments
 (0)