mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-16 09:16:38 +00:00
.github/workflows: add image building stage and unify workflows
additionally added myself as github action code owner for future PR reviews and swapped travis CI badge in README.md for GitHub actions one
This commit is contained in:
parent
94d0bd7e93
commit
a1361008ff
6 changed files with 176 additions and 138 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -1,3 +1,4 @@
|
||||||
* @prometheus-operator/prometheus-operator-reviewers
|
* @prometheus-operator/prometheus-operator-reviewers
|
||||||
|
|
||||||
/scripts/ @paulfantom
|
/scripts/ @paulfantom
|
||||||
|
/.github/workflows/ @paulfantom
|
||||||
|
|
129
.github/workflows/ci.yaml
vendored
Normal file
129
.github/workflows/ci.yaml
vendored
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
name: ci
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
env:
|
||||||
|
golang-version: '1.14'
|
||||||
|
kind-version: 'v0.8.1'
|
||||||
|
kind-image: 'kindest/node:v1.18.8' # Image defines which k8s version is used
|
||||||
|
jobs:
|
||||||
|
generate:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- macos-latest
|
||||||
|
- ubuntu-latest
|
||||||
|
name: Generate and format
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.golang-version }}
|
||||||
|
- run: make --always-make format generate && git diff --exit-code
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- macos-latest
|
||||||
|
- ubuntu-latest
|
||||||
|
name: Build operator binary
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.golang-version }}
|
||||||
|
- run: make operator
|
||||||
|
po-rule-migration:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Build Prometheus Operator rule config map to rule file CRDs CLI tool
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.golang-version }}
|
||||||
|
- run: cd cmd/po-rule-migration && go install
|
||||||
|
unit-tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Unit tests
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.golang-version }}
|
||||||
|
- run: make test-unit
|
||||||
|
extended-tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Extended tests
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.golang-version }}
|
||||||
|
- run: make test-long
|
||||||
|
e2e-tests:
|
||||||
|
name: E2E tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
suite: [alertmanager, prometheus, thanosruler]
|
||||||
|
include:
|
||||||
|
- suite: alertmanager
|
||||||
|
prometheus: "exclude"
|
||||||
|
alertmanager: ""
|
||||||
|
thanosruler: "exclude"
|
||||||
|
- suite: prometheus
|
||||||
|
prometheus: ""
|
||||||
|
alertmanager: "exclude"
|
||||||
|
thanosruler: "exclude"
|
||||||
|
- suite: thanosruler
|
||||||
|
prometheus: "exclude"
|
||||||
|
alertmanager: "exclude"
|
||||||
|
thanosruler: ""
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Start KinD
|
||||||
|
uses: engineerd/setup-kind@v0.4.0
|
||||||
|
with:
|
||||||
|
version: ${{ env.kind-version }}
|
||||||
|
image: ${{ env.kind-image }}
|
||||||
|
- name: Check cluster
|
||||||
|
run: |
|
||||||
|
kubectl cluster-info
|
||||||
|
kubectl get pods -A
|
||||||
|
- name: Build and load images
|
||||||
|
run: |
|
||||||
|
export SHELL=/bin/bash
|
||||||
|
make build image
|
||||||
|
kind load docker-image quay.io/prometheus-operator/prometheus-operator:$(git rev-parse --short HEAD)
|
||||||
|
kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:$(git rev-parse --short HEAD)
|
||||||
|
kubectl apply -f scripts/minikube-rbac.yaml
|
||||||
|
- name: Run tests
|
||||||
|
run: >
|
||||||
|
EXCLUDE_ALERTMANAGER_TESTS=${{ matrix.alertmanager }}
|
||||||
|
EXCLUDE_PROMETHEUS_TESTS=${{ matrix.prometheus }}
|
||||||
|
EXCLUDE_THANOS_TESTS=${{ matrix.thanosruler }}
|
||||||
|
make test-e2e
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Publish container images to quay.io
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
needs:
|
||||||
|
- generate
|
||||||
|
- build
|
||||||
|
- po-rule-migration
|
||||||
|
- unit-tests
|
||||||
|
- extended-tests
|
||||||
|
- e2e-tests
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Login to Quay.io
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: quay.io
|
||||||
|
username: ${{ secrets.QUAY_USERNAME }}
|
||||||
|
password: ${{ secrets.QUAY_PASSWORD }}
|
||||||
|
- name: Build images and push
|
||||||
|
run: ./scripts/push-docker-image.sh
|
77
.github/workflows/e2e.yaml
vendored
77
.github/workflows/e2e.yaml
vendored
|
@ -1,77 +0,0 @@
|
||||||
name: e2e
|
|
||||||
on:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
jobs:
|
|
||||||
prometheus:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: prometheus tests
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Start KinD
|
|
||||||
uses: engineerd/setup-kind@v0.4.0
|
|
||||||
with:
|
|
||||||
version: v0.8.1
|
|
||||||
image: kindest/node:v1.18.8
|
|
||||||
- name: Check cluster
|
|
||||||
run: |
|
|
||||||
kubectl cluster-info
|
|
||||||
kubectl get pods -A
|
|
||||||
- name: Build and load images
|
|
||||||
run: |
|
|
||||||
export SHELL=/bin/bash
|
|
||||||
make build image
|
|
||||||
kind load docker-image quay.io/prometheus-operator/prometheus-operator:$(git rev-parse --short HEAD)
|
|
||||||
kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:$(git rev-parse --short HEAD)
|
|
||||||
kubectl apply -f scripts/minikube-rbac.yaml
|
|
||||||
- name: Run tests
|
|
||||||
run:
|
|
||||||
EXCLUDE_ALERTMANAGER_TESTS=true EXCLUDE_THANOS_TESTS=true make test-e2e
|
|
||||||
alertmanager:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: alertmanager tests
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Start KinD
|
|
||||||
uses: engineerd/setup-kind@v0.4.0
|
|
||||||
with:
|
|
||||||
version: v0.8.1
|
|
||||||
image: kindest/node:v1.18.8
|
|
||||||
- name: Check cluster
|
|
||||||
run: |
|
|
||||||
kubectl cluster-info
|
|
||||||
kubectl get pods -A
|
|
||||||
- name: Build and load images
|
|
||||||
run: |
|
|
||||||
export SHELL=/bin/bash
|
|
||||||
make build image
|
|
||||||
kind load docker-image quay.io/prometheus-operator/prometheus-operator:$(git rev-parse --short HEAD)
|
|
||||||
kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:$(git rev-parse --short HEAD)
|
|
||||||
kubectl apply -f scripts/minikube-rbac.yaml
|
|
||||||
- name: Run tests
|
|
||||||
run:
|
|
||||||
EXCLUDE_PROMETHEUS_TESTS=true EXCLUDE_THANOS_TESTS=true make test-e2e
|
|
||||||
thanosruler:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: thanos ruler tests
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Start KinD
|
|
||||||
uses: engineerd/setup-kind@v0.4.0
|
|
||||||
with:
|
|
||||||
version: v0.8.1
|
|
||||||
image: kindest/node:v1.18.8
|
|
||||||
- name: Check cluster
|
|
||||||
run: |
|
|
||||||
kubectl cluster-info
|
|
||||||
kubectl get pods -A
|
|
||||||
- name: Build and load images
|
|
||||||
run: |
|
|
||||||
export SHELL=/bin/bash
|
|
||||||
make build image
|
|
||||||
kind load docker-image quay.io/prometheus-operator/prometheus-operator:$(git rev-parse --short HEAD)
|
|
||||||
kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:$(git rev-parse --short HEAD)
|
|
||||||
kubectl apply -f scripts/minikube-rbac.yaml
|
|
||||||
- name: Run tests
|
|
||||||
run:
|
|
||||||
EXCLUDE_ALERTMANAGER_TESTS=true EXCLUDE_PROMETHEUS_TESTS=true make test-e2e
|
|
60
.github/workflows/tests.yaml
vendored
60
.github/workflows/tests.yaml
vendored
|
@ -1,60 +0,0 @@
|
||||||
name: tests
|
|
||||||
on:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
jobs:
|
|
||||||
generate:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- macos-latest
|
|
||||||
- ubuntu-latest
|
|
||||||
name: generate and format
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '^1.14'
|
|
||||||
- run: make --always-make format generate && git diff --exit-code
|
|
||||||
build:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- macos-latest
|
|
||||||
- ubuntu-latest
|
|
||||||
name: build
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '^1.14'
|
|
||||||
- run: make operator
|
|
||||||
po-rule-migration:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Build Prometheus Operator rule config map to rule file CRDs CLI tool
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '^1.14'
|
|
||||||
- run: cd cmd/po-rule-migration && go install
|
|
||||||
unit-tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Unit tests
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '^1.14'
|
|
||||||
- run: make test-unit
|
|
||||||
extended-tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Extended tests
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '^1.14'
|
|
||||||
- run: make test-long
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Prometheus Operator
|
# Prometheus Operator
|
||||||
[](https://travis-ci.com/prometheus-operator/prometheus-operator)
|
[](https://github.com/prometheus-operator/prometheus-operator/actions)
|
||||||
[](https://goreportcard.com/report/prometheus-operator/prometheus-operator)
|
[](https://goreportcard.com/report/prometheus-operator/prometheus-operator)
|
||||||
[](http://slack.k8s.io/)
|
[](http://slack.k8s.io/)
|
||||||
|
|
||||||
|
|
45
scripts/push-docker-image.sh
Executable file
45
scripts/push-docker-image.sh
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# exit immediately when a command fails
|
||||||
|
set -e
|
||||||
|
# only exit with zero if all commands of the pipeline exit successfully
|
||||||
|
set -o pipefail
|
||||||
|
# error on unset variables
|
||||||
|
set -u
|
||||||
|
|
||||||
|
CPU_ARCHS="amd64 arm64 arm"
|
||||||
|
|
||||||
|
# Push `-dev` images unless commit is tagged
|
||||||
|
export REPO="${REPO:-"quay.io/prometheus-operator/prometheus-operator-dev"}"
|
||||||
|
export REPO_PROMETHEUS_CONFIG_RELOADER="${REPO_PROMETHEUS_CONFIG_RELOADER:-"quay.io/prometheus-operator/prometheus-config-reloader-dev"}"
|
||||||
|
if git describe --exact-match; then
|
||||||
|
export REPO="quay.io/prometheus-operator/prometheus-operator"
|
||||||
|
export REPO_PROMETHEUS_CONFIG_RELOADER="quay.io/prometheus-operator/prometheus-config-reloader"
|
||||||
|
export TAG="${GITHUB_REF#refs/tags/}"
|
||||||
|
else
|
||||||
|
# Use branch name as dev image tags
|
||||||
|
TAG="${GITHUB_REF#refs/heads/}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for arch in ${CPU_ARCHS}; do
|
||||||
|
make --always-make image GOARCH="$arch" TAG="${TAG}-$arch"
|
||||||
|
done
|
||||||
|
|
||||||
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
|
for r in ${REPO} ${REPO_PROMETHEUS_CONFIG_RELOADER}; do
|
||||||
|
# Images need to be on remote registry before creating manifests
|
||||||
|
for arch in $CPU_ARCHS; do
|
||||||
|
docker push "${r}:${TAG}-$arch"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create manifest to join all images under one virtual tag
|
||||||
|
docker manifest create -a "${r}:${TAG}" \
|
||||||
|
"${r}:${TAG}-amd64" \
|
||||||
|
"${r}:${TAG}-arm64" \
|
||||||
|
"${r}:${TAG}-arm"
|
||||||
|
|
||||||
|
# Annotate to set which image is build for which CPU architecture
|
||||||
|
for arch in $CPU_ARCHS; do
|
||||||
|
docker manifest annotate --arch "$arch" "${r}:${TAG}" "${r}:${TAG}-$arch"
|
||||||
|
done
|
||||||
|
docker manifest push "${r}:${TAG}"
|
||||||
|
done
|
Loading…
Add table
Reference in a new issue