Skip to content

Commit

Permalink
refactor: remove all debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP committed Mar 10, 2024
1 parent d64640d commit 6c8d6f0
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 766 deletions.
121 changes: 102 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,73 @@ concurrency:
cancel-in-progress: true

jobs:
buld_deps:
name: Build dependencies
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
submodules: true

- name: Generate cache key
id: cache_key
run: |
bazel_registry_commit=$(git submodule status ngx_waf_deps | awk '{ print $1 }')
echo "bazel_registry_commit=$bazel_registry_commit" >> "$GITHUB_OUTPUT"
important_files=${{ hashFiles('.bazelrc') }}
important_files=${important_files}-${{ hashFiles('.bazelversion') }}
important_files=${important_files}-${{ hashFiles('BUILD') }}
important_files=${important_files}-${{ hashFiles('MODULE.bazel') }}
important_files=${important_files}-${{ hashFiles('MODULE.bazel.lock') }}
important_files=${important_files}-${{ hashFiles('.github/workflows/test.yml') }}
echo "important_files=$important_files" >> "$GITHUB_OUTPUT"
- name: Lookup build cache
id: cache
uses: actions/cache@v4
with:
key: ${{ steps.cache_key.outputs.important_files }}-${{ steps.cache_key.outputs.bazel_registry_commit }}
path: |
${{ github.workspace }}/deps.tar.gz
- name: Install dependencies
run: |
sudo apt-get --yes update
# https://github.com/actions/runner-images/issues/2139
sudo apt-get remove nginx-core \
nginx-full \
nginx-light \
nginx-extras \
libgd3
sudo apt-get install --yes \
build-essential \
zlib1g-dev \
libpcre3 \
libpcre3-dev \
libssl-dev \
libxslt1-dev \
libxml2-dev \
libgeoip-dev \
libgd-dev \
libperl-dev \
libcurl4-openssl-dev
- name: Build dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
bazel build --registry=file://$(realpath ngx_waf_deps) //:deps
cp bazel-bin/deps.tar.gz .
build_test:
name: Build & Test
runs-on: ubuntu-latest
# container: ${{ matrix.os }}
needs: [buld_deps]

strategy:
matrix:
# os: ["ubuntu:jammy", "debian:buster", "redhat/ubi9"]
nginx-version: ['stable', 'mainline']
module-type: ['static', 'dynamic']

Expand All @@ -43,8 +102,35 @@ jobs:
ref: ${{ github.ref }}
submodules: true

