diff --git a/.github/actions/setup-echo-server/action.yml b/.github/actions/setup-echo-server/action.yml new file mode 100644 index 000000000..d946684d5 --- /dev/null +++ b/.github/actions/setup-echo-server/action.yml @@ -0,0 +1,59 @@ +name: setup-echo-server +decription: | + This action sets up an echo server associating a name to it. + The name, e.g. `httpbin.org`, will be resolved to 127.0.0.1 by dnsmasq. + +inputs: + upstream_dns_server: + description: 'DNS server used by dnsmasq to resolve entries not yet cached' + required: false + default: '1.1.1.1' + echo_server_name: + description: 'A name dnsmasq will resolve to 127.0.0.1, e.g.: httpbin.org' + required: false + +runs: + using: "composite" + steps: + - run: sudo apt-get install -y dnsmasq + if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-22.04' }} + shell: bash + - run: brew install dnsmasq + if: ${{ matrix.os == 'macos-latest' }} + shell: bash + + - run: | + sudo systemctl stop systemd-resolved + sudo dnsmasq --no-hosts \ + --no-resolv \ + --server=${{ inputs.upstream_dns_server }} \ + --address=/${{ inputs.echo_server_name }}/127.0.0.1 + shell: bash + - run: | + cat <> /tmp/nginx.conf + server { + listen 80; + server_name '${{ inputs.echo_server_name }}'; + + listen 443 ssl; + server_name '${{ inputs.echo_server_name }}'; + ssl_protocols TLSv1.2; + ssl_certificate /etc/nginx/hostname_cert.pem; + ssl_certificate_key /etc/nginx/hostname_key.pem; + + location / { + proxy_pass http://httpbin; + } + } + EOT + + docker run --name httpbin -d kennethreitz/httpbin + docker run --name httpbin_proxy \ + --link httpbin \ + -p 80:80 \ + -p 443:443 \ + -v /tmp/nginx.conf:/etc/nginx/nginx.conf.d/httpbin.conf:ro \ + -v ./t/data/hostname_cert.pem:/etc/nginx/hostname_cert.pem:ro \ + -v ./t/data/hostname_key.pem:/etc/nginx/hostname_key.pem:ro \ + -d nginx + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 461280ea9..f5b13a9b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,79 +27,80 @@ jobs: wasmer: [3.1.1] v8: [""] ssl: [ssl] - debug: [debug, no_debug] + # debug: [debug, no_debug] + debug: [debug] hup: [no_hup] module_type: ["static"] - include: - # Wasmtime - - runtime: wasmtime - wasmtime: 8.0.1 - os: ubuntu-latest - cc: gcc-9 - ngx: 1.25.1 - ssl: ssl - debug: debug - hup: hup - # V8 - - runtime: v8 - v8: 11.4.183.23 - os: ubuntu-latest - cc: gcc-9 - ngx: 1.25.1 - ssl: ssl - debug: debug - hup: no_hup - # Old Nginx - - label: old_nginx - os: ubuntu-latest - cc: gcc-9 - ngx: 1.21.6 - runtime: wasmer - wasmer: 3.1.1 - ssl: ssl - debug: debug - hup: no_hup - # Nginx + dynamic ngx_wasm_module + HUP - - label: dynamic_nginx - os: ubuntu-latest - cc: gcc-9 - ngx: 1.25.1 - runtime: wasmtime - wasmtime: 8.0.1 - ssl: ssl - debug: debug - hup: hup - module_type: dynamic - # No SSL - - os: ubuntu-latest - cc: gcc-9 - ngx: 1.25.1 - runtime: wasmer - wasmer: 3.1.1 - ssl: no_ssl - debug: no_debug - hup: no_hup - # OpenResty - - label: openresty - os: ubuntu-latest - cc: gcc-9 - openresty: 1.21.4.1 - runtime: wasmtime - wasmtime: 8.0.1 - ssl: ssl - debug: debug - hup: no_hup - # OpenResty + dynamic ngx_wasm_module - - label: dynamic_openresty - os: ubuntu-latest - cc: gcc-9 - openresty: 1.21.4.1 - runtime: wasmtime - wasmtime: 8.0.1 - ssl: ssl - debug: debug - hup: no_hup - module_type: dynamic + # include: + # # Wasmtime + # - runtime: wasmtime + # wasmtime: 8.0.1 + # os: ubuntu-latest + # cc: gcc-9 + # ngx: 1.25.1 + # ssl: ssl + # debug: debug + # hup: hup + # # V8 + # - runtime: v8 + # v8: 11.4.183.23 + # os: ubuntu-latest + # cc: gcc-9 + # ngx: 1.25.1 + # ssl: ssl + # debug: debug + # hup: no_hup + # # Old Nginx + # - label: old_nginx + # os: ubuntu-latest + # cc: gcc-9 + # ngx: 1.21.6 + # runtime: wasmer + # wasmer: 3.1.1 + # ssl: ssl + # debug: debug + # hup: no_hup + # # Nginx + dynamic ngx_wasm_module + HUP + # - label: dynamic_nginx + # os: ubuntu-latest + # cc: gcc-9 + # ngx: 1.25.1 + # runtime: wasmtime + # wasmtime: 8.0.1 + # ssl: ssl + # debug: debug + # hup: hup + # module_type: dynamic + # # No SSL + # - os: ubuntu-latest + # cc: gcc-9 + # ngx: 1.25.1 + # runtime: wasmer + # wasmer: 3.1.1 + # ssl: no_ssl + # debug: no_debug + # hup: no_hup + # # OpenResty + # - label: openresty + # os: ubuntu-latest + # cc: gcc-9 + # openresty: 1.21.4.1 + # runtime: wasmtime + # wasmtime: 8.0.1 + # ssl: ssl + # debug: debug + # hup: no_hup + # # OpenResty + dynamic ngx_wasm_module + # - label: dynamic_openresty + # os: ubuntu-latest + # cc: gcc-9 + # openresty: 1.21.4.1 + # runtime: wasmtime + # wasmtime: 8.0.1 + # ssl: ssl + # debug: debug + # hup: no_hup + # module_type: dynamic uses: ./.github/workflows/job-unit-tests.yml with: os: ${{ matrix.os }} @@ -129,161 +130,161 @@ jobs: parallel-finished: true carryforward: 'unit-ngx_1.25.1-wasmer-ssl-debug-no_hup-static,unit-ngx_1.25.1-wasmer-ssl-no_debug-no_hup-static,unit-ngx_1.25.1-wasmtime-ssl-debug-hup-static,unit-ngx_1.25.1-wasmtime-ssl-debug-hup-dynamic,unit-ngx_1.25.1-v8-ssl-debug-no_hup-static,unit-ngx_1.21.6-wasmer-ssl-debug-no_hup-static,unit-ngx_1.25.1-wasmer-no_ssl-no_debug-no_hup-static,unit-openresty_1.21.4.1-wasmtime-ssl-debug-no_hup-static,unit-openresty_1.21.4.1-wasmtime-ssl-debug-no_hup-dynamic' - valgrind: - name: 'Valgrind' - #if: ${{ false }} - strategy: - fail-fast: false - matrix: - label: [""] - os: [ubuntu-22.04] - cc: [gcc-10] - ngx: [1.25.1] - openresty: [""] - runtime: [wasmer] - wasmtime: [""] - wasmer: [3.1.1] - v8: [""] - hup: [no_hup, hup] - debug: [debug] - include: - # Wasmtime - - runtime: wasmtime - wasmtime: 8.0.1 - os: ubuntu-22.04 - cc: gcc-10 - ngx: 1.25.1 - hup: no_hup - debug: debug - # V8 - - runtime: v8 - v8: 11.4.183.23 - os: ubuntu-22.04 - cc: gcc-10 - ngx: 1.25.1 - debug: debug - hup: no_hup - # OpenResty - - label: openresty - os: ubuntu-22.04 - cc: gcc-10 - openresty: 1.21.4.1 - ngx: - runtime: wasmer - wasmer: 3.1.1 - debug: debug - hup: no_hup - uses: ./.github/workflows/job-valgrind-tests.yml - with: - os: ${{ matrix.os }} - cc: ${{ matrix.cc }} - ngx: ${{ matrix.ngx }} - openresty: ${{ matrix.openresty }} - runtime: ${{ matrix.runtime }} - wasmtime: ${{ matrix.wasmtime }} - wasmer: ${{ matrix.wasmer }} - v8: ${{ matrix.v8 }} - hup: ${{ matrix.hup }} - debug: ${{ matrix.debug }} - - lint: - name: 'Lint' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - components: clippy - - uses: actions/cache@v3 - if: ${{ !env.ACT }} - with: - path: | - work/downloads - key: lint-${{ runner.os }}-${{ hashFiles('util/**/*.sh', 'util/**/*.pl', 'util/**/*.awk', '.github/**/*.yml', '.github/**/*.sh', '.github/**/*.js', 'rust-toolchain') }} - - run: make setup - - run: make lint - - uses: actions-rs/clippy-check@v1 - if: ${{ !env.ACT }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features - - run: | - if [[ $(make reindex 2>&1 | tee reindex.out | grep -c done) -gt 0 ]]; then - cat reindex.out >&2 - exit 1 - fi - - analyzer: - name: 'Clang analyzer' - strategy: - fail-fast: false - matrix: - cc: [clang-11] - openresty: [1.21.4.1] - runtime: [wasmtime, wasmer, v8] - wasmtime: [8.0.1] - wasmer: [3.1.1] - v8: [11.4.183.23] - ssl: [ssl] - debug: [debug, no_debug] - include: - # No SSL - - os: ubuntu-latest - cc: clang-11 - ngx: 1.25.1 - runtime: wasmer - wasmer: 3.1.1 - ssl: no_ssl - debug: debug - uses: ./.github/workflows/job-clang-analyzer.yml - with: - cc: ${{ matrix.cc }} - ngx: ${{ matrix.ngx }} - openresty: ${{ matrix.openresty }} - runtime: ${{ matrix.runtime }} - wasmtime: ${{ matrix.wasmtime }} - wasmer: ${{ matrix.wasmer }} - v8: ${{ matrix.v8 }} - ssl: ${{ matrix.ssl }} - debug: ${{ matrix.debug }} - - build: - name: 'Test builds' - #if: ${{ false }} - runs-on: ${{ matrix.os }} - timeout-minutes: 45 - strategy: - fail-fast: false - matrix: - label: [""] - os: [ubuntu-latest] - cc: [clang-14, gcc-10] - ngx: [1.25.1] - runtime: [wasmtime, wasmer, v8] - wasmtime: [8.0.1] - wasmer: [3.1.1] - v8: [11.4.183.23] - include: - - label: old_nginx - os: ubuntu-latest - cc: clang-14 - ngx: 1.21.6 - runtime: wasmtime - wasmtime: 8.0.1 - steps: - - uses: actions/checkout@v3 - - name: 'Setup cache - work/ dir' - uses: actions/cache@v3 - if: ${{ !env.ACT }} - with: - path: | - work/downloads - work/runtimes - work/openssl - key: work-${{ runner.os }}-${{ matrix.cc }}-${{ matrix.ngx }}-${{ matrix.openresty }}-${{ matrix.runtime }}-${{ hashFiles('util/**/*.sh', 'util/**/*.pl', 'util/**/*.awk', '.github/**/*.yml', '.github/**/*.sh', '.github/**/*.js', 'rust-toolchain') }} - - name: Setup Wasm runtime - run: ./util/runtime.sh -R ${{ matrix.runtime }} -V ${{ matrix[matrix.runtime] }} - - run: make setup - - run: make test-build - env: - NGX_WASM_RUNTIME: ${{ matrix.runtime }} + # valgrind: + # name: 'Valgrind' + # #if: ${{ false }} + # strategy: + # fail-fast: false + # matrix: + # label: [""] + # os: [ubuntu-22.04] + # cc: [gcc-10] + # ngx: [1.25.1] + # openresty: [""] + # runtime: [wasmer] + # wasmtime: [""] + # wasmer: [3.1.1] + # v8: [""] + # hup: [no_hup, hup] + # debug: [debug] + # include: + # # Wasmtime + # - runtime: wasmtime + # wasmtime: 8.0.1 + # os: ubuntu-22.04 + # cc: gcc-10 + # ngx: 1.25.1 + # hup: no_hup + # debug: debug + # # V8 + # - runtime: v8 + # v8: 11.4.183.23 + # os: ubuntu-22.04 + # cc: gcc-10 + # ngx: 1.25.1 + # debug: debug + # hup: no_hup + # # OpenResty + # - label: openresty + # os: ubuntu-22.04 + # cc: gcc-10 + # openresty: 1.21.4.1 + # ngx: + # runtime: wasmer + # wasmer: 3.1.1 + # debug: debug + # hup: no_hup + # uses: ./.github/workflows/job-valgrind-tests.yml + # with: + # os: ${{ matrix.os }} + # cc: ${{ matrix.cc }} + # ngx: ${{ matrix.ngx }} + # openresty: ${{ matrix.openresty }} + # runtime: ${{ matrix.runtime }} + # wasmtime: ${{ matrix.wasmtime }} + # wasmer: ${{ matrix.wasmer }} + # v8: ${{ matrix.v8 }} + # hup: ${{ matrix.hup }} + # debug: ${{ matrix.debug }} + # + # lint: + # name: 'Lint' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - uses: actions-rs/toolchain@v1 + # with: + # components: clippy + # - uses: actions/cache@v3 + # if: ${{ !env.ACT }} + # with: + # path: | + # work/downloads + # key: lint-${{ runner.os }}-${{ hashFiles('util/**/*.sh', 'util/**/*.pl', 'util/**/*.awk', '.github/**/*.yml', '.github/**/*.sh', '.github/**/*.js', 'rust-toolchain') }} + # - run: make setup + # - run: make lint + # - uses: actions-rs/clippy-check@v1 + # if: ${{ !env.ACT }} + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # args: --all-features + # - run: | + # if [[ $(make reindex 2>&1 | tee reindex.out | grep -c done) -gt 0 ]]; then + # cat reindex.out >&2 + # exit 1 + # fi + # + # analyzer: + # name: 'Clang analyzer' + # strategy: + # fail-fast: false + # matrix: + # cc: [clang-11] + # openresty: [1.21.4.1] + # runtime: [wasmtime, wasmer, v8] + # wasmtime: [8.0.1] + # wasmer: [3.1.1] + # v8: [11.4.183.23] + # ssl: [ssl] + # debug: [debug, no_debug] + # include: + # # No SSL + # - os: ubuntu-latest + # cc: clang-11 + # ngx: 1.25.1 + # runtime: wasmer + # wasmer: 3.1.1 + # ssl: no_ssl + # debug: debug + # uses: ./.github/workflows/job-clang-analyzer.yml + # with: + # cc: ${{ matrix.cc }} + # ngx: ${{ matrix.ngx }} + # openresty: ${{ matrix.openresty }} + # runtime: ${{ matrix.runtime }} + # wasmtime: ${{ matrix.wasmtime }} + # wasmer: ${{ matrix.wasmer }} + # v8: ${{ matrix.v8 }} + # ssl: ${{ matrix.ssl }} + # debug: ${{ matrix.debug }} + # + # build: + # name: 'Test builds' + # #if: ${{ false }} + # runs-on: ${{ matrix.os }} + # timeout-minutes: 45 + # strategy: + # fail-fast: false + # matrix: + # label: [""] + # os: [ubuntu-latest] + # cc: [clang-14, gcc-10] + # ngx: [1.25.1] + # runtime: [wasmtime, wasmer, v8] + # wasmtime: [8.0.1] + # wasmer: [3.1.1] + # v8: [11.4.183.23] + # include: + # - label: old_nginx + # os: ubuntu-latest + # cc: clang-14 + # ngx: 1.21.6 + # runtime: wasmtime + # wasmtime: 8.0.1 + # steps: + # - uses: actions/checkout@v3 + # - name: 'Setup cache - work/ dir' + # uses: actions/cache@v3 + # if: ${{ !env.ACT }} + # with: + # path: | + # work/downloads + # work/runtimes + # work/openssl + # key: work-${{ runner.os }}-${{ matrix.cc }}-${{ matrix.ngx }}-${{ matrix.openresty }}-${{ matrix.runtime }}-${{ hashFiles('util/**/*.sh', 'util/**/*.pl', 'util/**/*.awk', '.github/**/*.yml', '.github/**/*.sh', '.github/**/*.js', 'rust-toolchain') }} + # - name: Setup Wasm runtime + # run: ./util/runtime.sh -R ${{ matrix.runtime }} -V ${{ matrix[matrix.runtime] }} + # - run: make setup + # - run: make test-build + # env: + # NGX_WASM_RUNTIME: ${{ matrix.runtime }} diff --git a/.github/workflows/job-unit-tests.yml b/.github/workflows/job-unit-tests.yml index 3a4f80ed6..e6c9b0813 100644 --- a/.github/workflows/job-unit-tests.yml +++ b/.github/workflows/job-unit-tests.yml @@ -59,6 +59,7 @@ env: TEST_NGINX_USE_HUP: ${{ inputs.hup == 'hup' && 1 || 0 }} TEST_NGINX_TIMEOUT: 60 TEST_NGINX_EXTERNAL_TIMEOUT: 120s + TEST_NGINX_EXTERNAL_RESOLVER: 127.0.0.1 jobs: tests: @@ -72,6 +73,9 @@ jobs: if: ${{ inputs.cc == 'gcc-9' }} run: sudo apt-get update && sudo apt-get install -y gcc-9 libstdc++-9-dev lcov - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-echo-server + with: + echo_server_name: 'httpbin.org' - name: 'Setup cache - rustup toolchain' uses: actions/cache@v3 if: ${{ !env.ACT }} @@ -103,6 +107,10 @@ jobs: run: ./util/runtime.sh -R ${{ inputs.runtime }} -V ${{ inputs[inputs.runtime] }} - run: make setup - run: make + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + with: + limit-access-to-actor: true - run: make test - name: Run lcov id: lcov