Skip to content
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
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
shell: bash
run: |
echo "TIER_TEST" > tier.txt
./build.sh configure build start
./build.sh configure build start --debug
env:
fail-fast: true

Expand All @@ -37,13 +37,21 @@ jobs:

- name: Check broken links
shell: bash
continue-on-error: false
run: |
set +e;
set +o pipefail;
npx broken-link-checker http://localhost:8055 --ordered --recursive --requests 50 --host-requests 50 -e --filter-level 3 | \
set +e
set +o pipefail
npx broken-link-checker http://localhost:8055 --ordered --recursive --host-requests 50 -e --filter-level 3 | tee blc.log
echo "BLC_RESULT=${PIPESTATUS[0]}" >> "$GITHUB_ENV"

- name: Report on broken links
run: |
set +e
set +o pipefail
cat blc.log | \
grep -E "BROKEN|Getting links from" | \
grep -B 1 "BROKEN"
exit ${PIPESTATUS[0]}
grep -B 1 "BROKEN";
exit "${BLC_RESULT}"

- name: Check PHP errors
shell: bash
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
**/.DS_Store
.idea/
cdn/deploy

tier.txt

# unit test artifacts
blc.log
.phpunit.result.cache

vendor*
.vscode/
node_modules/
Expand Down
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# syntax=docker/dockerfile:1

ARG BUILDER_CONFIGURATION="release"
FROM php:7.4-apache@sha256:c9d7e608f73832673479770d66aacc8100011ec751d1905ff63fae3fe2e0ca6d AS composer-builder

# Install Zip to use composer
Expand All @@ -15,7 +17,14 @@ RUN composer self-update
USER www-data
WORKDIR /composer
COPY composer.* /composer/
RUN composer install
# Consume the build argment
ARG BUILDER_CONFIGURATION
RUN if [ "$BUILDER_CONFIGURATION" = "debug" ]; then \
# composer install --dev deprecated
COMPOSER_NO_DEV=0 composer install ; \
else \
COMPOSER_NO_DEV=1 composer install ; \
fi

# Site
FROM php:7.4-apache@sha256:c9d7e608f73832673479770d66aacc8100011ec751d1905ff63fae3fe2e0ca6d
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ shell, and from this folder, run:
./build.sh build
```

If you'll be running tests locally, the Docker image will need to be built with dev dependencies:

```sh
./build.sh build --debug
```

#### Start the Docker container

To start up the website, in bash, run:
Expand Down Expand Up @@ -101,7 +107,11 @@ In bash, run:

#### Running tests

To check for broken links and .php file conformance, when the site is running,
When the site is running, the test action will do the following:
* PHP unit tests
* Check .php file conformance
* Check for internal broken links

in bash, run:

```sh
Expand Down
23 changes: 20 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,38 @@ builder_parse "$@"
function test_docker_container() {
# Note: ci.yml replicates these

# Run unit tests
echo "TIER_TEST" > tier.txt
set +e;
set +o pipefail;

builder_echo blue "---- PHP unit tests"
docker exec $HELP_CONTAINER_DESC sh -c "vendor/bin/phpunit --testdox"

# Lint .php files for obvious errors
builder_echo blue "---- Lint PHP files"
docker exec $HELP_CONTAINER_DESC sh -c "find . -name '*.php' | grep -v '/vendor/' | xargs -n 1 -d '\\n' php -l"

# Check all internal links
# NOTE: link checker runs on host rather than in docker image
npx broken-link-checker http://localhost:8055 --ordered --recursive --host-requests 10 -e --filter-level 3
builder_echo blue "---- Testing links"
npx broken-link-checker http://localhost:8055 --recursive --ordered ---host-requests 50 -e --filter-level 3 | tee blc.log
local BLC_RESULT=${PIPESTATUS[0]}
echo ----------------------------------------------------------------------
echo Link check summary
echo ----------------------------------------------------------------------
cat blc.log | \
grep -E "BROKEN|Getting links from" | \
grep -B 1 "BROKEN";

builder_echo blue "Done checking links"
rm tier.txt
return "${BLC_RESULT}"
}

builder_run_action configure bootstrap_configure
builder_run_action clean clean_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME
builder_run_action stop stop_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME
builder_run_action build build_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME
builder_run_action build build_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME $BUILDER_CONFIGURATION
builder_run_action start start_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME $HELP_CONTAINER_DESC $HOST_HELP_KEYMAN_COM $PORT_HELP_KEYMAN_COM $BUILDER_CONFIGURATION

builder_run_action test test_docker_container