Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Move to github action (#250)
Browse files Browse the repository at this point in the history
* Move to github action

Signed-off-by: Julien Pivotto <[email protected]>
  • Loading branch information
roidelapluie authored Oct 11, 2022
1 parent 2cc962d commit 575d68c
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 73 deletions.
63 changes: 25 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
---
# Prometheus has switched to GitHub action.
# Circle CI is not disabled repository-wise so that previous pull requests
# continue working.
# This file does not generate any CircleCI workflow.

version: 2.1
orbs:
prometheus: prometheus/[email protected]
jobs:
test:
# Whenever the Go version is updated here, .promu.yml
# should also be updated.

executors:
golang:
docker:
- image: cimg/go:1.18
- image: busybox

jobs:
noopjob:
executor: golang

steps:
- prometheus/setup_environment
- setup_remote_docker
- run: make
- prometheus/store_artifact:
file: haproxy_exporter
- run:
command: "true"

workflows:
version: 2
haproxy_exporter:
prometheus:
jobs:
- test:
filters:
tags:
only: /.*/
- prometheus/build:
name: build
filters:
tags:
only: /.*/
- prometheus/publish_main:
context: org-context
requires:
- test
- build
filters:
branches:
only: main
- prometheus/publish_release:
context: org-context
requires:
- test
- build
- noopjob
triggers:
- schedule:
cron: "0 0 30 2 *"
filters:
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
branches:
ignore: /.*/
only:
- main
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: CI
on:
pull_request:
push:
jobs:
test:
name: Test
runs-on: ubuntu-latest
# Whenever the Go version is updated here, .promu.yml
# should also be updated.
container:
image: quay.io/prometheus/golang-builder:1.19-base
steps:
- uses: actions/checkout@v3
- uses: prometheus/[email protected]
- uses: ./.github/promci/actions/setup_environment
- run: make

build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
thread: [ 0, 1, 2 ]
steps:
- uses: actions/checkout@v3
- uses: prometheus/[email protected]
- uses: ./.github/promci/actions/build
with:
parallelism: 3
thread: ${{ matrix.thread }}

golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '<1.19'
- name: Lint
uses: golangci/[email protected]
with:
version: v1.49.0

publish_main:
name: Publish main branch artifacts
runs-on: ubuntu-latest
needs: [test, build]
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: prometheus/[email protected]
- uses: ./.github/promci/actions/publish_main
with:
docker_hub_login: ${{ secrets.docker_hub_login }}
docker_hub_password: ${{ secrets.docker_hub_password }}
quay_io_login: ${{ secrets.quay_io_login }}
quay_io_password: ${{ secrets.quay_io_password }}

publish_release:
name: Publish release arfefacts
runs-on: ubuntu-latest
needs: [test, build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- uses: prometheus/[email protected]
- uses: ./.github/promci/actions/publish_release
with:
docker_hub_login: ${{ secrets.docker_hub_login }}
docker_hub_password: ${{ secrets.docker_hub_password }}
quay_io_login: ${{ secrets.quay_io_login }}
quay_io_password: ${{ secrets.quay_io_password }}
30 changes: 0 additions & 30 deletions .github/workflows/golangci-lint.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
commas: disable
comments: disable
comments-indentation: disable
document-start: disable
indentation:
spaces: consistent
indent-sequences: consistent
line-length: disable
truthy:
ignore: |
.github/workflows/ci.yml
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ all:: vet checkmetrics common-all

include Makefile.common

PROMTOOL_DOCKER_IMAGE ?= $(shell docker pull -q quay.io/prometheus/prometheus:latest || echo quay.io/prometheus/prometheus:latest)
PROMTOOL ?= docker run -i --rm -w "$(PWD)" -v "$(PWD):$(PWD)" --entrypoint promtool $(PROMTOOL_DOCKER_IMAGE)
PROMETHEUS_VERSION=2.39.1
PROMTOOL ?= /tmp/prometheus-$(PROMETHEUS_VERSION).linux-amd64/promtool

.PHONY: checkmetrics
checkmetrics:
@echo ">> checking metrics for correctness"
if ! test -x $(PROMTOOL); then curl -sL -o - https://github.com/prometheus/prometheus/releases/download/v$(PROMETHEUS_VERSION)/prometheus-$(PROMETHEUS_VERSION).linux-amd64.tar.gz | tar -C /tmp -xzf - prometheus-$(PROMETHEUS_VERSION).linux-amd64/promtool; fi
for file in test/*.metrics; do $(PROMTOOL) check metrics < $$file || exit 1; done
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_

GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v1.45.2
GOLANGCI_LINT_VERSION ?= v1.49.0
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
# windows isn't included here because of the path separator being different.
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
Expand Down
3 changes: 1 addition & 2 deletions haproxy_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ func TestServerWithoutChecks(t *testing.T) {

// TestServerBrokenCSV ensures bugs in CSV format are handled gracefully. List of known bugs:
//
// * http://permalink.gmane.org/gmane.comp.web.haproxy/26561
//
// - http://permalink.gmane.org/gmane.comp.web.haproxy/26561
func TestServerBrokenCSV(t *testing.T) {
const data = `foo,FRONTEND,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,5007,0,,1,8,1,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,,,,,,,
foo,bug-missing-comma,0,0,0,0,,0,0,0,,0,,0,0,0,0,DRAIN (agent)1,1,0,0,0,5007,0,,1,8,1,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,,,,,,,
Expand Down

0 comments on commit 575d68c

Please sign in to comment.