|
| 1 | +--- |
| 2 | +name: CI |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [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 and .promu-cgo.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 | + with: |
| 23 | + persist-credentials: false |
| 24 | + - run: go mod download |
| 25 | + - run: make |
| 26 | + |
| 27 | + test_go_arm: |
| 28 | + name: Go ARM tests |
| 29 | + runs-on: ubuntu-24.04-arm |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 32 | + with: |
| 33 | + persist-credentials: false |
| 34 | + - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 |
| 35 | + with: |
| 36 | + go-version: 1.26.x |
| 37 | + - run: uname -a |
| 38 | + - run: make test-e2e |
| 39 | + |
| 40 | + test_mixins: |
| 41 | + name: Mixins tests |
| 42 | + runs-on: ubuntu-latest |
| 43 | + container: |
| 44 | + # Whenever the Go version is updated here, .promu.yml and .promu-cgo.yml |
| 45 | + # should also be updated. |
| 46 | + image: quay.io/prometheus/golang-builder:1.26-base |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 49 | + with: |
| 50 | + persist-credentials: false |
| 51 | + - run: go install github.com/google/go-jsonnet/cmd/jsonnet@latest |
| 52 | + - run: go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest |
| 53 | + - run: go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest |
| 54 | + - run: make promtool |
| 55 | + - run: make -C docs/node-mixin clean |
| 56 | + - run: make -C docs/node-mixin jb_install |
| 57 | + - run: make -C docs/node-mixin |
| 58 | + - run: git diff --exit-code |
| 59 | + |
| 60 | + build: |
| 61 | + name: Build node_exporter for all architectures |
| 62 | + runs-on: ubuntu-latest |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + thread: [ 0, 1, 2 ] |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 68 | + with: |
| 69 | + persist-credentials: false |
| 70 | + - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 |
| 71 | + - name: Crossbuild |
| 72 | + run: ~/go/bin/promu crossbuild -v --parallelism 3 --parallelism-thread ${{ matrix.thread }} |
| 73 | + - name: CGO crossbuild |
| 74 | + run: ~/go/bin/promu --config .promu-cgo.yml crossbuild -v --parallelism 3 --parallelism-thread ${{ matrix.thread }} |
| 75 | + - name: Codesign darwin binaries |
| 76 | + run: | |
| 77 | + if [[ -f "$(pwd)/.build/darwin-arm64/node_exporter" ]]; then |
| 78 | + ~/go/bin/promu codesign "$(pwd)/.build/darwin-arm64/node_exporter" |
| 79 | + fi |
| 80 | + if [[ -f "$(pwd)/.build/darwin-amd64/node_exporter" ]]; then |
| 81 | + ~/go/bin/promu codesign "$(pwd)/.build/darwin-amd64/node_exporter" |
| 82 | + fi |
| 83 | + - uses: prometheus/promci-artifacts/save@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 |
| 84 | + with: |
| 85 | + directory: .build |
| 86 | + |
| 87 | + test_docker: |
| 88 | + name: Test docker image |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: [test_go, build] |
| 91 | + env: |
| 92 | + DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.26-base |
| 93 | + REPO_PATH: github.com/prometheus/node_exporter |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 96 | + with: |
| 97 | + persist-credentials: false |
| 98 | + - uses: prometheus/promci-artifacts/restore@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 |
| 99 | + - name: Build docker image |
| 100 | + run: | |
| 101 | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 102 | + make docker DOCKER_IMAGE_TAG=${{ github.ref_name }} |
| 103 | + else |
| 104 | + make docker |
| 105 | + fi |
| 106 | + - run: docker images |
| 107 | + - run: docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T |
| 108 | + - name: Test docker image |
| 109 | + run: | |
| 110 | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 111 | + make test-docker DOCKER_IMAGE_TAG=${{ github.ref_name }} |
| 112 | + else |
| 113 | + make test-docker |
| 114 | + fi |
| 115 | +
|
| 116 | + publish_main: |
| 117 | + name: Publish main branch artifacts |
| 118 | + runs-on: ubuntu-latest |
| 119 | + needs: [test_go, test_go_arm, build] |
| 120 | + if: github.event_name == 'push' && github.event.ref == 'refs/heads/master' |
| 121 | + steps: |
| 122 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 123 | + with: |
| 124 | + persist-credentials: false |
| 125 | + - uses: prometheus/promci/publish_main@769ee18070cd21cfc2a24fa912349fd3e48dee58 # v0.6.0 |
| 126 | + with: |
| 127 | + docker_hub_login: ${{ secrets.docker_hub_login }} |
| 128 | + docker_hub_password: ${{ secrets.docker_hub_password }} |
| 129 | + quay_io_login: ${{ secrets.quay_io_login }} |
| 130 | + quay_io_password: ${{ secrets.quay_io_password }} |
| 131 | + |
| 132 | + publish_release: |
| 133 | + name: Publish release artifacts |
| 134 | + runs-on: ubuntu-latest |
| 135 | + needs: [test_go, test_go_arm, build] |
| 136 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 137 | + steps: |
| 138 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 139 | + with: |
| 140 | + persist-credentials: false |
| 141 | + - uses: prometheus/promci/publish_release@769ee18070cd21cfc2a24fa912349fd3e48dee58 # v0.6.0 |
| 142 | + with: |
| 143 | + docker_hub_login: ${{ secrets.docker_hub_login }} |
| 144 | + docker_hub_password: ${{ secrets.docker_hub_password }} |
| 145 | + quay_io_login: ${{ secrets.quay_io_login }} |
| 146 | + quay_io_password: ${{ secrets.quay_io_password }} |
| 147 | + github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }} |
0 commit comments