-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.yml
731 lines (685 loc) · 23.1 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
version: 2.1
# To easily configure jobs here, parameters are set up below. Since we are
# typically not calling this workflow via pipelines, consider changing the
# defaults here for any permanent configuration you need to do on a project
# by project basis.
parameters:
run-sec-updates-check:
description: "use to trigger the Autosec process"
type: boolean
default: false
# The value for this variable will be set using a External POST request
# To trigger the Automatic security updates check.
php-version:
description: major.minor version number for php version to use.
type: string
# This value must be only a major.minor version if pantheon is the
# host-variant as the build-tool images do not support major.minor.patch
# version numbers.
default: "8.2"
tz:
description: The timezone definition.
type: string
default: "America/Chicago"
host-variant:
description: A string representing a site's host. EX acquia, pantheon
type: string
default: "pantheon"
docroot:
description: "Where composer installs drupal."
default: "web"
type: string
artifact_workspace:
description: "Where the build stores the built artifact temporarily."
default: "~/project"
type: string
# These are the directories that will be saved between builds and deploys.
# Change these if the list below needs different folders. Directory names are
# relative to the project root.
persisting_dirs: &persisting_dirs
- << pipeline.parameters.docroot >>
- vendor
- drush
- .gitignore
# - node_modules
env: &env
#########################
# MANDITORY CONFIGURATION
#
# Set these either here in your config.yml or in CircleCI project Enviornment
# variables.
#########################
# A github access token so the bot user can comment back on the commit.
#
# GITHUB_TOKEN: 12345678790abcdef
############################
# ACQUIA SPECIFIC SETTINGS
############################
# Acquia git repo url.
#
# ACQUIA_REPO: [email protected]:sitename.git
# Cloud API Realm. Usually "prod" or "devcloud".
#
# See: https://docs.acquia.com/acquia-cloud/api#realm
#
# ACQUIA_REALM: prod
############################
# PANTHEON SPECIFIC SETTINGS
############################
# TERMINUS_TOKEN: The Pantheon machine token
########################
# OPTIONAL CONFIGURATION
########################
# An arbitrary email that will be used as the committer when building the
# artifact.
#
# Default: [email protected]
#
# GIT_EMAIL: [email protected]
# Name of the Acquia or Pantheon site to deploy to.
#
# Default: github repo name
#
# SITE_NAME: my_site
# Environment to get canonical database and files from
#
# Possible Values:
# For Acquia: dev, test prod
# For Pantheon: dev, test, live
#
# Default: "prod" on Acquia. "live" on Pantheon
#
# CANONICAL_ENV: dev
# Script used to sanitize databases. Only used when CANONICAL_ENV is not dev.
#
# Default: empty
#
# SANITIZE_SCRIPT: ./vendor/fourkitchens/pots/scripts/sanitize-db
# Sync Configuration
#
# We can't identify the sync directory here, so we make an assumption
# that if we have the unique (not usually config ignored) system.site.yml
# somewhere in the ./config directory, that you likely want configuration to
# be synced. You can manually turn it off here though.
#
# Possible Values YES, NO
# Default: Yes if Any directory in the ./config directory (inclusive) contains
# system.site.yml. Ex: YES if ./config/system.site.yml or
# ./config/default/system.site.yml or ./config/sync/system.site.yml
# exists.
#
# SYNC_CONFIG: NO
#####################################
# OPTIONAL CONFIGURATION FOR PANTHEON
#####################################
# Build CI multidevs on every commit on Pantheon. This way you get the ci-*
# environments. This may be useful for visual regression testing or workflows
# without PRs.
#
# Possible Values: YES, NO
#
# Default: NO
#
# CI_BUILD: YES
# Define the main branch releases are cut from.
#
# Default: "main" if the branch it exists, "master" otherwise.
#
# MAIN_BRANCH: master
# Define the development branch where active development happens on github.
# This branch is used most in gitflow development patterns.
#
# Default: develop
#
# DEVELOPMENT_BRANCH: dev
# Re-sync content for multidevs every time a push is made to Pantheon.
#
# Possible Values: NO, YES
#
# Default: NO
#
# REBUILD_MULTIDEV_ENV_EVERY_PUSH: YES
# Re-sync content for the Github
# development multidev on Pantheon every time a push is made to
# DEVELOPMENT_BRANCH branch.
#
# Possible Values: NO, YES
#
# Default: NO
#
# REBUILD_DEVELOPMENT_ENV_EVERY_PUSH: YES
# Define the name of the multidev used for the Github development branch. Must
# follow the multidev naming conventions for Pantheon.
#
# Default: github-dev
#
# DEVELOPMENT_ENV: circleci
###########################
# STUFF THAT DOESN'T CHANGE
###########################
HOST_VARIANT: << pipeline.parameters.host-variant >>
DATE_TIMEZONE: << pipeline.parameters.tz >>
DOCROOT: << pipeline.parameters.docroot >>
TERM: xterm
defaults: &defaults
executor:
name: php/default
tag: << pipeline.parameters.php-version >>
working_directory: ~/project
resource_class: small
environment:
<<: *env
jobs:
# Static Testing. This will run independently of a build to fail quickly.
static_tests:
<<: *defaults
steps:
- setup-project
- run:
name: run static tests
command: |
if [ -f "./.circleci/scripts/test/static" ]; then
./.circleci/scripts/test/static
else
./vendor/fourkitchens/pots/scripts/test/static
fi
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
# Job used to create what will be committed to the Artifact.
#
# You will have all the dependency managers installed here in case you need
# them.
build:
<<: *defaults
resource_class: medium+
steps:
- setup-project
- run:
name: run PHP build step
command: |
if [ -f "./.circleci/scripts/build/php" ]; then
./.circleci/scripts/build/php
else
./vendor/fourkitchens/pots/scripts/build/php
fi
- run:
name: run theme build step
command: |
if [ -f "./.circleci/scripts/build/theme" ]; then
./.circleci/scripts/build/theme
else
./vendor/fourkitchens/pots/scripts/build/theme
fi
- persist_to_workspace:
root: .
paths: *persisting_dirs
# Job used to deploy to a remote environment.
#
# This could be as simple as pushing the artifact to a remote git repo or as
# complicated as building a remote environment to push to. This job will not
# be run if the host-variant parameter is set to "pantheon"
deploy:
<<: *defaults
steps:
- restore-project:
workspace_root: << pipeline.parameters.artifact_workspace >>
- run:
name: Deploy the code
command: |
if [ -f "./.circleci/scripts/deploy" ]; then
./.circleci/scripts/deploy
else
./vendor/fourkitchens/pots/scripts/deploy
fi
# Job used to deploy to pantheon.
#
# This job is special because pantheon employs a special docker container and
# the use of terminus with build tools which expect a very specific
# environment configuration. To enable this job, set the host-variant
# parameter to "pantheon".
deploy_to_pantheon:
<<: *defaults
docker:
# quay.io/pantheon-public/build-tools-ci:8.x-php${PHPVERSION}
- image: quay.io/pantheon-public/build-tools-ci:8.x-php<< pipeline.parameters.php-version >>
environment:
<<: *env
TZ: /usr/share/zoneinfo/<< pipeline.parameters.tz >>
TERM: dumb
# BUILD_TOOLS_VERSION: ^2.0.0-alpha4
steps:
- restore-project:
workspace_root: << pipeline.parameters.artifact_workspace >>
# This says "dev" but it also handles Multidev instances too.
- deploy-to-pantheon-env:
environment: 'dev'
deploy_to_pantheon_to_test:
<<: *defaults
docker:
# quay.io/pantheon-public/build-tools-ci:8.x-php${PHPVERSION}
- image: quay.io/pantheon-public/build-tools-ci:8.x-php<< pipeline.parameters.php-version >>
environment:
<<: *env
TZ: /usr/share/zoneinfo/<< pipeline.parameters.tz >>
TERM: dumb
steps:
- deploy-to-pantheon-env:
environment: 'test'
deploy_to_pantheon_to_live:
<<: *defaults
docker:
# quay.io/pantheon-public/build-tools-ci:8.x-php${PHPVERSION}
- image: quay.io/pantheon-public/build-tools-ci:8.x-php<< pipeline.parameters.php-version >>
environment:
<<: *env
TZ: /usr/share/zoneinfo/<< pipeline.parameters.tz >>
TERM: dumb
steps:
- deploy-to-pantheon-env:
environment: 'live'
security_updates_check:
<<: *defaults
docker:
# quay.io/pantheon-public/build-tools-ci:8.x-php${PHPVERSION}
- image: quay.io/pantheon-public/build-tools-ci:8.x-php<< pipeline.parameters.php-version >>
environment:
<<: *env
TZ: /usr/share/zoneinfo/<< pipeline.parameters.tz >>
TERM: dumb
steps:
- run:
name: Upgrade composer
command: composer self-update
- checkout
- php/install-composer
- php/install-packages
- run:
name: setup-environment-vars
command: |
if [ -f "./.circleci/scripts/set-environment" ]; then
./.circleci/scripts/set-environment
else
./vendor/fourkitchens/pots/scripts/set-environment
fi
- add_ssh_keys
- run: composer audit --format=json > /tmp/projects_to_update.json 2>/dev/null || true
- run:
name: Check security updates
command: |
git config --global user.email "[email protected]"
git config --global user.name "CI Bot"
echo "Starting script"
if [ -f "./.circleci/scripts/security-updates/automatic-update" ]; then
cat /tmp/projects_to_update.json | ./.circleci/scripts/security-updates/automatic-update
else
cat /tmp/projects_to_update.json | ./vendor/fourkitchens/pots/scripts/security-updates/automatic-update
fi
echo "Script done"
# Run this on one of the main branches to push a release back to github.
#
# This usually will do things like create a change log and bump the version
# on the source repository.
release:
<<: *defaults
steps:
- setup-project
- run:
name: Publish a Release
command: |
if [ -f "./.circleci/scripts/release" ]; then
./.circleci/scripts/release
else
./vendor/fourkitchens/pots/scripts/release
fi
workflows:
version: 2
scheduled_update_check:
when: << pipeline.parameters.run-sec-updates-check >>
jobs:
- security_updates_check:
filters:
branches:
only:
- 'main'
- 'master'
build-deploy-pantheon:
when:
and:
- equal: [ pantheon, << pipeline.parameters.host-variant >> ]
- equal: [ false, << pipeline.parameters.run-sec-updates-check >> ]
jobs:
- static_tests
- build
# This is doesn't set the branch restraints because multidevs can be
# created using any branch.
- deploy_to_pantheon:
requires:
- static_tests
- build
- approve_deploy_to_test:
type: approval
requires:
- deploy_to_pantheon
filters:
branches:
only:
- 'main'
- 'master'
- deploy_to_pantheon_to_test:
requires:
- approve_deploy_to_test
filters:
branches:
only:
- 'main'
- 'master'
- approve_deploy_to_live:
type: approval
requires:
- deploy_to_pantheon_to_test
filters:
branches:
only:
- 'main'
- 'master'
- deploy_to_pantheon_to_live:
requires:
- approve_deploy_to_live
filters:
branches:
only:
- 'main'
- 'master'
- release:
requires:
- deploy_to_pantheon
filters:
branches:
only:
- 'main'
- 'master'
build-deploy-acquia:
when:
not:
equal: [ pantheon, << pipeline.parameters.host-variant >> ]
jobs:
- static_tests
- build
- deploy:
requires:
- static_tests
- build
filters:
branches:
only:
- main
- master
- develop
- /release-.*/
- release:
requires:
- deploy
filters:
branches:
only:
- 'main'
- 'master'
###### Please do not change things in the commands without contributing back.
node-install-parameters: &node-install-parameters
install-yarn:
default: false
description: Install Yarn?
type: boolean
node-install-dir:
default: /usr/local
description: |
Where should Node.js be installed?
type: string
node-version:
default: ""
description: |
Specify the full version tag to install. To install the latest version, set the version to `latest`. If unspecified, the version listed in .nvmrc will be installed. If no .nvmrc file exists the active LTS version of Node.js will be installed by default. For a full list of releases, see the following: https://nodejs.org/en/download/releases
type: string
yarn-version:
default: ""
description: |
Pick a version of Yarn to install (if no version is specified, the latest stable version will be installed): https://github.com/yarnpkg/yarn/releases
type: string
node-install-packages-parameters: &node-install-packages-parameters
node-app-dir:
default: .
description: >-
Path to the directory containing your package.json file. Not needed if
package.json lives in the root.
type: string
node-cache-only-lockfile:
default: true
description: >
If true, package.json will be ignored in the cache key. Useful for
projects where package.json changes do not always invalidate dependencies.
Note: package.json will still be the final fallback key incase a project
is not configured with a lock file.
type: boolean
node-cache-path:
default: ''
description: >
By default, this orb will utilize 'npm ci' and cache the '~/.npm'
directory. Override which path to cache with this parameter.
type: string
node-cache-version:
default: v1
description: >-
Change the default cache version if you need to clear the cache for any
reason.
type: string
node-check-cache:
default: never
description: |
Yarn berry only for Zero install support -
Use 'always' to always --check-cache argument to yarn install.
Use 'detect' to enable caching of yarn.lock and to only add when required.
enum:
- never
- always
- detect
type: enum
node-include-branch-in-cache-key:
default: true
description: |
If true, this cache bucket will only apply to jobs within the same branch.
type: boolean
node-override-ci-command:
default: ''
description: >
By default, packages will be installed with "npm ci", "yarn install
--frozen-lockfile" or "yarn install --immutable".
Optionally supply a custom package installation command, with any
additional flags needed.
type: string
node-pkg-manager:
default: npm
description: Select the default node package manager to use. NPM v5+ Required.
enum:
- npm
- yarn
- yarn-berry
type: enum
node-with-cache:
default: true
description: Cache your node packages automatically for faster install times.
type: boolean
orbs:
node: circleci/[email protected]
php: circleci/[email protected]
commands:
install-project-dependency-managers:
description: setup composer and npm.
parameters:
<<: *node-install-parameters
steps:
# Most projects require both composer and npm to be installed to do
# anything.
- php/install-composer
- run:
name: Set up Github Token
command: |
# Configure the GitHub Oauth token if it is available
if hash composer 2>/dev/null && [[ -n "$GITHUB_TOKEN" ]]; then
composer -n config --global github-oauth.github.com $GITHUB_TOKEN
fi
- restore_cache:
keys:
- nvm-v2-{{ checksum ".nvmrc" }}
- nvm-v2-
- run:
name: Relink NVM if it was cached.
command: |
# If NVM was cached, we need to hook it up via .bashrc. This will
# allow the node orb to detect nvm being installed and not make
# the nvm install script try to upgrade the existing nvm version.
NVM_DIR="$HOME/.nvm"
if [ -s "$NVM_DIR/nvm.sh" ]; then
echo 'NVM already exists.'
echo 'export NVM_DIR="$HOME/.nvm"' >> "$BASH_ENV";
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use' >> "$BASH_ENV";
fi
- node/install:
install-yarn: << parameters.install-yarn >>
node-install-dir: << parameters.node-install-dir >>
node-version: << parameters.node-version >>
yarn-version: << parameters.yarn-version >>
- save_cache:
key: nvm-v2-{{ checksum ".nvmrc" }}
paths:
- ~/.nvm
- run: node --version
install-project-dependencies:
description: install both npm and composer dependencies
parameters:
<<: *node-install-packages-parameters
steps:
- php/install-packages
- node/install-packages:
app-dir: << parameters.node-app-dir >>
cache-only-lockfile: << parameters.node-cache-only-lockfile >>
cache-path: << parameters.node-cache-path >>
cache-version: << parameters.node-cache-version >>
check-cache: << parameters.node-check-cache >>
include-branch-in-cache-key: << parameters.node-include-branch-in-cache-key >>
override-ci-command: << parameters.node-override-ci-command >>
pkg-manager: << parameters.node-pkg-manager >>
with-cache: << parameters.node-with-cache >>
install-rsync:
description: install rsync
steps:
- run:
name: Install rsync
command: |
if ! command -v rsync &> /dev/null
then
sudo apt-get update -y
sudo apt-get -y install rsync
fi
setup-project:
description: setup php and node and download all dependencies for the project.
parameters:
<<: *node-install-packages-parameters
<<: *node-install-parameters
steps:
- checkout
- install-rsync
- install-project-dependency-managers:
install-yarn: << parameters.install-yarn >>
node-install-dir: << parameters.node-install-dir >>
node-version: << parameters.node-version >>
yarn-version: << parameters.yarn-version >>
- install-project-dependencies:
node-app-dir: << parameters.node-app-dir >>
node-cache-only-lockfile: << parameters.node-cache-only-lockfile >>
node-cache-path: << parameters.node-cache-path >>
node-cache-version: << parameters.node-cache-version >>
node-check-cache: << parameters.node-check-cache >>
node-include-branch-in-cache-key: << parameters.node-include-branch-in-cache-key >>
node-override-ci-command: << parameters.node-override-ci-command >>
node-pkg-manager: << parameters.node-pkg-manager >>
node-with-cache: << parameters.node-with-cache >>
- run:
name: Set up environment variables
command: |
if [ -f "./.circleci/scripts/set-environment" ]; then
./.circleci/scripts/set-environment
elif [ -f "./vendor/fourkitchens/pots/set-environment" ]; then
./vendor/fourkitchens/pots/set-environment
fi
restore-project:
description: Restore a Drupal project that was persisted from another job.
parameters:
workspace_root:
description: "Where to copy the workspace to"
default: "/tmp/build"
type: string
steps:
- checkout
- attach_workspace:
at: << parameters.workspace_root >>
deploy-to-pantheon-env:
description: Do the work to deploy to a pantheon environment.
parameters:
environment:
description: "The environment: dev, test, live. Dev will make accommodations for Multidev workflow"
default: "dev"
type: string
steps:
- restore-project:
workspace_root: << pipeline.parameters.artifact_workspace >>
- run:
name: Prep Terminus Token for Cache Key
command: echo "$TERMINUS_TOKEN" > terminus-cache-key.txt
- restore_cache:
keys:
- terminus-cache-v1-{{ checksum "terminus-cache-key.txt" }}
- terminus-cache-v1-
- run:
name: setup-environment-vars
command: |
if [ -f "./.circleci/scripts/set-environment" ]; then
./.circleci/scripts/set-environment
else
./vendor/fourkitchens/pots/scripts/set-environment
fi
- when:
condition:
and:
- equal: [ dev, << parameters.environment >> ]
steps:
- run:
name: deploy to Pantheon
command: |
if [ -f "./.circleci/scripts/deploy" ]; then
./.circleci/scripts/deploy
else
./vendor/fourkitchens/pots/scripts/pantheon/deploy
fi
no_output_timeout: 30m
- when:
condition:
and:
- not:
equal: [ dev, << parameters.environment >> ]
steps:
- run:
name: deploy to Pantheon
command: |
if [ -f "./.circleci/scripts/deploy-to-<< parameters.environment >>" ]; then
./.circleci/scripts/deploy-to-<< parameters.environment >>
else
./vendor/fourkitchens/pots/scripts/pantheon/deploy-to-<< parameters.environment >>
fi
no_output_timeout: 30m
- save_cache:
key: terminus-cache-v1-{{ checksum "terminus-cache-key.txt" }}
paths:
- ~/.terminus
##### Feel free to alter the tasks below to point to your own tasks.