From 1e992092808aa24e51d8386f289c4a21d9b4e77e Mon Sep 17 00:00:00 2001 From: SuperQ Date: Sun, 19 Apr 2026 11:04:15 +0200 Subject: [PATCH] Migrate to PromCI Migrate to PromCI GitHub Actions * Fixup end-to-end test to work with Actions services. * Update Go to 1.26.x. Signed-off-by: SuperQ --- .circleci/config.yml | 71 -------------------------- .github/workflows/ci.yml | 103 ++++++++++++++++++++++++++++++++++++++ .promu.yml | 4 +- end-to-end-test.sh | 51 ------------------- end-to-end/prometheus.yml | 8 +++ end-to-end/test.sh | 64 +++++++++++++++++++++++ go.mod | 2 +- 7 files changed, 178 insertions(+), 125 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml delete mode 100755 end-to-end-test.sh create mode 100644 end-to-end/prometheus.yml create mode 100755 end-to-end/test.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index d4270c7a..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,71 +0,0 @@ ---- -version: 2.1 -orbs: - prometheus: prometheus/prometheus@0.17.1 -executors: - golang: - docker: - - image: cimg/go:1.25 - - image: quay.io/prometheus/node-exporter:latest - -jobs: - test: - executor: golang - environment: - prom_ver: 3.7.3 - steps: - - prometheus/setup_environment - - run: wget https://github.com/prometheus/prometheus/releases/download/v${prom_ver}/prometheus-${prom_ver}.linux-amd64.tar.gz - - run: tar xzf prometheus-${prom_ver}.linux-amd64.tar.gz - - run: sudo cp -v prometheus-${prom_ver}.linux-amd64/prometheus /bin/prometheus - - run: - name: Configure Prometheus - command: | - cat \<< EOF > prometheus.yml - global: - scrape_interval: 1s - scrape_configs: - - job_name: pushprox - proxy_url: http://127.0.0.1:8080 - static_configs: - - targets: ['$(hostname):9100'] - EOF - - run: make - - run: - name: Run everything and test that Prometheus can scrape node_exporter via pushprox - command: ./end-to-end-test.sh -workflows: - version: 2 - PushProx: - jobs: - - test: - filters: - tags: - only: /.*/ - - prometheus/build: - name: build - filters: - tags: - only: /.*/ - - prometheus/publish_master: - context: org-context - docker_hub_organization: prometheuscommunity - quay_io_organization: prometheuscommunity - requires: - - test - - build - filters: - branches: - only: master - - prometheus/publish_release: - context: org-context - docker_hub_organization: prometheuscommunity - quay_io_organization: prometheuscommunity - requires: - - test - - build - filters: - tags: - only: /^v.*/ - branches: - ignore: /.*/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ca746435 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,103 @@ +--- +name: CI +on: + pull_request: + push: + branches: [main, master, 'release-*'] + tags: ['v*'] + +permissions: + contents: read + +jobs: + test_go: + name: Go tests + runs-on: ubuntu-latest + container: + # Whenever the Go version is updated here, .promu.yml + # should also be updated. + image: quay.io/prometheus/golang-builder:1.26-base + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 + - run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1 + + + build: + name: Build + runs-on: ubuntu-latest + strategy: + matrix: + thread: [ 0, 1, 2, 3] + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: prometheus/promci/build@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0 + with: + parallelism: 4 + thread: ${{ matrix.thread }} + + integration: + name: Integration test + runs-on: ubuntu-latest + needs: [test_go, build] + container: + # Whenever the Go version is updated here, .promu.yml + # should also be updated. + image: quay.io/prometheus/golang-builder:1.26-base + services: + node-exporter: + image: quay.io/prometheus/node-exporter:latest + prometheus: + image: quay.io/prometheus/prometheus:latest + command: | + --config.file=/etc/prometheus/prometheus.yml + --storage.tsdb.path=/prometheus + --web.enable-lifecycle + volumes: + - ./end-to-end/:/etc/prometheus/ + env: + NODE_EXPORTER_HOST: node-exporter + PROMETHEUS_HOST: prometheus + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: prometheus/promci-artifacts/restore@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 + - run: cp -v .build/linux-amd64/pushprox-client ./ + - run: cp -v .build/linux-amd64/pushprox-proxy ./ + #- run: cp -v end-to-end/prometheus.yml promcfg/prometheus.yml + - run: ls -l end-to-end/prometheus.yml + - run: cat end-to-end/prometheus.yml + - run: curl -X POST -v -f -L http://prometheus:9090/-/reload + - run: ./end-to-end/test.sh + + publish_main: + name: Publish main branch artifacts + runs-on: ubuntu-latest + needs: [test_go, build] + if: | + (github.event_name == 'push' && github.event.ref == 'refs/heads/main') + || + (github.event_name == 'push' && github.event.ref == 'refs/heads/master') + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: prometheus/promci/publish_main@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0 + with: + docker_hub_organization: prometheuscommunity + docker_hub_password: ${{ secrets.docker_hub_password }} + quay_io_organization: prometheuscommunity + quay_io_password: ${{ secrets.quay_io_password }} + + publish_release: + name: Publish release artefacts + runs-on: ubuntu-latest + needs: [test_go, build] + if: | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: prometheus/promci/publish_release@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0 + with: + docker_hub_organization: prometheuscommunity + docker_hub_password: ${{ secrets.docker_hub_password }} + quay_io_organization: prometheuscommunity + quay_io_password: ${{ secrets.quay_io_password }} + github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }} diff --git a/.promu.yml b/.promu.yml index 05f1645f..cfcc84ff 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,6 +1,6 @@ go: - # This must match .circle/config.yml. - version: 1.25 + # This must match .github/workflows/ci.yml. + version: 1.26 repository: path: github.com/prometheus-community/pushprox build: diff --git a/end-to-end-test.sh b/end-to-end-test.sh deleted file mode 100755 index 3ceb681b..00000000 --- a/end-to-end-test.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -set -u -o pipefail - -tmpdir=$(mktemp -d /tmp/pushprox_e2e_test.XXXXXX) - -cleanup() { - for f in "${tmpdir}"/*.pid ; do - kill -9 "$(< $f)" - done - rm -r "${tmpdir}" -} - -trap cleanup EXIT - -if type node_exporter > /dev/null 2>&1 ; then - node_exporter & - echo $! > "${tmpdir}/node_exporter.pid" -fi -while ! curl -s -f -L http://localhost:9100; do - echo 'Waiting for node_exporter' - sleep 2 -done - -./pushprox-proxy --log.level=debug & -echo $! > "${tmpdir}/proxy.pid" -while ! curl -s -f -L http://localhost:8080/clients; do - echo 'Waiting for proxy' - sleep 2 -done - -./pushprox-client --log.level=debug --proxy-url=http://localhost:8080 & -echo $! > "${tmpdir}/client.pid" -while [ "$(curl -s -L 'http://localhost:8080/clients' | jq 'length')" != '1' ] ; do - echo 'Waiting for client' - sleep 2 -done - -prometheus --config.file=prometheus.yml --log.level=debug & -echo $! > "${tmpdir}/prometheus.pid" -while ! curl -s -f -L http://localhost:9090/-/ready; do - echo 'Waiting for Prometheus' - sleep 2 -done -sleep 15 - -query='http://localhost:9090/api/v1/query?query=node_exporter_build_info' -while [ $(curl -s -L "${query}" | jq '.data.result | length') != '1' ]; do - echo 'Waiting for results' - sleep 2 -done diff --git a/end-to-end/prometheus.yml b/end-to-end/prometheus.yml new file mode 100644 index 00000000..b33875b6 --- /dev/null +++ b/end-to-end/prometheus.yml @@ -0,0 +1,8 @@ +global: + scrape_interval: 1s +scrape_configs: + - job_name: pushprox + proxy_url: http://172.17.0.1:8080 + static_configs: + - targets: + - node-exporter:9100 diff --git a/end-to-end/test.sh b/end-to-end/test.sh new file mode 100755 index 00000000..e87b84ab --- /dev/null +++ b/end-to-end/test.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +set -u -o pipefail + +node_exporter_host=${NODE_EXPORTER_HOST:-localhost} +prometheus_host=${PROMETHEUS_HOST:-localhost} + +tmpdir=$(mktemp -d /tmp/pushprox_e2e_test.XXXXXX) + +cleanup() { + for f in "${tmpdir}"/*.pid ; do + kill -9 "$(< $f)" + done + rm -r "${tmpdir}" +} + +trap cleanup EXIT + +if type node_exporter > /dev/null 2>&1 ; then + node_exporter & + echo $! > "${tmpdir}/node_exporter.pid" +fi +while ! curl -s -f -L "http://${node_exporter_host}:9100" > /dev/null; do + echo "Waiting for node_exporter host=${node_exporter_host}" + sleep 2 +done + +if [[ ! -f 'pushprox-proxy' ]] ; then + echo 'ERROR: Missing pushprox-proxy binary' + exit 1 +fi +./pushprox-proxy --log.level=debug & +echo $! > "${tmpdir}/proxy.pid" +while ! curl -s -f -L http://localhost:8080/clients > /dev/null; do + echo 'Waiting for proxy' + sleep 2 +done + +if [[ ! -f 'pushprox-client' ]] ; then + echo 'ERROR: Missing pushprox-client binary' + exit 1 +fi +./pushprox-client --log.level=debug --proxy-url=http://localhost:8080 & +echo $! > "${tmpdir}/client.pid" +while [ "$(curl -s -L 'http://localhost:8080/clients' | jq 'length')" != '1' ] ; do + echo 'Waiting for client' + sleep 2 +done + +if type prometheus > /dev/null 2>&1 ; then + prometheus --config.file=end-to-end/prometheus.yml --log.level=debug & + echo $! > "${tmpdir}/prometheus.pid" +fi +while ! curl -s -f -L "http://${prometheus_host}:9090/-/ready"; do + echo "Waiting for Prometheus host=${prometheus_host}" + sleep 2 +done +sleep 15 + +query="http://${prometheus_host}:9090/api/v1/query?query=node_exporter_build_info" +while [ $(curl -s -L "${query}" | jq '.data.result | length') != '1' ]; do + echo 'Waiting for results' + sleep 2 +done diff --git a/go.mod b/go.mod index bfb00505..e616f2d7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/prometheus-community/pushprox -go 1.24.0 +go 1.25.0 require ( github.com/Showmax/go-fqdn v1.0.0