Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a root job for composer update #26

Merged
merged 18 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

* A single job is now used to initialize composer, and it's results are used to
seed all of the individual test jobs.
[#26](https://github.com/deviantintegral/drupal_tests/pull/26/files)

### Changed

### Fixed
Expand Down
9 changes: 4 additions & 5 deletions hooks/code-coverage-stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ export SIMPLETEST_BASE_URL="http://localhost"
export SIMPLETEST_DB="sqlite://localhost//tmp/drupal.sqlite"
export BROWSERTEST_OUTPUT_DIRECTORY="/var/www/html/sites/simpletest"

robo setup:skeleton

robo add:modules $1

robo update:dependencies
if [ ! -f dependencies_updated ]
then
./update-dependencies.sh $1
fi

robo override:phpunit-config $1

Expand Down
11 changes: 4 additions & 7 deletions hooks/code-sniffer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

# Runs CodeSniffer checks on a Drupal module.

robo setup:skeleton

robo add:coding-standards-deps

robo add:modules $1

robo update:dependencies
if [ ! -f dependencies_updated ]
then
./update-dependencies.sh $1
fi

# Install dependencies and configure phpcs
vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer
Expand Down
12 changes: 7 additions & 5 deletions hooks/test-js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
#
# Runs Behat tests.

if [ ! -f dependencies_updated ]
then
./update-dependencies.sh $1
fi

# This is the command used by the base image to serve Drupal.
apache2-foreground&

robo add:behat-deps

robo add:modules $1

robo update:dependencies
# Wait for the mariadb container to come up.
while ! mysqladmin ping --silent -h127.0.0.1; do sleep 1; done

robo setup:drupal || true

Expand Down
10 changes: 5 additions & 5 deletions hooks/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export SIMPLETEST_BASE_URL="http://localhost"
export SIMPLETEST_DB="sqlite://localhost//tmp/drupal.sqlite"
export BROWSERTEST_OUTPUT_DIRECTORY="/var/www/html/sites/simpletest"

if [ ! -f dependencies_updated ]
then
./update-dependencies.sh $1
fi

# This is the command used by the base image to serve Drupal.
apache2-foreground&

robo setup:skeleton
robo add:modules $1

robo update:dependencies

robo override:phpunit-config $1

sudo -E -u www-data vendor/bin/phpunit -c core --group $1 --debug --verbose --log-junit artifacts/phpunit/phpunit.xml
10 changes: 10 additions & 0 deletions hooks/update-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -ex

robo setup:skeleton
robo add:modules $1
robo update:dependencies

# Touch a flag so we know dependencies have been set. Otherwise, there is no
# easy way to know this step needs to be done when running circleci locally since
# it does not support workflows.
touch dependencies_updated
68 changes: 49 additions & 19 deletions templates/circleci-2.0/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,47 @@ defaults: &defaults
# We use the composer.json as a way to determine if we can cache our build.
restore_cache: &restore_cache
keys:
- v1-dependencies-{{ checksum "composer.json" }}
- v3-dependencies-{{ checksum "composer.json" }}-{{ checksum "../../composer.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v3-dependencies-

# If composer.json hasn't changed, restore the vendor directory. We don't
# restore the lock file so we ensure we get updated dependencies.
save_cache: &save_cache
paths:
- ./vendor
key: v1-dependencies-{{ checksum "composer.json" }}
- ../../vendor
key: v3-dependencies-{{ checksum "composer.json" }}-{{ checksum "../../composer.json" }}

# Run Drupal unit and kernel tests as one job. This command invokes the test.sh
# hook.
unit_kernel_tests: &unit_kernel_tests
# Install composer dependencies into the workspace to share with all jobs.
update_dependencies: &update_dependencies
<<: *defaults
steps:
- checkout

- restore_cache: *restore_cache

- run:
working_directory: /var/www/html
command: |
./update-dependencies.sh $CIRCLE_PROJECT_REPONAME

- save_cache: *save_cache

- persist_to_workspace:
root: /var/www/html
paths:
- .

# Run Drupal unit and kernel tests as one job. This command invokes the test.sh
# hook.
unit_kernel_tests: &unit_kernel_tests
<<: *defaults
steps:
- attach_workspace:
at: /var/www/html

- checkout

- run:
working_directory: /var/www/html
command: |
Expand All @@ -79,10 +99,10 @@ unit_kernel_tests: &unit_kernel_tests
behat_tests: &behat_tests
<<: *defaults
steps:
- checkout
- attach_workspace:
at: /var/www/html

- restore_cache: *restore_cache
- save_cache: *save_cache
- checkout

- run:
working_directory: /var/www/html
Expand All @@ -98,10 +118,10 @@ behat_tests: &behat_tests
code_sniffer: &code_sniffer
<<: *defaults
steps:
- checkout
- attach_workspace:
at: /var/www/html

- restore_cache: *restore_cache
- save_cache: *save_cache
- checkout

- run:
working_directory: /var/www/html
Expand All @@ -117,10 +137,10 @@ code_sniffer: &code_sniffer
code_coverage: &code_coverage
<<: *defaults
steps:
- checkout
- attach_workspace:
at: /var/www/html

- restore_cache: *restore_cache
- save_cache: *save_cache
- checkout

- run:
working_directory: /var/www/html
Expand All @@ -132,6 +152,8 @@ code_coverage: &code_coverage
# Declare all of the jobs we should run.
version: 2
jobs:
update-dependencies:
<<: *update_dependencies
run-unit-kernel-tests:
<<: *unit_kernel_tests
run-behat-tests:
Expand All @@ -147,9 +169,17 @@ workflows:
# Declare a workflow that runs all of our jobs in parallel.
test_and_lint:
jobs:
- run-unit-kernel-tests
- run-behat-tests
- run-code-sniffer
- update-dependencies
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

- run-unit-kernel-tests:
requires:
- update-dependencies
- run-behat-tests:
requires:
- update-dependencies
- run-code-sniffer:
requires:
- update-dependencies
- run-code-coverage:
requires:
- update-dependencies
- run-unit-kernel-tests