From a529e2511480661ff3a2a7f079d4049a6277345c Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Wed, 18 Sep 2024 12:29:55 +0700 Subject: [PATCH] add action.yml --- .github/workflows/test.yml | 47 ++++++++++++-------------------------- action.yml | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 32 deletions(-) create mode 100644 action.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a5db6f..4cddfc4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Run Caddy to proxy Prometheus + run: | + docker run -d --name promproxy -p 9090:9090 caddy caddy reverse-proxy --from :9090 --to https://${{ secrets.PROMETHEUS_REMOTE_WRITE_DESTINATION }} --change-host-header + - name: Run Netdata + uses: . + with: + exporting-config: | + [prometheus_remote_write:prom] + enabled = yes + destination = 127.0.0.1:9090 + username = ${{ secrets.PROMETHEUS_REMOTE_WRITE_USERNAME }} + password = ${{ secrets.PROMETHEUS_REMOTE_WRITE_PASSWORD }} + remote write URL path = /api/v1/write + update every = 5 + - uses: pnpm/action-setup@v4 with: version: 9 @@ -18,37 +33,5 @@ jobs: uses: actions/setup-node@v4 with: node-version: "22" - - name: Run Netdata - run: | - echo '[prometheus_remote_write:prom] - enabled = yes - destination = ${{ secrets.PROMETHEUS_REMOTE_WRITE_DESTINATION }} - username = ${{ secrets.PROMETHEUS_REMOTE_WRITE_USERNAME }} - password = ${{ secrets.PROMETHEUS_REMOTE_WRITE_PASSWORD }} - remote write URL path = /api/v1/write - update every = 5 - ' > exporting.conf - docker run -d --rm \ - --name netdata \ - --hostname gha${{ github.repository_id }}-${{ github.run_id }}-${{ github.run_attempt }} \ - --pid host \ - --network host \ - --cap-add SYS_PTRACE \ - --cap-add SYS_ADMIN \ - --security-opt apparmor=unconfined \ - -v /:/host/root:ro,rslave \ - -v /etc/passwd:/host/etc/passwd:ro \ - -v /etc/group:/host/etc/group:ro \ - -v /etc/localtime:/etc/localtime:ro \ - -v /proc:/host/proc:ro \ - -v /sys:/host/sys:ro \ - -v /etc/os-release:/host/etc/os-release:ro \ - -v /var/log:/host/var/log:ro \ - -v /var/run/docker.sock:/var/run/docker.sock:ro \ - -v /run/dbus:/run/dbus:ro \ - -v $PWD/exporting.conf:/etc/netdata/exporting.conf:ro \ - netdata/netdata - name: Install Playwright and dependencies run: pnpx playwright install --with-deps - - name: Print netdata logs - run: docker logs netdata diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..47096dd --- /dev/null +++ b/action.yml @@ -0,0 +1,45 @@ +name: Netdata +description: Runs Netdata to collect performance metrics during the test run +inputs: + exporting-config: + required: true + description: Contents of netdata/exporting.conf +outputs: + host-id: + description: The randomly-generated host ID + value: ${{ steps.netdata.outputs.hostid }} +runs: + using: "composite" + steps: + - name: Write configuration + env: + EXPORTING_CONFIG: ${{ inputs.exporting-config }} + run: | + echo "$EXPORTING_CONFIG" > $RUNNER_TEMP/netdata_exporting.conf + shell: bash + - name: Start netdata + id: netdata + run: | + hostid=$(openssl rand -hex 4) + echo "hostid=$hostid" | tee -a "$GITHUB_OUTPUT" + docker run -d --rm \ + --name netdata \ + --hostname gha${{ github.repository_id }}-${{ github.run_id }}-${{ github.run_attempt }}-$hostid \ + --pid host \ + --network host \ + --cap-add SYS_PTRACE \ + --cap-add SYS_ADMIN \ + --security-opt apparmor=unconfined \ + -v /:/host/root:ro,rslave \ + -v /etc/passwd:/host/etc/passwd:ro \ + -v /etc/group:/host/etc/group:ro \ + -v /etc/localtime:/etc/localtime:ro \ + -v /proc:/host/proc:ro \ + -v /sys:/host/sys:ro \ + -v /etc/os-release:/host/etc/os-release:ro \ + -v /var/log:/host/var/log:ro \ + -v /var/run/docker.sock:/var/run/docker.sock:ro \ + -v /run/dbus:/run/dbus:ro \ + -v $RUNNER_TEMP/netdata_exporting.conf:/etc/netdata/exporting.conf:ro \ + netdata/netdata + shell: bash