mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 11:48:53 +00:00
Merge pull request #3475 from paulfantom/gh_actions
This commit is contained in:
commit
93896327b0
8 changed files with 141 additions and 167 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -1,3 +1,4 @@
|
|||
* @prometheus-operator/prometheus-operator-reviewers
|
||||
|
||||
/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
|
40
.travis.yml
40
.travis.yml
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
dist: xenial
|
||||
language: go
|
||||
go:
|
||||
- "1.14.x"
|
||||
go_import_path: github.com/prometheus-operator/prometheus-operator
|
||||
services:
|
||||
- docker
|
||||
before_install:
|
||||
- export PATH=$PATH:$HOME/.local/bin
|
||||
# k8s >= 1.18 requires conntrack, ebtables and socat.
|
||||
- sudo apt update -y
|
||||
- sudo apt install -y conntrack ebtables socat
|
||||
jobs:
|
||||
include:
|
||||
- name: "Sanity checks and tests"
|
||||
stage: test
|
||||
# Check generated contents are up to date and code & docs files are formatted.
|
||||
script: make --always-make format generate && git diff --exit-code
|
||||
- name: "Build Prometheus Operator rule config map to rule file CRDs CLI tool"
|
||||
script: cd cmd/po-rule-migration && go install
|
||||
- name: "Run unit tests"
|
||||
script: make test-unit
|
||||
- name: "Run extended tests"
|
||||
script: make test-long
|
||||
- name: "Run e2e tests (Alertmanager)"
|
||||
script: EXCLUDE_PROMETHEUS_TESTS=true EXCLUDE_THANOS_TESTS=true ./scripts/travis-e2e.sh
|
||||
- name: "Run e2e tests (Prometheus)"
|
||||
script: EXCLUDE_ALERTMANAGER_TESTS=true EXCLUDE_THANOS_TESTS=true ./scripts/travis-e2e.sh
|
||||
- name: "Run e2e tests (Thanos)"
|
||||
script: EXCLUDE_PROMETHEUS_TESTS=true EXCLUDE_ALERTMANAGER_TESTS=true ./scripts/travis-e2e.sh
|
||||
|
||||
- name: "Push Docker Image"
|
||||
stage: push-docker-image
|
||||
script: ./scripts/travis-push-docker-image.sh
|
||||
|
||||
stages:
|
||||
- test
|
||||
- name: push-docker-image
|
||||
if: type != pull_request
|
|
@ -1,5 +1,5 @@
|
|||
# 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)
|
||||
[](http://slack.k8s.io/)
|
||||
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
#!/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
|
||||
# print each command before executing it
|
||||
set -x
|
||||
|
||||
export MINIKUBE_VERSION=v1.9.2
|
||||
export KUBERNETES_VERSION=v1.18.1
|
||||
|
||||
sudo mount --make-rshared /
|
||||
sudo mount --make-rshared /proc
|
||||
sudo mount --make-rshared /sys
|
||||
|
||||
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && \
|
||||
chmod +x kubectl && \
|
||||
sudo mv kubectl /usr/local/bin/
|
||||
curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && \
|
||||
chmod +x minikube && \
|
||||
sudo mv minikube /usr/local/bin/
|
||||
|
||||
export MINIKUBE_HOME=$HOME
|
||||
export CHANGE_MINIKUBE_NONE_USER=true
|
||||
mkdir "${HOME}"/.kube || true
|
||||
touch "${HOME}"/.kube/config
|
||||
|
||||
export KUBECONFIG=$HOME/.kube/config
|
||||
|
||||
# minikube config
|
||||
minikube config set WantUpdateNotification false
|
||||
minikube config set WantReportErrorPrompt false
|
||||
minikube config set WantNoneDriverWarning false
|
||||
minikube config set vm-driver none
|
||||
minikube config view
|
||||
|
||||
# Setup Docker according to https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker
|
||||
cat > daemon.json <<EOF
|
||||
{
|
||||
"exec-opts": ["native.cgroupdriver=systemd"],
|
||||
"log-driver": "json-file",
|
||||
"log-opts": {
|
||||
"max-size": "100m"
|
||||
},
|
||||
"storage-driver": "overlay2"
|
||||
}
|
||||
EOF
|
||||
sudo mkdir -p /etc/docker
|
||||
sudo mv daemon.json /etc/docker/daemon.json
|
||||
|
||||
# Restart Docker
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart docker
|
||||
docker info
|
||||
|
||||
minikube version
|
||||
sudo minikube start --kubernetes-version=$KUBERNETES_VERSION
|
||||
sudo chown -R travis: /home/travis/.minikube/
|
||||
|
||||
minikube update-context
|
||||
|
||||
# waiting for node(s) to be ready
|
||||
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
|
||||
|
||||
kubectl apply -f scripts/minikube-rbac.yaml
|
|
@ -1,14 +0,0 @@
|
|||
#!/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
|
||||
# print each command before executing it
|
||||
set -x
|
||||
|
||||
export KUBECONFIG=$HOME/.kube/config
|
||||
|
||||
minikube version
|
||||
sudo minikube delete
|
|
@ -6,40 +6,24 @@ set -o pipefail
|
|||
# error on unset variables
|
||||
set -u
|
||||
|
||||
function defer {
|
||||
docker logout quay.io
|
||||
}
|
||||
trap defer EXIT
|
||||
|
||||
CPU_ARCHS="amd64 arm64 arm"
|
||||
|
||||
# Push to Quay '-dev' repo if it's not a git tag or master branch build.
|
||||
export REPO="${REPO:-"quay.io/prometheus-operator/prometheus-operator"}"
|
||||
export REPO_PROMETHEUS_CONFIG_RELOADER="${REPO_PROMETHEUS_CONFIG_RELOADER:-"quay.io/prometheus-operator/prometheus-config-reloader"}"
|
||||
|
||||
if [[ "${TRAVIS_TAG}" == "" ]] && [[ "${TRAVIS_BRANCH}" != master ]]; then
|
||||
export REPO="quay.io/prometheus-operator/prometheus-operator-dev"
|
||||
export REPO_PROMETHEUS_CONFIG_RELOADER="quay.io/prometheus-operator/prometheus-config-reloader-dev"
|
||||
# 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 both git tags and git branches 'TRAVIS_BRANCH' contains the name.
|
||||
export TAG="${TRAVIS_BRANCH}"
|
||||
|
||||
for arch in ${CPU_ARCHS}; do
|
||||
make --always-make image GOARCH="$arch" TAG="${TAG}-$arch"
|
||||
done
|
||||
|
||||
if [ "$TRAVIS" == "true" ]; then
|
||||
# Workaround for docker bug https://github.com/docker/for-linux/issues/396
|
||||
sudo chmod o+x /etc/docker
|
||||
fi
|
||||
|
||||
# TODO(paulfantom): Remove this after v0.43.0 release as it won't be needed
|
||||
if [ -z "${QUAY_COREOS_PASSWORD+x}" ]; then
|
||||
echo "${QUAY_COREOS_PASSWORD}" | docker login -u "${QUAY_COREOS_USERNAME}" --password-stdin quay.io
|
||||
else
|
||||
echo "${QUAY_PASSWORD}" | docker login -u "${QUAY_USERNAME}" --password-stdin quay.io
|
||||
fi
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
for r in ${REPO} ${REPO_PROMETHEUS_CONFIG_RELOADER}; do
|
||||
# Images need to be on remote registry before creating manifests
|
|
@ -1,19 +0,0 @@
|
|||
#!/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
|
||||
# print each command before executing it
|
||||
set -x
|
||||
|
||||
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
|
||||
"${SCRIPT_DIR}"/create-minikube.sh
|
||||
|
||||
make build image
|
||||
export TEST_RUN_ARGS="-failfast"
|
||||
make test-e2e
|
||||
|
||||
"${SCRIPT_DIR}"/delete-minikube.sh
|
Loading…
Add table
Add a link
Reference in a new issue