- name: Install dependencies
# if: ${{ startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'debian') }}
- name: Generate cache key
id: cache_key
run: |
bazel_registry_commit=$(git submodule status ngx_waf_deps | awk '{ print $1 }')
echo "bazel_registry_commit=$bazel_registry_commit" >> "$GITHUB_OUTPUT"
important_files=${{ hashFiles('.bazelrc') }}
important_files=${important_files}-${{ hashFiles('.bazelversion') }}
important_files=${important_files}-${{ hashFiles('BUILD') }}
important_files=${important_files}-${{ hashFiles('MODULE.bazel') }}
important_files=${important_files}-${{ hashFiles('MODULE.bazel.lock') }}
important_files=${important_files}-${{ hashFiles('.github/workflows/test.yml') }}
echo "important_files=$important_files" >> "$GITHUB_OUTPUT"
- name: Lookup build cache
id: cache
uses: actions/cache@v4
with:
key: ${{ steps.cache_key.outputs.important_files }}-${{ steps.cache_key.outputs.bazel_registry_commit }}
path: |
${{ github.workspace }}/deps.tar.gz
- name: Unreachable step
if: steps.cache.outputs.cache-hit != 'true'
run: |
echo "Build dependencies cache not found, this step should be unreachable."
exit 1
- name: Install prerequisites
run: |
sudo apt-get --yes update
# https://github.com/actions/runner-images/issues/2139
Expand All @@ -66,22 +152,19 @@ jobs:
libperl-dev \
libcurl4-openssl-dev
- name: Build dependencies
- name: Apply dependencies
run: |
bazel build --registry=file://$(realpath ngx_waf_deps) //:deps
pushd bazel-bin
tar -zxf deps.tar.gz
echo "$(realpath deps/libmodsecurity/lib)" | sudo tee -a /etc/ld.so.conf.d/ngx_waf.conf
echo "$(realpath deps/libsodium/lib)" | sudo tee -a /etc/ld.so.conf.d/ngx_waf.conf
echo "$(realpath deps/libcjson/lib)" | sudo tee -a /etc/ld.so.conf.d/ngx_waf.conf
sudo ldconfig
echo "LIB_MODSECURITY=$(realpath deps/libmodsecurity)" >> "$GITHUB_ENV"
echo "LIB_SODIUM=$(realpath deps/libsodium)" >> "$GITHUB_ENV"
echo "LIB_CJSON=$(realpath deps/libcjson)" >> "$GITHUB_ENV"
echo "LIB_UTHASH=$(realpath deps/uthash)" >> "$GITHUB_ENV"
popd
tar -zxf deps.tar.gz
echo "$(realpath deps/libmodsecurity/lib)" | sudo tee -a /etc/ld.so.conf.d/ngx_waf.conf
echo "$(realpath deps/libsodium/lib)" | sudo tee -a /etc/ld.so.conf.d/ngx_waf.conf
echo "$(realpath deps/libcjson/lib)" | sudo tee -a /etc/ld.so.conf.d/ngx_waf.conf
sudo ldconfig
echo "LIB_MODSECURITY=$(realpath deps/libmodsecurity)" >> "$GITHUB_ENV"
echo "LIB_SODIUM=$(realpath deps/libsodium)" >> "$GITHUB_ENV"
echo "LIB_CJSON=$(realpath deps/libcjson)" >> "$GITHUB_ENV"
echo "LIB_UTHASH=$(realpath deps/uthash)" >> "$GITHUB_ENV"
- name: Download & Build & Install nginx-${{ matrix.nginx-version }}
run: |
Expand Down
43 changes: 0 additions & 43 deletions inc/ngx_http_waf_module_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,47 +359,4 @@
#define ngx_is_null_str(s) ((s) == NULL || (s)->data == NULL || (s)->len == 0 || ((s)->data[0] == '\0' && (s)->len == 1))


#ifndef NGX_HTTP_WAF_NO_DEBUG
#define ngx_http_waf_dp_func_start(r) { \
if (r != NULL) { \
ngx_http_waf_dpf(r, "%s start", __func__); \
} \
}


#define ngx_http_waf_dp(r, str) { \
if (r != NULL) { \
ngx_log_error(NGX_LOG_DEBUG, (r)->connection->log, 0, \
"ngx_waf_debug: ["str"] at %s:%s:%d, ngx_waf %s", __func__, __FILE__, __LINE__, NGX_HTTP_WAF_VERSION); \
} \
}


#define ngx_http_waf_dpf(r, fmt, ...) { \
if (r != NULL) { \
ngx_log_error(NGX_LOG_DEBUG, (r)->connection->log, 0, \
"ngx_waf_debug: ["fmt"] at %s:%s:%d, ngx_waf %s", __VA_ARGS__, __func__, __FILE__, __LINE__, NGX_HTTP_WAF_VERSION); \
} \
}


#define ngx_http_waf_dp_func_end(r) { \
if (r != NULL) { \
ngx_http_waf_dpf(r, "%s end", __func__); \
} \
}
#else
#define ngx_http_waf_dp_func_start(...) {}


#define ngx_http_waf_dp(...) {}


#define ngx_http_waf_dpf(...) {}


#define ngx_http_waf_dp_func_end(...) {}
#endif


#endif // !NGX_HTTP_WAF_MODULE_MACRO_H
Loading

0 comments on commit 6c8d6f0

Please sign in to comment.