Skip to content

Commit

Permalink
Migrate to actions (#9)
Browse files Browse the repository at this point in the history
* add ci workflow

* update settings

* Fix missing deps

* fixes linting issue

* Remove "

* bash error

* fix condition and push

* Add actions badge

* retire azure devops

* remove gitversion config

* Update image repos

* add alt text

* 🐳

* Update with note on ghcr move

* add extra check to push
  • Loading branch information
chelnak authored Sep 1, 2021
1 parent 8d2db92 commit 4671738
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 87 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: status-cake-exporter

on:
push:
tags:
- v*
pull_request:
branches:
- main

env:
IMAGE_NAME: status-cake-exporter

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Dependencies 🚧
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Lint 🍻
run: |
python -m flake8 exporter/ --max-line-length=120 --tee
# - name: Test ✅
# run: |
# python setup.py test

- name: Build image 🐳
run: docker build . --file Dockerfile --tag status-cake-exporter

- name: Log into registry 🐳
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image 🐳
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
if [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
docker tag $IMAGE_NAME $IMAGE_ID:$(echo $VERSION | sed -e 's/^v//')
# latest should always reflect the most recent tagged release
VERSION=latest
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
# main represents the latest build from main branch
VERSION=main
else
# dev represents the latest build from prs or branches
VERSION=dev
fi
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push -a $IMAGE_ID
env:
GITVERSION_MAJORMINORPATCH: ${{ steps.gitversion.outputs.majorMinorPatch }}

- name: Build Changelog 📝
if: ${{ github.ref == 'refs/heads/main' }}
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v1
with:
configuration: "changelog.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release 🚀
if: ${{ github.ref == 'refs/heads/main' }}
id: create_release
uses: ncipollo/release-action@v1
with:
name: status-cake-exporter
body: ${{steps.build_changelog.outputs.changelog}}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"python.pythonPath": "env/bin/python3",
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true
}
1 change: 0 additions & 1 deletion GitVersion.yml

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[![Build Status](https://craigg.visualstudio.com/Pipelines/_apis/build/status/status-cake-exporter?branchName=master)](https://craigg.visualstudio.com/Pipelines/_build/latest?definitionId=19&branchName=master)

# Status Cake Exporter

![status-cake-exporter](https://github.com/chelnak/status-cake-exporter/actions/workflows/ci.yml/badge.svg)

> :rotating_light: Container images have moved to ghcr.io/chelnak/status-cake-exporter
Status Cake Exporter is a Prometheus exporter for [StatusCake](https://www.statuscake.com/).

Metrics are exposed on port 8000 when using the provided examples/manifest.yml](examples/manifest.yml) in Kubernetes, e.g.
Expand Down Expand Up @@ -92,7 +94,7 @@ Data collected by Prometheus can be easily surfaced in Grafana.
Using the [Statusmap panel](https://grafana.com/grafana/plugins/flant-statusmap-panel) by [flant](https://github.com/flant/grafana-statusmap) you can create a basic status visualization based on uptime percentage:
![](examples/grafana.png)
![grafan](examples/grafana.png)
### PromQL
Expand Down
78 changes: 0 additions & 78 deletions azure-pipelines.yml

This file was deleted.

2 changes: 1 addition & 1 deletion chart/status-cake-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
image:
repository: chelnak/status-cake-exporter
repository: ghcr.io/chelnak/status-cake-exporter
tag: latest
# A list of ImagePullSecrets to use for the containers in this Chart
pullSecrets: []
Expand Down
2 changes: 1 addition & 1 deletion examples/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
spec:
containers:
- name: status-cake-exporter
image: chelnak/status-cake-exporter:latest
image: ghcr.io/chelnak/status-cake-exporter:latest
ports:
- containerPort: 8000
env:
Expand Down
2 changes: 2 additions & 0 deletions exporter/collectors/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

logger = logging.getLogger("test_collector")


def parse_test_response(r, m):
t = []
try:
Expand Down Expand Up @@ -49,6 +50,7 @@ def parse_test_details_response(r):

return t


class TestCollector(object):

def __init__(self, username, api_key, tags):
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake8==3.7.8
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
prometheus-client==0.7.1
requests==2.22.0
flake8==3.7.8
ConfigArgParse==0.14.0


0 comments on commit 4671738

Please sign in to comment.