Skip to content

Commit 4c2926b

Browse files
committed
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 <superq@gmail.com>
1 parent fc7b1e1 commit 4c2926b

6 files changed

Lines changed: 173 additions & 124 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
name: CI
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, master, 'release-*']
7+
tags: ['v*']
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test_go:
14+
name: Go tests
15+
runs-on: ubuntu-latest
16+
container:
17+
# Whenever the Go version is updated here, .promu.yml
18+
# should also be updated.
19+
image: quay.io/prometheus/golang-builder:1.26-base
20+
steps:
21+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
- uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0
23+
- run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1
24+
- run: git diff --exit-code
25+
26+
build:
27+
name: Build
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
thread: [ 0, 1, 2, 3]
32+
steps:
33+
- uses: prometheus/promci/build@d9d4f5688814f0b77bf003d07fb8c00507390634 # v0.8.2
34+
with:
35+
parallelism: 4
36+
thread: ${{ matrix.thread }}
37+
38+
integration:
39+
name: Integration test
40+
runs-on: ubuntu-latest
41+
needs: [test_go, build]
42+
container:
43+
# Whenever the Go version is updated here, .promu.yml
44+
# should also be updated.
45+
image: quay.io/prometheus/golang-builder:1.26-base
46+
services:
47+
node-exporter:
48+
image: quay.io/prometheus/node-exporter:latest
49+
env:
50+
NODE_EXPORTER_HOST: node-exporter
51+
PROMETHEUS_HOST: localhost
52+
PROM_VERSION: 3.12.0
53+
steps:
54+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
55+
- uses: prometheus/promci-artifacts/restore@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0
56+
- run: cp -v .build/linux-amd64/pushprox-client ./
57+
- run: cp -v .build/linux-amd64/pushprox-proxy ./
58+
- run: curl -sSf -L https://github.com/prometheus/prometheus/releases/download/v${PROM_VERSION}/prometheus-${PROM_VERSION}.linux-amd64.tar.gz | tar xz
59+
- run: echo ${PATH}
60+
- run: cp -v prometheus-${PROM_VERSION}.linux-amd64/prometheus /bin/prometheus
61+
- run: ./end-to-end/test.sh
62+
63+
publish_default:
64+
name: Publish default branch artifacts
65+
runs-on: ubuntu-latest
66+
permissions:
67+
packages: write
68+
needs: [test_go, build]
69+
if: |
70+
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
71+
||
72+
(github.event_name == 'push' && github.event.ref == 'refs/heads/master')
73+
steps:
74+
- uses: prometheus/promci/publish_main@d9d4f5688814f0b77bf003d07fb8c00507390634 # v0.8.2
75+
with:
76+
docker_hub_organization: prometheuscommunity
77+
docker_hub_password: ${{ secrets.docker_hub_password }}
78+
ghcr_io_password: ${{ github.token }}
79+
quay_io_organization: prometheuscommunity
80+
quay_io_password: ${{ secrets.quay_io_password }}
81+
82+
publish_release:
83+
name: Publish release artefacts
84+
permissions:
85+
contents: write
86+
packages: write
87+
runs-on: ubuntu-latest
88+
needs: [test_go, build]
89+
if: |
90+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
91+
steps:
92+
- uses: prometheus/promci/publish_release@d9d4f5688814f0b77bf003d07fb8c00507390634 # v0.8.2
93+
with:
94+
docker_hub_organization: prometheuscommunity
95+
docker_hub_password: ${{ secrets.docker_hub_password }}
96+
ghcr_io_password: ${{ github.token }}
97+
quay_io_organization: prometheuscommunity
98+
quay_io_password: ${{ secrets.quay_io_password }}
99+
github_token: ${{ github.token }}

.promu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
go:
2-
# This must match .circle/config.yml.
3-
version: 1.25
2+
# This must match .github/workflows/ci.yml.
3+
version: 1.26
44
repository:
55
path: github.com/prometheus-community/pushprox
66
build:

end-to-end-test.sh

Lines changed: 0 additions & 51 deletions
This file was deleted.

end-to-end/prometheus.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
global:
2+
scrape_interval: 1s
3+
scrape_configs:
4+
- job_name: pushprox
5+
proxy_url: http://localhost:8080
6+
static_configs:
7+
- targets:
8+
- node-exporter:9100

end-to-end/test.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
3+
set -u -o pipefail
4+
5+
node_exporter_host=${NODE_EXPORTER_HOST:-localhost}
6+
prometheus_host=${PROMETHEUS_HOST:-localhost}
7+
8+
tmpdir=$(mktemp -d /tmp/pushprox_e2e_test.XXXXXX)
9+
10+
cleanup() {
11+
for f in "${tmpdir}"/*.pid ; do
12+
kill -9 "$(< $f)"
13+
done
14+
rm -r "${tmpdir}"
15+
}
16+
17+
trap cleanup EXIT
18+
19+
if type node_exporter > /dev/null 2>&1 ; then
20+
node_exporter &
21+
echo $! > "${tmpdir}/node_exporter.pid"
22+
fi
23+
while ! curl -s -f -L "http://${node_exporter_host}:9100" > /dev/null; do
24+
echo "Waiting for node_exporter host=${node_exporter_host}"
25+
sleep 2
26+
done
27+
28+
if [[ ! -f 'pushprox-proxy' ]] ; then
29+
echo 'ERROR: Missing pushprox-proxy binary'
30+
exit 1
31+
fi
32+
./pushprox-proxy --log.level=debug &
33+
echo $! > "${tmpdir}/proxy.pid"
34+
while ! curl -s -f -L http://localhost:8080/clients > /dev/null; do
35+
echo 'Waiting for proxy'
36+
sleep 2
37+
done
38+
39+
if [[ ! -f 'pushprox-client' ]] ; then
40+
echo 'ERROR: Missing pushprox-client binary'
41+
exit 1
42+
fi
43+
./pushprox-client --log.level=debug --proxy-url=http://localhost:8080 &
44+
echo $! > "${tmpdir}/client.pid"
45+
while [ "$(curl -s -L 'http://localhost:8080/clients' | jq 'length')" != '1' ] ; do
46+
echo 'Waiting for client'
47+
sleep 2
48+
done
49+
50+
if type prometheus > /dev/null 2>&1 ; then
51+
prometheus --config.file=end-to-end/prometheus.yml --log.level=debug &
52+
echo $! > "${tmpdir}/prometheus.pid"
53+
fi
54+
while ! curl -s -f -L "http://${prometheus_host}:9090/-/ready"; do
55+
echo "Waiting for Prometheus host=${prometheus_host}"
56+
sleep 2
57+
done
58+
sleep 15
59+
60+
query="http://${prometheus_host}:9090/api/v1/query?query=node_exporter_build_info"
61+
while [ $(curl -s -L "${query}" | jq '.data.result | length') != '1' ]; do
62+
echo 'Waiting for results'
63+
sleep 2
64+
done

0 commit comments

Comments
 (0)