Skip to content

Commit bb63208

Browse files
authored
Add github actions workflow for testing PRs (#959)
* Add github actions workflow for testing PRs This may need some more work because it's not always easy to test actions locally. Signed-off-by: Joe Adams <[email protected]> * Add build and publish jobs Signed-off-by: Joe Adams <[email protected]> * Update main branch references with checks for master Signed-off-by: Joe Adams <[email protected]> --------- Signed-off-by: Joe Adams <[email protected]>
1 parent 34c4936 commit bb63208

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

.github/workflows/ci.yml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
name: CI
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
test_go:
9+
name: Go tests
10+
runs-on: ubuntu-latest
11+
container:
12+
# Whenever the Go version is updated here, .promu.yml
13+
# should also be updated.
14+
image: quay.io/prometheus/golang-builder:1.23-base
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
18+
- uses: ./.github/promci/actions/setup_environment
19+
- run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1
20+
21+
build:
22+
name: Build Prometheus for common architectures
23+
runs-on: ubuntu-latest
24+
if: |
25+
!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
26+
&&
27+
!(github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-'))
28+
&&
29+
!(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
30+
&&
31+
!(github.event_name == 'push' && github.event.ref == 'refs/heads/master')
32+
strategy:
33+
matrix:
34+
thread: [ 0, 1, 2 ]
35+
steps:
36+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
38+
- uses: ./.github/promci/actions/build
39+
with:
40+
promu_opts: "-p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386"
41+
parallelism: 3
42+
thread: ${{ matrix.thread }}
43+
44+
build_all:
45+
name: Build Prometheus for all architectures
46+
runs-on: ubuntu-latest
47+
if: |
48+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
49+
||
50+
(github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-'))
51+
||
52+
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
53+
||
54+
(github.event_name == 'push' && github.event.ref == 'refs/heads/master')
55+
strategy:
56+
matrix:
57+
thread: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
58+
59+
# Whenever the Go version is updated here, .promu.yml
60+
# should also be updated.
61+
steps:
62+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
63+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
64+
- uses: ./.github/promci/actions/build
65+
with:
66+
parallelism: 12
67+
thread: ${{ matrix.thread }}
68+
69+
publish_main:
70+
name: Publish main branch artifacts
71+
runs-on: ubuntu-latest
72+
needs: [test_go, build_all]
73+
if: |
74+
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
75+
||
76+
(github.event_name == 'push' && github.event.ref == 'refs/heads/master')
77+
steps:
78+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
80+
- uses: ./.github/promci/actions/publish_main
81+
with:
82+
docker_hub_login: ${{ secrets.docker_hub_login }}
83+
docker_hub_password: ${{ secrets.docker_hub_password }}
84+
quay_io_login: ${{ secrets.quay_io_login }}
85+
quay_io_password: ${{ secrets.quay_io_password }}
86+
87+
publish_release:
88+
name: Publish release artefacts
89+
runs-on: ubuntu-latest
90+
needs: [test_go, build_all]
91+
if: |
92+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
93+
steps:
94+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
95+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
96+
- uses: ./.github/promci/actions/publish_release
97+
with:
98+
docker_hub_login: ${{ secrets.docker_hub_login }}
99+
docker_hub_password: ${{ secrets.docker_hub_password }}
100+
quay_io_login: ${{ secrets.quay_io_login }}
101+
quay_io_password: ${{ secrets.quay_io_password }}
102+
github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)