From f857a1d4c0440e8edd1177ab248cf3c3f0752882 Mon Sep 17 00:00:00 2001 From: Tyler Brekke Date: Tue, 29 Sep 2026 14:01:45 -0700 Subject: [PATCH] gha: modernize build/test workflow --- .github/workflows/{run_tests.yml => ci.yml} | 28 ++++++++----- .github/workflows/run_build.yml | 45 --------------------- 2 files changed, 18 insertions(+), 55 deletions(-) rename .github/workflows/{run_tests.yml => ci.yml} (50%) delete mode 100644 .github/workflows/run_build.yml diff --git a/.github/workflows/run_tests.yml b/.github/workflows/ci.yml similarity index 50% rename from .github/workflows/run_tests.yml rename to .github/workflows/ci.yml index a3bbad0..e70e5c7 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# Copyright 2023 DigitalOcean +# Copyright 2026 DigitalOcean # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Tests +name: CI on: push: @@ -22,16 +22,24 @@ on: jobs: - run-go-tests: - runs-on: ubuntu-20.04 + build: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: '1.20' + # Builds the `builder` stage of the Dockerfile, which already contains + # the Go toolchain and Ceph dev libraries needed to compile ceph_exporter. + - name: Build in Docker + run: docker build --target builder -t ceph_exporter:build . - # We only test the Ceph package since main depends on go-ceph - - name: Go test - run: go test -v ./ceph + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # Reuses the `builder` stage, but sets TEST so the Dockerfile runs + # `go test -tags nautilus -v -race -count=1 ./...` before compiling. + - name: Test in Docker + run: docker build --target builder --build-arg TEST=1 -t ceph_exporter:test . diff --git a/.github/workflows/run_build.yml b/.github/workflows/run_build.yml deleted file mode 100644 index 809c3a4..0000000 --- a/.github/workflows/run_build.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2023 DigitalOcean -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Build - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - - run-go-build: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 - with: - go-version: '1.20' - - - name: Download Ceph repository key - run: wget -q 'https://download.ceph.com/keys/release.asc' - - name: Install Ceph repository key - run: sudo apt-key add release.asc - - name: Declare Ceph Nautilus repository - run: echo deb https://download.ceph.com/debian-nautilus/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list - - name: Install go-ceph dependencies - run: sudo apt update && sudo apt install -y librados-dev librbd-dev - - - name: Go build - run: go build -tags nautilus -v ./...