-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Github CI and functional tests.
- Loading branch information
Showing
12 changed files
with
340 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: GitHub CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
schedule: | ||
- cron: 0 10 * * Mon | ||
|
||
defaults: | ||
run: | ||
shell: 'bash -Eeuo pipefail -x {0}' | ||
|
||
jobs: | ||
|
||
generate-jobs: | ||
name: Generate Jobs | ||
runs-on: ubuntu-latest | ||
outputs: | ||
strategy: ${{ steps.generate-jobs.outputs.strategy }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: docker-library/bashbrew@v0.1.8 | ||
- id: generate-jobs | ||
name: Generate Jobs | ||
run: | | ||
strategy="$(GITHUB_REPOSITORY=nginx "$BASHBREW_SCRIPTS/github-actions/generate.sh")" | ||
strategy="$(GITHUB_REPOSITORY=nginx "$BASHBREW_SCRIPTS/github-actions/munge-i386.sh" -c <<<"$strategy")" | ||
echo "strategy=$strategy" >> "$GITHUB_OUTPUT" | ||
jq . <<<"$strategy" # sanity check / debugging aid | ||
test: | ||
needs: generate-jobs | ||
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} | ||
name: ${{ matrix.name }} | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Prepare Environment | ||
run: ${{ matrix.runs.prepare }} | ||
- name: Pull Dependencies | ||
run: ${{ matrix.runs.pull }} | ||
- name: Build ${{ matrix.name }} | ||
run: ${{ matrix.runs.build }} | ||
- name: History ${{ matrix.name }} | ||
run: ${{ matrix.runs.history }} | ||
- name: Test ${{ matrix.name }} | ||
run: ${{ matrix.runs.test }} | ||
- name: '"docker images"' | ||
run: ${{ matrix.runs.images }} |
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,9 @@ | ||
imageTests+=( | ||
[nginx]=' | ||
ipv6 | ||
static | ||
templates | ||
templates-resolver | ||
workers | ||
' | ||
) |
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,2 @@ | ||
<h1>Welcome to nginx!</h1> | ||
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf |
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,52 @@ | ||
#!/bin/bash | ||
|
||
[ "$DEBUG" ] && set -x | ||
|
||
set -eo pipefail | ||
|
||
# check if we have ipv6 available | ||
if [ ! -f "/proc/net/if_inet6" ]; then | ||
exit 0 | ||
fi | ||
|
||
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
image="$1" | ||
|
||
clientImage='buildpack-deps:buster-curl' | ||
# ensure the clientImage is ready and available | ||
if ! docker image inspect "$clientImage" &> /dev/null; then | ||
docker pull "$clientImage" > /dev/null | ||
fi | ||
|
||
cid="$(docker run -d "$image")" | ||
trap "docker rm -vf $cid > /dev/null" EXIT | ||
|
||
_request() { | ||
local method="$1" | ||
shift | ||
|
||
local proto="$1" | ||
shift | ||
|
||
local url="${1#/}" | ||
shift | ||
|
||
if [ "$(docker inspect -f '{{.State.Running}}' "$cid" 2>/dev/null)" != 'true' ]; then | ||
echo >&2 "$image stopped unexpectedly!" | ||
( set -x && docker logs "$cid" ) >&2 || true | ||
false | ||
fi | ||
|
||
docker run --rm \ | ||
--link "$cid":nginx \ | ||
"$clientImage" \ | ||
curl -fsSL -X"$method" --connect-to '::nginx:' "$@" "$proto://example.com/$url" | ||
} | ||
|
||
. "$HOME/oi/test/retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]' | ||
|
||
# Check that we can request / | ||
_request GET http '/index.html' | grep '<h1>Welcome to nginx!</h1>' | ||
|
||
docker logs $cid 2>&1 | grep "Enabled listen on IPv6" |
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,46 @@ | ||
#!/bin/bash | ||
|
||
[ "$DEBUG" ] && set -x | ||
|
||
set -eo pipefail | ||
|
||
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
image="$1" | ||
|
||
clientImage='buildpack-deps:buster-curl' | ||
# ensure the clientImage is ready and available | ||
if ! docker image inspect "$clientImage" &> /dev/null; then | ||
docker pull "$clientImage" > /dev/null | ||
fi | ||
|
||
# Create an instance of the container-under-test | ||
cid="$(docker run -d "$image")" | ||
trap "docker rm -vf $cid > /dev/null" EXIT | ||
|
||
_request() { | ||
local method="$1" | ||
shift | ||
|
||
local proto="$1" | ||
shift | ||
|
||
local url="${1#/}" | ||
shift | ||
|
||
if [ "$(docker inspect -f '{{.State.Running}}' "$cid" 2>/dev/null)" != 'true' ]; then | ||
echo >&2 "$image stopped unexpectedly!" | ||
( set -x && docker logs "$cid" ) >&2 || true | ||
false | ||
fi | ||
|
||
docker run --rm \ | ||
--link "$cid":nginx \ | ||
"$clientImage" \ | ||
curl -fsSL -X"$method" --connect-to '::nginx:' "$@" "$proto://example.com/$url" | ||
} | ||
|
||
. "$HOME/oi/test/retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]' | ||
|
||
# Check that we can request / | ||
_request GET http '/index.html' | grep '<h1>Welcome to nginx!</h1>' |
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,51 @@ | ||
#!/bin/bash | ||
|
||
[ "$DEBUG" ] && set -x | ||
|
||
set -eo pipefail | ||
|
||
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
image="$1" | ||
|
||
clientImage='buildpack-deps:buster-curl' | ||
# ensure the clientImage is ready and available | ||
if ! docker image inspect "$clientImage" &> /dev/null; then | ||
docker pull "$clientImage" > /dev/null | ||
fi | ||
|
||
# Create an instance of the container-under-test | ||
serverImage="$("$HOME/oi/test/tests/image-name.sh" librarytest/nginx-template "$image")" | ||
"$HOME/oi/test/tests/docker-build.sh" "$dir" "$serverImage" <<EOD | ||
FROM $image | ||
COPY dir/server.conf.template /etc/nginx/templates/server.conf.template | ||
EOD | ||
cid="$(docker run -d -e NGINX_ENTRYPOINT_LOCAL_RESOLVERS=true -e NGINX_MY_SERVER_NAME=example.com "$serverImage")" | ||
trap "docker rm -vf $cid > /dev/null" EXIT | ||
|
||
_request() { | ||
local method="$1" | ||
shift | ||
|
||
local proto="$1" | ||
shift | ||
|
||
local url="${1#/}" | ||
shift | ||
|
||
if [ "$(docker inspect -f '{{.State.Running}}' "$cid" 2>/dev/null)" != 'true' ]; then | ||
echo >&2 "$image stopped unexpectedly!" | ||
( set -x && docker logs "$cid" ) >&2 || true | ||
false | ||
fi | ||
|
||
docker run --rm \ | ||
--link "$cid":nginx \ | ||
"$clientImage" \ | ||
curl -fsSL -X"$method" --connect-to '::nginx:' "$@" "$proto://example.com/$url" | ||
} | ||
|
||
. "$HOME/oi/test/retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]' | ||
|
||
# Check that we can request / | ||
_request GET http '/resolver-templates' | grep 'example.com - OK' |
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,9 @@ | ||
resolver ${NGINX_LOCAL_RESOLVERS}; | ||
|
||
server { | ||
listen 80; | ||
server_name ${NGINX_MY_SERVER_NAME}; | ||
default_type text/plain; | ||
location = / { return 200 'OK\n'; } | ||
location / { return 200 "${NGINX_MY_SERVER_NAME} - OK\n"; } | ||
} |
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,51 @@ | ||
#!/bin/bash | ||
|
||
[ "$DEBUG" ] && set -x | ||
|
||
set -eo pipefail | ||
|
||
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
image="$1" | ||
|
||
clientImage='buildpack-deps:buster-curl' | ||
# ensure the clientImage is ready and available | ||
if ! docker image inspect "$clientImage" &> /dev/null; then | ||
docker pull "$clientImage" > /dev/null | ||
fi | ||
|
||
# Create an instance of the container-under-test | ||
serverImage="$("$HOME/oi/test/tests/image-name.sh" librarytest/nginx-template "$image")" | ||
"$HOME/oi/test/tests/docker-build.sh" "$dir" "$serverImage" <<EOD | ||
FROM $image | ||
COPY dir/server.conf.template /etc/nginx/templates/server.conf.template | ||
EOD | ||
cid="$(docker run -d -e NGINX_MY_SERVER_NAME=example.com "$serverImage")" | ||
trap "docker rm -vf $cid > /dev/null" EXIT | ||
|
||
_request() { | ||
local method="$1" | ||
shift | ||
|
||
local proto="$1" | ||
shift | ||
|
||
local url="${1#/}" | ||
shift | ||
|
||
if [ "$(docker inspect -f '{{.State.Running}}' "$cid" 2>/dev/null)" != 'true' ]; then | ||
echo >&2 "$image stopped unexpectedly!" | ||
( set -x && docker logs "$cid" ) >&2 || true | ||
false | ||
fi | ||
|
||
docker run --rm \ | ||
--link "$cid":nginx \ | ||
"$clientImage" \ | ||
curl -fsSL -X"$method" --connect-to '::nginx:' "$@" "$proto://example.com/$url" | ||
} | ||
|
||
. "$HOME/oi/test/retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]' | ||
|
||
# Check that we can request / | ||
_request GET http '/templates' | grep 'example.com - OK' |
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,7 @@ | ||
server { | ||
listen 80; | ||
server_name ${NGINX_MY_SERVER_NAME}; | ||
default_type text/plain; | ||
location = / { return 200 'OK\n'; } | ||
location / { return 200 "${NGINX_MY_SERVER_NAME} - OK\n"; } | ||
} |
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,2 @@ | ||
example.com - OK | ||
# Commented out by 30-tune-worker-processes.sh |
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,55 @@ | ||
#!/bin/bash | ||
|
||
[ "$DEBUG" ] && set -x | ||
|
||
set -eo pipefail | ||
|
||
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
image="$1" | ||
|
||
clientImage='buildpack-deps:buster-curl' | ||
# ensure the clientImage is ready and available | ||
if ! docker image inspect "$clientImage" &> /dev/null; then | ||
docker pull "$clientImage" > /dev/null | ||
fi | ||
|
||
# Create an instance of the container-under-test | ||
serverImage="$("$HOME/oi/test/tests/image-name.sh" librarytest/nginx-template "$image")" | ||
"$HOME/oi/test/tests/docker-build.sh" "$dir" "$serverImage" <<EOD | ||
FROM $image | ||
COPY dir/server.conf.template /etc/nginx/templates/server.conf.template | ||
EOD | ||
cid="$(docker run -d -e NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true -e NGINX_MY_SERVER_NAME=example.com "$serverImage")" | ||
trap "docker rm -vf $cid > /dev/null" EXIT | ||
|
||
_request() { | ||
local method="$1" | ||
shift | ||
|
||
local proto="$1" | ||
shift | ||
|
||
local url="${1#/}" | ||
shift | ||
|
||
if [ "$(docker inspect -f '{{.State.Running}}' "$cid" 2>/dev/null)" != 'true' ]; then | ||
echo >&2 "$image stopped unexpectedly!" | ||
( set -x && docker logs "$cid" ) >&2 || true | ||
false | ||
fi | ||
|
||
docker run --rm \ | ||
--link "$cid":nginx \ | ||
"$clientImage" \ | ||
curl -fsSL -X"$method" --connect-to '::nginx:' "$@" "$proto://example.com/$url" | ||
} | ||
|
||
. "$HOME/oi/test/retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]' | ||
|
||
# Check that we can request / | ||
_request GET http '/worker-templates' | grep 'example.com - OK' | ||
|
||
result="$(docker exec $cid grep "Commented out by" /etc/nginx/nginx.conf)" | ||
|
||
echo "$result" | cut -d\ -f 1-5 |
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,7 @@ | ||
server { | ||
listen 80; | ||
server_name ${NGINX_MY_SERVER_NAME}; | ||
default_type text/plain; | ||
location = / { return 200 'OK\n'; } | ||
location / { return 200 "${NGINX_MY_SERVER_NAME} - OK\n"; } | ||
} |