Skip to content

Commit

Permalink
Merge branch 'dev' into USAGOV-2078-restore-newrelic
Browse files Browse the repository at this point in the history
  • Loading branch information
akf authored Dec 17, 2024
2 parents e89bf39 + 2cd7863 commit f5aafa2
Show file tree
Hide file tree
Showing 21 changed files with 1,174 additions and 399 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ To access the Drupal Portal to make any additional configurations, you will need
Log out as root, and log in with your own user account.
**Note:** You will need to repeat these steps any time you re-load the database from a backup.
**Note:** You will need to repeat these steps any time you re-load the database from a backup.
### Automated tests setup (cypress)
Expand All @@ -183,20 +183,20 @@ We use [Cypress](cypress.io). Note that we use only the Cypress App, _not_ Cypre
* Tests run in the `cypress` Docker container.
* The tests themselves are in the `automated_tests/e2e-cypress` directory.
* Twig debugging will break some of the tests! Turn it off before running tests to get the most accurate results.
* Twig debugging will break some of the tests! Turn it off before running tests to get the most accurate results.
## Minimal setup for headless tests
1. Supply Drupal *credentials* for the automated tests: Edit the file `env.local.cypress`. Supply a valid Drupal user name and password for `cypressCmsUser` and `cypressCmsPass`.
1. Supply Drupal *credentials* for the automated tests: Edit the file `env.local.cypress`. Supply a valid Drupal user name and password for `cypressCmsUser` and `cypressCmsPass`.
2. Run `docker compose up` to (re-)create the cypress container with the new environment variables.
3. Run `bin/cypress-ssh` to open a shell in the cypress container
You can run `npx cypress run --spec cypress/e2e` to run the entire test suite, or specify a smaller subset like `cypress/e2e/functional`.
The **Report** will be written to automated_tests/e2e-cypress/cypress/reports/html/index.html and you can open it in your web browser by navigating to that file and opening it. Cypress will report that it wrote the tests to /app/e2e-cypress/cypress/reports/html/index.html, which is the location of that file in the volume mounted to the cypress docker container.
The **Report** will be written to automated_tests/e2e-cypress/cypress/reports/html/index.html and you can open it in your web browser by navigating to that file and opening it. Cypress will report that it wrote the tests to /app/e2e-cypress/cypress/reports/html/index.html, which is the location of that file in the volume mounted to the cypress docker container.
Note: The first time you run bin/init, it will create the `env.local.cypress` file by copying `env.default.cypress`. The default `cypressBaseUrl` in that file should be correct for running tests against your local dev site.
Expand Down Expand Up @@ -232,7 +232,7 @@ This assumes you're using homebrew.
The "network client" you're enabling this for is the virtual machine running in your cypress container.
4. Reboot your computer. (You need to reboot once after installing XQuartz. Thereafter, when you change your XQuartz settings you need to restart XQuartz, but not reboot.)
4. Reboot your computer. (You need to reboot once after installing XQuartz. Thereafter, when you change your XQuartz settings you need to restart XQuartz, but not reboot.)
Proceed to [Allow cypress to open an X window](#allow-cypress-to-open-an-x-window)
Expand Down Expand Up @@ -320,6 +320,22 @@ If you make any changes to the `scss` or `js` files, make sure to check for lint
[back to top](#usagov-2021)
## Checking PHP Code style and syntax errors
PHPCodesniffer and the parallel linting tools should be installed automatically on a local environment via `composer install`. PHPCodeSniffer is used to ensure new code follows Drupal's coding standard. The parallel linter will check for PHP syntax errors. If they detect any errors, they must be fixed before a PR of changes can be accepted.
The following composer scripts are aliases for running these tools.
* Check for code style errors across all project files. Must have zero errors:
`./bin/composer phpcs-errors`:
* Check for code style errors and warnings across all project files.
`./bin/composer phpcs-strict`
* Check for code style errors in current branch. Must have zero errors:
`./bin/composer phpcs-changes`
* Check for code style errors and warnings in current branch.
`./bin/composer phpcs-changes-strict`
* Check for PHP lint errors
`./bin/composer php-lint`
## Project Restart/Reset
Sometimes, Docker problems arise after an upgrade and a more complete restart is needed. After closing down and destroying the existing containers, networks, and volumes the procedure is the same as the full project setup.
Expand Down
9 changes: 9 additions & 0 deletions bin/changed-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

CURRENT_BRANCH=`git branch --show-current`
# Get the changes between current branch and dev
CHANGED=`git diff --name-only --diff-filter=ARM dev $CURRENT_BRANCH`

if [ "$CURRENT_BRANCH" != "dev" ]; then
echo $CHANGED;
fi
9 changes: 9 additions & 0 deletions bin/composer-reqs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

docker compose run \
--rm \
--no-deps \
--workdir /var/www \
composer \
composer "$@"
15 changes: 6 additions & 9 deletions bin/deploy/git-annotation-parser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ else
exit 1
fi

# just testing?
if [ x$1 == x"--dryrun" ]; then
export echo=echo
shift
fi

SPACE=${1:-please-provide-space-as-first-argument}
SSPACE=$(echo "$SPACE" | tr '[:upper:]' '[:lower:]') ## lowercase, so tags are properly formatted
#assertCurSpace "$SPACE" ### <-- no need to assert that we're actually in $SPACE, because we're not doing anything w/ CF - just git
SPACE=$1
if [ -z "$SPACE" ]; then
echo "First argument must be a valid CF space name"
exit 1
fi;
shift
SSPACE=$(echo "$SPACE" | tr '[:upper:]' '[:lower:]') ## lowercase, so tags are properly formatted

# 1. Find the name of the latest annotated git tag matching our production post-deployment tag format
# 2. Query the content field of the reference attached to the tag, and make sure it contains correctly formated build number and digest hashes
Expand Down
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,29 @@
"drupal/ckeditor_templates"
]
}
},
"require-dev": {
"drupal/coder": "^8.3",
"php-parallel-lint/php-parallel-lint": "^1.4"
},
"scripts": {
"changed-files": [
"bin/changed-files"
],
"phpcs-errors": [
"vendor/bin/phpcs -n --standard=.phpcs.xml.dist"
],
"phpcs-strict": [
"vendor/bin/phpcs --standard=.phpcs.xml.dist"
],
"phpcs-changes": [
"vendor/bin/phpcs -n --standard=.phpcs.xml.dist `bin/changed-files`"
],
"phpcs-changes-strict": [
"vendor/bin/phpcs --standard=.phpcs.xml.dist `bin/changed-files`"
],
"php-lint": [
"vendor/bin/parallel-lint -e php,module,inc,install,test,profile,theme ./web/modules/custom ./web/themes/custom"
]
}
}
Loading

0 comments on commit f5aafa2

Please sign in to comment.