-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change gui-tests script to run all steps inside docker containers
- Loading branch information
Showing
6 changed files
with
177 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,9 +65,7 @@ RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar | |
ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}" | ||
ENV NODE_PATH="/node-v14.4.0-linux-x64/lib/node_modules/" | ||
|
||
WORKDIR /build | ||
|
||
RUN mkdir out | ||
WORKDIR /gui-tests | ||
|
||
# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries | ||
# to create a new folder. For reference: | ||
|
@@ -76,6 +74,6 @@ RUN mkdir out | |
# We also specify the version in case we need to update it to go around cache limitations. | ||
RUN npm install -g [email protected] --unsafe-perm=true | ||
|
||
EXPOSE 3000 | ||
COPY . /gui-tests | ||
|
||
CMD ["node", "/build/out/gui-tests/tester.js"] | ||
CMD ["node", "tester.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
## Running gui-tests in docker | ||
|
||
The easiest way to run the gui-tests in a stable environment setup as they | ||
expect is by spinning up a temporary web service with the correct data in | ||
docker. | ||
|
||
This is supported by the `in-docker` script. It has three phases that can be | ||
run, to allow quicker feedback when editing the gui-tests themselves. | ||
|
||
```console | ||
# initialize a temporary database and web service and builds some crates in it | ||
> gui-tests/in-docker init | ||
... | ||
✔ Container docsrs-db-1 Healthy | ||
✔ Container docsrs-s3-1 Healthy | ||
✔ Container docsrs-gui-tests-web-1 Healthy | ||
|
||
# while you have changes to make | ||
# do | ||
# edit your tests | ||
> vim gui-tests/basic.goml | ||
|
||
# run the tests against the temporary web service | ||
> gui-tests/in-docker run | ||
... | ||
Running 2 docs.rs GUI (2 concurrently) ... | ||
.. (2/2) | ||
# done | ||
|
||
# tear down the temporary database and web service | ||
> gui-tests/in-docker cleanup | ||
... | ||
Removed `local/gui-tests` successfully. | ||
``` | ||
|
||
Running with `all` or without an argument will run all steps in sequence, | ||
skipping the cleanup if it fails so you can inspect the failure. Useful if | ||
you've done some other changes and want to run the gui-tests but aren't | ||
expecting them to fail. | ||
|
||
If you are changing the web service or doc builder, take a look in the script at | ||
the steps that `init` takes, you can likely run just one of these steps manually | ||
within your edit-test loop rather than having to fully reinit the setup | ||
(remember to use `--build` to ensure docker-compose rebuilds the image from your | ||
updated source). | ||
|
||
```console | ||
# e.g. after editing the doc builder | ||
docker compose run --build --rm gui-tests-builder build crate sysinfo 0.23.4 | ||
docker compose run --build --rm gui-tests-builder build crate sysinfo 0.23.5 | ||
|
||
# or after editing the web service | ||
docker compose up --build --wait --wait-timeout 10 gui-tests-web | ||
``` | ||
|
||
The web service is also bound onto `localhost:3001` so that you can manually | ||
inspect the pages if necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
run() { | ||
cmd="$1" | ||
shift | ||
printf ' \e[36;1mRunning\e[0m `%q' "$cmd" >&2 | ||
printf ' %q' "$@" >&2 | ||
printf '`\n' >&2 | ||
"$cmd" "$@" | ||
} | ||
|
||
cleanup() { | ||
run docker compose rm --stop --volumes --force gui-tests-web | ||
|
||
run docker compose up --wait --wait-timeout 10 db s3 | ||
|
||
run docker compose exec db dropdb --user cratesfyi gui-tests || true | ||
run docker compose exec s3 mc rb --force local/gui-tests || true | ||
} | ||
|
||
init() { | ||
run docker compose up --wait --wait-timeout 10 db s3 | ||
|
||
run docker compose exec db createdb --user cratesfyi gui-tests | ||
run docker compose exec s3 mc mb local/gui-tests | ||
|
||
# Pre-build the images needed | ||
run docker compose build gui-tests-cli gui-tests-builder gui-tests-web | ||
|
||
# Add the information we need | ||
run docker compose run --rm gui-tests-cli database migrate | ||
run docker compose run --rm gui-tests-builder build update-toolchain | ||
run docker compose run --rm gui-tests-builder build crate sysinfo 0.23.4 | ||
run docker compose run --rm gui-tests-builder build crate sysinfo 0.23.5 | ||
|
||
# Start the web server up | ||
run docker compose up --wait --wait-timeout 10 gui-tests-web | ||
} | ||
|
||
execute() { | ||
run docker compose build gui-tests | ||
run docker compose run --rm gui-tests | ||
} | ||
|
||
case "${1:-all}" | ||
in | ||
cleanup) | ||
cleanup | ||
;; | ||
init) | ||
cleanup | ||
init | ||
;; | ||
run) | ||
execute | ||
;; | ||
all) | ||
cleanup | ||
init | ||
execute | ||
cleanup | ||
;; | ||
*) | ||
echo 'unknown command `'"$1"'`, expected one of [init, run, cleanup, all]' >&2 | ||
exit 1 | ||
;; | ||
esac |