Skip to content

Commit

Permalink
ci: add TEST_MODE environment for test all configurations (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd authored Nov 8, 2024
2 parents e381706 + 333b069 commit c55a1de
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
run: |
echo "Running tests for ${{matrix.path}}"
docker run --rm ${{env.USER}}/${{matrix.path}}:test /etc/nginx/entrypoint.sh nginx -t
docker run --rm -e TEST_MODE=1 ${{env.USER}}/${{matrix.path}}:test /etc/nginx/entrypoint.sh nginx -T -c /etc/nginx/nginx.conf
- name: 🚀 Build and publish container image
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
Expand Down
5 changes: 3 additions & 2 deletions nginx-core/etc/nginx/entrypoint.d/91-force-domain.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/sh
set -eu

ME=$(basename "$0")

# FIXME: nginx: [emerg] invalid condition "$host" in 40-force-domain.conf:1 (its work perfectly in production!)
# test -n "${TEST_MODE:-}" && exit 0
test -n "${NGINX_FORCE_DOMAIN:-}" && exit 0

ME=$(basename "$0")
echo "$ME: Remove force domain location config"
rm -fv /etc/nginx/conf.d/location.d/40-force-domain.conf

Expand Down
4 changes: 2 additions & 2 deletions nginx-core/etc/nginx/entrypoint.d/92-auto-webp.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
set -eu

ME=$(basename "$0")

test -n "${TEST_MODE:-}" && exit 0
test -n "${NGINX_AUTO_WEBP:-}" && exit 0

ME=$(basename "$0")
echo "$ME: Remove auto webp config"
rm -fv /etc/nginx/conf.d/http.d/42-map-webp.conf
rm -fv /etc/nginx/conf.d/location.d/60-webp.conf
Expand Down
4 changes: 2 additions & 2 deletions nginx-core/etc/nginx/entrypoint.d/93-cors.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
set -eu

ME=$(basename "$0")

test -n "${TEST_MODE:-}" && exit 0
test -n "${NGINX_CORS_ENABLE:-}" && exit 0

ME=$(basename "$0")
echo "$ME: Remove CORS config"
rm -fv /etc/nginx/conf.d/location.d/70-cors.conf

Expand Down
18 changes: 10 additions & 8 deletions nginx-core/etc/nginx/templates/location.d/70-cors.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS;
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS;
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE;

if ($request_method = 'OPTIONS') {
location / {
# Handle OPTIONS requests (preflight requests for complex requests)
add_header 'Access-Control-Allow-Origin' $NGINX_CORS_ORIGIN;
add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS;
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS;
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' $NGINX_CORS_ORIGIN;
add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS;
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS;
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;

return 204;
return 204;
}
}

0 comments on commit c55a1de

Please sign in to comment.