Skip to content

Commit 788b35e

Browse files
authored
Update to use gotestfmt in complement CI (#281)
* Update to use gotestfmt in complement CI * Add failing test * set pipefail * Use a bash shell * Fix test; update README
1 parent 33c8a65 commit 788b35e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
working-directory: homeserver
8383

8484
- run: docker build -t homeserver -f dockerfiles/${{ matrix.homeserver }}.Dockerfile dockerfiles/
85-
- run: go test -p 2 -v -tags "${{ matrix.tags }}" ./tests/...
85+
- run: set -o pipefail && go test -p 2 -v -json -tags "${{ matrix.tags }}" ./tests/... 2>&1 | gotestfmt
86+
shell: bash # required for pipefail to be A Thing. pipefail is required to stop gotestfmt swallowing non-zero exit codes
8687
env:
8788
COMPLEMENT_BASE_IMAGE: homeserver

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ If you're looking to run against a custom Dockerfile, it must meet the following
7676
- The homeserver needs to assume dockerfile `CMD` or `ENTRYPOINT` instructions will be run multiple times.
7777
- The homeserver can use the CA certificate mounted at /ca to create its own TLS cert (see [Complement PKI](README.md#complement-pki)).
7878

79+
### Getting prettier output
80+
81+
The default output isn't particularly nice to read. You can use [gotestfmt](https://github.com/haveyoudebuggedit/gotestfmt)
82+
to make this very pretty. To do so, ask for JSON output via `go test -json` then pipe the output to `gotestfmt`.
83+
If you are doing this in CI, make sure to `set -o pipefail` or else test failures will NOT result in a non-zero exit code
84+
as `gotestfmt`'s exit code (0 as it successfully printed) will replace the previous commands exit code.
85+
See Complement's [Github Actions](https://github.com/matrix-org/complement/blob/master/.github/workflows/ci.yaml) file
86+
for an example of how to do this correctly.
87+
7988
## Writing tests
8089

8190
To get started developing Complement tests, see [the onboarding documentation](ONBOARDING.md).

dockerfiles/ComplementCIBuildkite.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
# This Dockerfile prepares an image with Complement/Docker pre-installed.
55
# This allows users of this image to issue `docker build` commands to build their HS
66
# and then run Complement against it.
7-
FROM golang:1.15-buster
7+
FROM golang:1.17-buster
88
RUN echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/complement.list && apt-get update && apt-get install -y libolm3 libolm-dev/buster-backports
99
RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
1010
ADD https://github.com/matrix-org/complement/archive/master.tar.gz .
1111
RUN tar -xzf master.tar.gz && cd complement-master && go mod download
12+
RUN cd complement-master && go get github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest
1213

1314
VOLUME [ "/ca" ]

0 commit comments

Comments
 (0)