diff --git a/.circleci/config.yml b/.circleci/config.yml index 959d31d2..916441aa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,75 +1,28 @@ +--- +# CI has been migrated to GitHub Actions +# Keeping this file so that previous pull requests continue working +# This file does not generate any CircleCI workflow + version: 2.1 -orbs: - prometheus: prometheus/prometheus@0.17.1 executors: - # Whenever the Go version is updated here, .promu.yml should also be updated. golang: docker: - - image: cimg/go:1.23 + - image: busybox jobs: - test: + noopjob: executor: golang steps: - - prometheus/setup_environment - - run: make - - prometheus/store_artifact: - file: blackbox_exporter - - run: git diff --exit-code - # IPv6 tests require the machine executor. - # See https://circleci.com/docs/2.0/faq/#can-i-use-ipv6-in-my-tests for details. - test-ipv6: - machine: true - working_directory: /home/circleci/.go_workspace/src/github.com/prometheus/blackbox_exporter - # Whenever the Go version is updated here, .promu.yml should also be updated. - environment: - DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.23-base - steps: - - checkout - run: - name: enable ipv6 - command: | - cat \<<'EOF' | sudo tee /etc/docker/daemon.json - { - "ipv6": true, - "fixed-cidr-v6": "2001:db8:1::/64" - } - EOF - sudo service docker restart - - run: docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i github.com/prometheus/blackbox_exporter -T + command: "true" workflows: version: 2 - blackbox_exporter: + prometheus: jobs: - - test: - filters: - tags: - only: /.*/ - - test-ipv6: - filters: - tags: - only: /.*/ - - prometheus/build: - name: build - filters: - tags: - only: /.*/ - - prometheus/publish_master: - context: org-context - requires: - - test - - test-ipv6 - - build - filters: - branches: - only: master - - prometheus/publish_release: - context: org-context - requires: - - test - - test-ipv6 - - build + - noopjob + triggers: + - schedule: + cron: "0 0 30 2 *" filters: - tags: - only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ branches: - ignore: /.*/ + only: + - master diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..50c50301 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,109 @@ +--- +name: CI +on: + - push + - pull_request +jobs: + test: + name: Test + strategy: + matrix: + os: + - ubuntu-24.04 + - windows-2022 + - macos-13 + - macos-14 + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Read .promu.yml + uses: pietrobolcato/action-read-yaml@dd664040f4883322f6d143e58302062b35a46e4d + id: read_promu + with: + config: .promu.yml + - name: Set up Go + uses: actions/setup-go@v5.2.0 + with: + go-version: ${{ steps.read_promu.outputs['go.version'] }} + - run: make build + - run: make test GOOPTS=-v + + build_common: + name: Build common architectures + if: github.event_name == 'pull_request' + strategy: + matrix: + thread: [0, 1, 2] + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Import PromCI + uses: prometheus/promci@v0.4.5 + - name: Cross-build + uses: ./.github/promci/actions/build + with: + thread: ${{ matrix.thread }} + parallelism: 3 + promu_opts: -p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386 + + build_all: + name: Build all architectures + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v0.')) + strategy: + matrix: + thread: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Import PromCI + uses: prometheus/promci@v0.4.5 + - name: Cross-build + uses: ./.github/promci/actions/build + with: + thread: ${{ matrix.thread }} + parallelism: 12 + promu_opts: -p linux + + publish_master: + name: Publish master + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + needs: + - test + - build_all + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Import PromCI + uses: prometheus/promci@v0.4.5 + - name: Publish + uses: ./.github/promci/actions/publish_main + with: + docker_hub_login: ${{ secrets.DOCKER_HUB_LOGIN }} + docker_hub_password: ${{ secrets.DOCKER_HUB_PASSWORD }} + quay_io_login: ${{ secrets.QUAY_IO_LOGIN }} + quay_io_password: ${{ secrets.QUAY_IO_PASSWORD }} + + publish_release: + name: Publish release + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v0.') + needs: + - test + - build_all + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Import PromCI + uses: prometheus/promci@v0.4.5 + - name: Publish + uses: ./.github/promci/actions/publish_release + with: + github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }} + docker_hub_login: ${{ secrets.DOCKER_HUB_LOGIN }} + docker_hub_password: ${{ secrets.DOCKER_HUB_PASSWORD }} + quay_io_login: ${{ secrets.QUAY_IO_LOGIN }} + quay_io_password: ${{ secrets.QUAY_IO_PASSWORD }} diff --git a/.promu.yml b/.promu.yml index acb28a4c..4b1b7363 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,17 +1,16 @@ go: - # Whenever the Go version is updated here, .circle/config.yml should also be updated. - version: 1.23 + version: 1.23 repository: - path: github.com/prometheus/blackbox_exporter + path: github.com/prometheus/blackbox_exporter build: - ldflags: | - -X github.com/prometheus/common/version.Version={{.Version}} - -X github.com/prometheus/common/version.Revision={{.Revision}} - -X github.com/prometheus/common/version.Branch={{.Branch}} - -X github.com/prometheus/common/version.BuildUser={{user}}@{{host}} - -X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} + ldflags: | + -X github.com/prometheus/common/version.Version={{.Version}} + -X github.com/prometheus/common/version.Revision={{.Revision}} + -X github.com/prometheus/common/version.Branch={{.Branch}} + -X github.com/prometheus/common/version.BuildUser={{user}}@{{host}} + -X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} tarball: - files: - - blackbox.yml - - LICENSE - - NOTICE + files: + - blackbox.yml + - LICENSE + - NOTICE diff --git a/README.md b/README.md index 71a3c060..f2bccff3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Blackbox exporter -[![CircleCI](https://circleci.com/gh/prometheus/blackbox_exporter/tree/master.svg?style=shield)][circleci] +[![CI](https://github.com/prometheus/blackbox_exporter/actions/workflows/ci.yml/badge.svg)](https://github.com/prometheus/blackbox_exporter/actions/workflows/ci.yml) [![Docker Repository on Quay](https://quay.io/repository/prometheus/blackbox-exporter/status)][quay] [![Docker Pulls](https://img.shields.io/docker/pulls/prom/blackbox-exporter.svg?maxAge=604800)][hub] @@ -159,6 +159,5 @@ The ICMP probe requires elevated privileges to function: * *BSD*: root user is required. * *OS X*: No additional privileges are needed. -[circleci]: https://circleci.com/gh/prometheus/blackbox_exporter [hub]: https://hub.docker.com/r/prom/blackbox-exporter/ [quay]: https://quay.io/repository/prometheus/blackbox-exporter diff --git a/prober/dns_test.go b/prober/dns_test.go index 4e4fdff2..0eb1c850 100644 --- a/prober/dns_test.go +++ b/prober/dns_test.go @@ -16,7 +16,6 @@ package prober import ( "context" "net" - "os" "runtime" "testing" "time" @@ -90,10 +89,6 @@ func recursiveDNSHandler(w dns.ResponseWriter, r *dns.Msg) { } func TestRecursiveDNSResponse(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - tests := []struct { Probe config.DNSProbe ShouldSucceed bool @@ -247,10 +242,6 @@ func authoritativeDNSHandler(w dns.ResponseWriter, r *dns.Msg) { } func TestAuthoritativeDNSResponse(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - tests := []struct { Probe config.DNSProbe ShouldSucceed bool @@ -398,10 +389,6 @@ func TestAuthoritativeDNSResponse(t *testing.T) { } func TestServfailDNSResponse(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - tests := []struct { Probe config.DNSProbe ShouldSucceed bool @@ -475,10 +462,6 @@ func TestServfailDNSResponse(t *testing.T) { } func TestDNSProtocol(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - // This test assumes that listening TCP listens both IPv6 and IPv4 traffic and // localhost resolves to both 127.0.0.1 and ::1. we must skip the test if either // of these isn't true. This should be true for modern Linux systems. diff --git a/prober/grpc_test.go b/prober/grpc_test.go index 2a2c4aeb..bc2dc5c5 100644 --- a/prober/grpc_test.go +++ b/prober/grpc_test.go @@ -35,10 +35,6 @@ import ( ) func TestGRPCConnection(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - ln, err := net.Listen("tcp", "localhost:0") if err != nil { t.Fatalf("Error listening on socket: %s", err) @@ -103,10 +99,6 @@ func TestGRPCConnection(t *testing.T) { } func TestMultipleGRPCservices(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - ln, err := net.Listen("tcp", "localhost:0") if err != nil { t.Fatalf("Error listening on socket: %s", err) @@ -172,10 +164,6 @@ func TestMultipleGRPCservices(t *testing.T) { } func TestGRPCTLSConnection(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - certExpiry := time.Now().AddDate(0, 0, 1) testCertTmpl := generateCertificateTemplate(certExpiry, false) testCertTmpl.IsCA = true @@ -267,10 +255,6 @@ func TestGRPCTLSConnection(t *testing.T) { } func TestNoTLSConnection(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - ln, err := net.Listen("tcp", "localhost:0") if err != nil { t.Fatalf("Error listening on socket: %s", err) @@ -325,10 +309,6 @@ func TestNoTLSConnection(t *testing.T) { } func TestGRPCServiceNotFound(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - ln, err := net.Listen("tcp", "localhost:0") if err != nil { t.Fatalf("Error listening on socket: %s", err) @@ -381,10 +361,6 @@ func TestGRPCServiceNotFound(t *testing.T) { } func TestGRPCHealthCheckUnimplemented(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - ln, err := net.Listen("tcp", "localhost:0") if err != nil { t.Fatalf("Error listening on socket: %s", err) diff --git a/prober/tcp_test.go b/prober/tcp_test.go index 94709a0f..1303eec1 100644 --- a/prober/tcp_test.go +++ b/prober/tcp_test.go @@ -71,10 +71,6 @@ func TestTCPConnectionFails(t *testing.T) { } func TestTCPConnectionWithTLS(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - ln, err := net.Listen("tcp", ":0") if err != nil { t.Fatalf("Error listening on socket: %s", err) @@ -201,10 +197,6 @@ func TestTCPConnectionWithTLS(t *testing.T) { } func TestTCPConnectionWithTLSAndVerifiedCertificateChain(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - ln, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { t.Fatalf("Error listening on socket: %s", err) @@ -581,10 +573,6 @@ func TestTCPConnectionQueryResponseMatching(t *testing.T) { } func TestTCPConnectionProtocol(t *testing.T) { - if os.Getenv("CI") == "true" { - t.Skip("skipping; CI is failing on ipv6 dns requests") - } - // This test assumes that listening TCP listens both IPv6 and IPv4 traffic and // localhost resolves to both 127.0.0.1 and ::1. we must skip the test if either // of these isn't true. This should be true for modern Linux systems. diff --git a/prober/utils_test.go b/prober/utils_test.go index cbc21210..878b2879 100644 --- a/prober/utils_test.go +++ b/prober/utils_test.go @@ -23,6 +23,8 @@ import ( "fmt" "math/big" "net" + "os" + "runtime" "slices" "testing" "time" @@ -143,6 +145,9 @@ func generateSelfSignedCertificateWithPrivateKey(template *x509.Certificate, pri } func TestChooseProtocol(t *testing.T) { + if os.Getenv("CI") == "true" && runtime.GOOS == "windows" { + t.Skip("skipping; Windows CI failing on IPv6 DNS") + } if testing.Short() { t.Skip("skipping network dependent test") }