From 51d6ed42d711a1954245753338cf7e02a6fca3da Mon Sep 17 00:00:00 2001 From: darkweak Date: Thu, 29 Feb 2024 21:17:04 +0100 Subject: [PATCH] debug mr.json and test screenshot --- .github/workflows/plugins.yml | 166 ++++++++++++++----------- docs/cache-tests/cache-tests-caddyfile | 22 ++-- 2 files changed, 106 insertions(+), 82 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 214689813..b9d3adeac 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -4,74 +4,74 @@ on: - pull_request jobs: - build-caddy-validator: - name: Check that Souin build as caddy module - runs-on: ubuntu-latest - services: - redis: - image: redis - ports: - - 6379:6379 - etcd: - image: quay.io/coreos/etcd - env: - ETCD_NAME: etcd0 - ETCD_ADVERTISE_CLIENT_URLS: http://etcd:2379,http://etcd:4001 - ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379,http://0.0.0.0:4001 - ETCD_INITIAL_ADVERTISE_PEER_URLS: http://etcd:2380 - ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380 - ETCD_INITIAL_CLUSTER_TOKEN: etcd-cluster-1 - ETCD_INITIAL_CLUSTER: etcd0=http://etcd:2380 - ETCD_INITIAL_CLUSTER_STATE: new - ports: - - 2379:2379 - - 2380:2380 - - 4001:4001 - steps: - - - name: Add domain.com host to /etc/hosts - run: | - sudo echo "127.0.0.1 domain.com etcd redis" | sudo tee -a /etc/hosts - - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: '1.21' - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install xcaddy - run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest - - - name: Build Souin as caddy module - run: cd plugins/caddy && xcaddy build --with github.com/darkweak/souin/plugins/caddy=./ --with github.com/darkweak/souin@latest=../.. - - - name: Run Caddy tests - run: cd plugins/caddy && go test -v ./... - - - name: Run detached caddy - run: cd plugins/caddy && ./caddy run & - - - name: Run Caddy E2E tests - uses: matt-ball/newman-action@master - with: - collection: "docs/e2e/Souin E2E.postman_collection.json" - folder: '["Caddy"]' - delayRequest: 5000 - - - name: Run detached caddy - run: cd plugins/caddy && ./caddy stop - - - name: Run detached caddy - run: cd plugins/caddy && ./caddy run --config ./configuration.json & - - - name: Run Caddy E2E tests - uses: matt-ball/newman-action@master - with: - collection: "docs/e2e/Souin E2E.postman_collection.json" - folder: '["Caddy"]' - delayRequest: 5000 +# build-caddy-validator: +# name: Check that Souin build as caddy module +# runs-on: ubuntu-latest +# services: +# redis: +# image: redis +# ports: +# - 6379:6379 +# etcd: +# image: quay.io/coreos/etcd +# env: +# ETCD_NAME: etcd0 +# ETCD_ADVERTISE_CLIENT_URLS: http://etcd:2379,http://etcd:4001 +# ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379,http://0.0.0.0:4001 +# ETCD_INITIAL_ADVERTISE_PEER_URLS: http://etcd:2380 +# ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380 +# ETCD_INITIAL_CLUSTER_TOKEN: etcd-cluster-1 +# ETCD_INITIAL_CLUSTER: etcd0=http://etcd:2380 +# ETCD_INITIAL_CLUSTER_STATE: new +# ports: +# - 2379:2379 +# - 2380:2380 +# - 4001:4001 +# steps: +# - +# name: Add domain.com host to /etc/hosts +# run: | +# sudo echo "127.0.0.1 domain.com etcd redis" | sudo tee -a /etc/hosts +# - +# name: Install Go +# uses: actions/setup-go@v3 +# with: +# go-version: '1.21' +# - +# name: Checkout code +# uses: actions/checkout@v4 +# - +# name: Install xcaddy +# run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest +# - +# name: Build Souin as caddy module +# run: cd plugins/caddy && xcaddy build --with github.com/darkweak/souin/plugins/caddy=./ --with github.com/darkweak/souin@latest=../.. +# - +# name: Run Caddy tests +# run: cd plugins/caddy && go test -v ./... +# - +# name: Run detached caddy +# run: cd plugins/caddy && ./caddy run & +# - +# name: Run Caddy E2E tests +# uses: matt-ball/newman-action@master +# with: +# collection: "docs/e2e/Souin E2E.postman_collection.json" +# folder: '["Caddy"]' +# delayRequest: 5000 +# - +# name: Run detached caddy +# run: cd plugins/caddy && ./caddy stop +# - +# name: Run detached caddy +# run: cd plugins/caddy && ./caddy run --config ./configuration.json & +# - +# name: Run Caddy E2E tests +# uses: matt-ball/newman-action@master +# with: +# collection: "docs/e2e/Souin E2E.postman_collection.json" +# folder: '["Caddy"]' +# delayRequest: 5000 run-cache-tests: # needs: build-caddy-validator name: Run cache-tests suite requirements and add the generated screenshot to the PR @@ -83,12 +83,12 @@ jobs: sudo echo "127.0.0.1 domain.com etcd redis" | sudo tee -a /etc/hosts - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: '1.21' - name: Install Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 @@ -116,7 +116,7 @@ jobs: run: cd souin/plugins/caddy && xcaddy build --with github.com/darkweak/souin/plugins/caddy=./ --with github.com/darkweak/souin=../.. - name: Run detached caddy - run: cd souin/plugins/caddy && ./caddy run --config souin/docs/cache-tests/cache-tests-caddyfile & + run: cd souin/plugins/caddy && ./caddy run --config ../../docs/cache-tests/cache-tests-caddyfile --adapter caddyfile & - name: Sync index.mjs from souin to cache-tests run: cp souin/docs/cache-tests/index.mjs cache-tests/results/index.mjs @@ -126,6 +126,30 @@ jobs: - name: Run cache-tests test suite run: cd cache-tests && ./test-host.sh 127.0.0.1:4443 > results/mr.json + - + name: Screenshot cache-tests + id: screenshot-generator + uses: swinton/screenshot-website@main + with: + source: http://127.0.0.1:8000/ + destination: cache-tests-screenshot.png + full-page: true + - + name: Screenshot cache-tests + uses: karol-brejna-i/webpage-screenshot-action@v1 + with: + url: http://127.0.0.1:8000/ + # mode: element + # xpath: //table[1] + output: cache-tests-screenshot.png + - + name: Pull request artifacts + uses: edunad/actions-image@master + with: + # path: ${{ steps.screenshot-generator.outputs.path }} + path: cache-tests-screenshot.png + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + title: 'cache-tests suite' # build-beego-validator: # name: Check that Souin build as middleware diff --git a/docs/cache-tests/cache-tests-caddyfile b/docs/cache-tests/cache-tests-caddyfile index e66ab5ad3..178980711 100644 --- a/docs/cache-tests/cache-tests-caddyfile +++ b/docs/cache-tests/cache-tests-caddyfile @@ -1,16 +1,16 @@ { - order cache before rewrite - cache { - api { - prometheus - souin - } - cdn { - dynamic - } - ttl 1000s - default_cache_control public + order cache before rewrite + cache { + api { + prometheus + souin + } + cdn { + dynamic } + ttl 1000s + default_cache_control public + } } :4443