|
| 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.25-base |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 17 | + - uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7 |
| 18 | + - uses: ./.github/promci/actions/setup_environment |
| 19 | + - run: make test |
| 20 | + - run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1 |
| 21 | + integration_tests: |
| 22 | + name: Integration tests |
| 23 | + runs-on: ubuntu-latest |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + # Define Postgres versions to test against. |
| 27 | + postgres_version: |
| 28 | + - 13.22 |
| 29 | + - 14.19 |
| 30 | + - 15.14 |
| 31 | + - 16.10 |
| 32 | + - 17.6 |
| 33 | + services: |
| 34 | + postgres: |
| 35 | + image: postgres:${{ matrix.postgres_version }} |
| 36 | + env: |
| 37 | + POSTGRES_DB: circle_test |
| 38 | + POSTGRES_USER: postgres |
| 39 | + POSTGRES_PASSWORD: test |
| 40 | + # options: >- |
| 41 | + # --health-cmd="pg_isready -U postgres -d circle_test" |
| 42 | + # --health-interval=10s |
| 43 | + # --health-timeout=5s |
| 44 | + # --health-retries=5 |
| 45 | + container: |
| 46 | + # Whenever the Go version is updated here, .promu.yml |
| 47 | + # should also be updated. |
| 48 | + image: quay.io/prometheus/golang-builder:1.25-base |
| 49 | + env: |
| 50 | + DATA_SOURCE_NAME: 'postgresql://postgres:test@postgres:5432/circle_test?sslmode=disable' |
| 51 | + GOOPTS: '-v -tags integration' |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 54 | + - uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7 |
| 55 | + - uses: ./.github/promci/actions/setup_environment |
| 56 | + - run: make build |
| 57 | + - run: make test |
| 58 | + |
| 59 | + |
| 60 | + build: |
| 61 | + name: Build Prometheus for common architectures |
| 62 | + runs-on: ubuntu-latest |
| 63 | + if: | |
| 64 | + !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) |
| 65 | + && |
| 66 | + !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-')) |
| 67 | + && |
| 68 | + !(github.event_name == 'push' && github.event.ref == 'refs/heads/main') |
| 69 | + && |
| 70 | + !(github.event_name == 'push' && github.event.ref == 'refs/heads/master') |
| 71 | + strategy: |
| 72 | + matrix: |
| 73 | + thread: [ 0, 1, 2 ] |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 76 | + - uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7 |
| 77 | + - uses: ./.github/promci/actions/build |
| 78 | + with: |
| 79 | + promu_opts: "-p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386" |
| 80 | + parallelism: 3 |
| 81 | + thread: ${{ matrix.thread }} |
| 82 | + |
| 83 | + build_all: |
| 84 | + name: Build Prometheus for all architectures |
| 85 | + runs-on: ubuntu-latest |
| 86 | + if: | |
| 87 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) |
| 88 | + || |
| 89 | + (github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-')) |
| 90 | + || |
| 91 | + (github.event_name == 'push' && github.event.ref == 'refs/heads/main') |
| 92 | + || |
| 93 | + (github.event_name == 'push' && github.event.ref == 'refs/heads/master') |
| 94 | + strategy: |
| 95 | + matrix: |
| 96 | + thread: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] |
| 97 | + |
| 98 | + # Whenever the Go version is updated here, .promu.yml |
| 99 | + # should also be updated. |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 102 | + - uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7 |
| 103 | + - uses: ./.github/promci/actions/build |
| 104 | + with: |
| 105 | + parallelism: 12 |
| 106 | + thread: ${{ matrix.thread }} |
| 107 | + |
| 108 | + publish_main: |
| 109 | + # https://github.com/prometheus/promci/blob/52c7012f5f0070d7281b8db4a119e21341d43c91/actions/publish_main/action.yml |
| 110 | + name: Publish main branch artifacts |
| 111 | + runs-on: ubuntu-latest |
| 112 | + needs: [test_go, build_all] |
| 113 | + if: | |
| 114 | + (github.event_name == 'push' && github.event.ref == 'refs/heads/main') |
| 115 | + || |
| 116 | + (github.event_name == 'push' && github.event.ref == 'refs/heads/master') |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 119 | + - uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7 |
| 120 | + - uses: ./.github/promci/actions/publish_main |
| 121 | + with: |
| 122 | + docker_hub_organization: prometheuscommunity |
| 123 | + docker_hub_login: ${{ secrets.docker_hub_login }} |
| 124 | + docker_hub_password: ${{ secrets.docker_hub_password }} |
| 125 | + quay_io_organization: prometheuscommunity |
| 126 | + quay_io_login: ${{ secrets.quay_io_login }} |
| 127 | + quay_io_password: ${{ secrets.quay_io_password }} |
| 128 | + |
| 129 | + publish_release: |
| 130 | + name: Publish release artefacts |
| 131 | + runs-on: ubuntu-latest |
| 132 | + needs: [test_go, build_all] |
| 133 | + if: | |
| 134 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) |
| 135 | + steps: |
| 136 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 137 | + - uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7 |
| 138 | + - uses: ./.github/promci/actions/publish_release |
| 139 | + with: |
| 140 | + docker_hub_organization: prometheuscommunity |
| 141 | + docker_hub_login: ${{ secrets.docker_hub_login }} |
| 142 | + docker_hub_password: ${{ secrets.docker_hub_password }} |
| 143 | + quay_io_organization: prometheuscommunity |
| 144 | + quay_io_login: ${{ secrets.quay_io_login }} |
| 145 | + quay_io_password: ${{ secrets.quay_io_password }} |
| 146 | + github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }} |
0 commit comments