Skip to content

Commit 44d83b8

Browse files
Fix build failures on MacOS by addressing bash compatibility and OpenSSL download issues (#153)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshMcCullough <4859660+JoshMcCullough@users.noreply.github.com>
1 parent b128954 commit 44d83b8

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,20 @@ Once you save your changes to `.vscode/c_cpp_properties.json`, you should see th
192192

193193
### Building and Testing
194194

195+
#### Prerequisites
196+
197+
- Docker and Docker Compose
198+
- For **macOS users**: Bash 4.0+ is required due to the use of associative arrays. macOS ships with Bash 3.2 by default. You can upgrade with:
199+
```shell
200+
# Install a newer bash version
201+
brew install bash
202+
203+
# Update your shell or ensure the scripts use the new bash
204+
export PATH="/opt/homebrew/bin:$PATH" # or /usr/local/bin for Intel Macs
205+
```
206+
207+
#### Available Commands
208+
195209
The `./scripts` file contains multiple commands to make things easy:
196210

197211
| Command | Description |
@@ -234,28 +248,40 @@ The tests use a customized NGINX image, distinct from the main image, as well as
234248

235249
After making changes and finding that some tests fail, it can be difficult to understand why. By default, logs are written to Docker's internal log mechanism, but they won't be persisted after the test run completes and the containers are removed.
236250

237-
If you'd like to persist logs across test runs, you can configure the log driver to use `journald` (on Linux/Unix systems for example). You can do this by setting the environment variable `LOG_DRIVER` before running the tests:
251+
If you'd like to persist logs across test runs, you can configure the log driver. By default, logs use the `json-file` driver for cross-platform compatibility. On Linux systems, you may prefer to use `journald` for better integration with systemd. You can do this by setting the environment variable `LOG_DRIVER` before running the tests:
238252

239253
```shell
240-
# need to rebuild the test runner with the proper log driver
254+
# For Linux systems with systemd (optional)
241255
export LOG_DRIVER=journald
242256

257+
# For other systems or if you prefer file-based logs (default)
258+
export LOG_DRIVER=json-file
259+
243260
# rebuild the test images
244261
./scripts rebuild_test
245262

246263
# run the tests
247264
./scripts test
248265

249266
# check the logs -- adjust the container name as needed
267+
# For journald (Linux systems):
250268
journalctl -eu docker CONTAINER_NAME=nginx-auth-jwt-test-nginx
269+
270+
# For json-file driver (all systems):
271+
docker logs nginx-auth-jwt-test-nginx
251272
```
252273

253-
Now you'll be able to see logs from previous test runs. The best way to make use of this is to open two terminals, one where you run the tests, and one where you follow the logs:
274+
Now you'll be able to see logs from previous test runs. The best way to make use of this is to open two terminals, one where you run the tests, and one where you follow the logs:
254275

255276
```shell
256277
# terminal 1
257278
./scripts test
258279

259-
# terminal 2
280+
# terminal 2 - choose based on your LOG_DRIVER setting:
281+
282+
# For journald:
260283
journalctl -fu docker CONTAINER_NAME=jwt-nginx-test
284+
285+
# For json-file (default):
286+
docker logs -f nginx-auth-jwt-test-nginx
261287
```

openssl.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN <<`
1515
WORKDIR ${SRC_DIR}
1616
RUN <<`
1717
set -ex
18-
curl --silent -LO https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz
18+
curl --silent --location -O https://github.com/openssl/openssl/releases/download/openssl-${SSL_VERSION}/openssl-${SSL_VERSION}.tar.gz
1919
tar -xf openssl-${SSL_VERSION}.tar.gz --strip-components=1
2020
`
2121
RUN ./config --prefix=${OUT_DIR} --openssldir=${OUT_DIR} shared zlib

scripts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/bash -eu
1+
#!/usr/bin/env bash
2+
3+
set -eu
24

35
MAGENTA='\u001b[35m'
46
BLUE='\033[0;34m'

test/docker-compose-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
BASE_IMAGE: ${FULL_IMAGE_NAME}:${NGINX_VERSION:?required}
1212
platform: linux/amd64
1313
logging:
14-
driver: ${LOG_DRIVER:-journald}
14+
driver: ${LOG_DRIVER:-json-file}
1515

1616
runner:
1717
container_name: ${TEST_CONTAINER_NAME_PREFIX:?required}-runner

test/test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/bash -eu
1+
#!/usr/bin/env bash
2+
3+
set -eu
24

35
# set a test # here to execute only that test and output additional info
46
DEBUG=

0 commit comments

Comments
 (0)