Skip to content

Commit

Permalink
Merge branch 'feature/refactor' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
moutonjeremy committed Mar 26, 2021
2 parents 323bdac + 6899c92 commit 41c3133
Show file tree
Hide file tree
Showing 22 changed files with 1,146 additions and 455 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-go@v2
with:
go-version: '1.15'
go-version: '1.16'

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Build
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o github-actions-exporter
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=${{ steps.get_version.outputs.VERSION }}'" -o github-actions-exporter

- name: Create Release
id: create_release
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM golang:1.15 as builder

FROM golang:1.16 as builder

WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/app
RUN bash ./build.sh

FROM alpine:latest as release
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
Expand Down
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# github-actions-exporter
github-actions-exporter for prometheus

![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/spendeskplatform/github-actions-exporter)
![Docker Pulls](https://img.shields.io/docker/pulls/spendeskplatform/github-actions-exporter)
[![Go Report Card](https://goreportcard.com/badge/github.com/Spendesk/github-actions-exporter)](https://goreportcard.com/report/github.com/Spendesk/github-actions-exporter)

Container image : https://hub.docker.com/repository/docker/spendeskplatform/github-actions-exporter

## Information
If you want to monitor a public repository, you must put the public_repo option in the repo scope of your github token.

Expand All @@ -12,10 +18,11 @@ If you want to monitor a public repository, you must put the public_repo option
| Github Organizations | github_orgas, go | GITHUB_ORGAS | - | List all organizations you want get informations. Format \<orga1>,\<orga2>,\<orga3> (like test1,test2) |
| Github Repos | github_repos, grs | GITHUB_REPOS | - | List all repositories you want get informations. Format \<orga>/\<repo>,\<orga>/\<repo2>,\<orga>/\<repo3> (like test/test) |
| Exporter port | port, p | PORT | 9999 | Exporter port |
| Github Api URL | github_api_url, url | GITHUB_API_URL | api.github.com | Github API URL (primarily for Github Enterprise usage) |

## Exported stats

### github_job
### github_workflow_run_status
Gauge type

**Result possibility**
Expand All @@ -41,6 +48,32 @@ Gauge type
| workflow | Workflow Name |
| status | Workflow status (completed/in_progress) |

### github_workflow_run_duration_ms
Gauge type

**Result possibility**

| Gauge | Description |
|---|---|
| milliseconds | Number of milliseconds that a specific workflow run took time to complete. |

**Fields**

| Name | Description |
|---|---|
| event | Event type like push/pull_request/...|
| head_branch | Branch name |
| head_sha | Commit ID |
| node_id | Node ID (github actions) (mandatory ??) |
| repo | Repository like \<org>/\<repo> |
| run_number | Build id for the repo (incremental id => 1/2/3/4/...) |
| workflow_id | Workflow ID |
| workflow | Workflow Name |
| status | Workflow status (completed/in_progress) |

### github_job
> :warning: **This is a duplicate of the `github_workflow_run_status` metric that will soon be deprecated, do not use anymore.**
### github_runner_status
Gauge type
(If you have self hosted runner)
Expand Down Expand Up @@ -104,7 +137,7 @@ Gauge type
| repo | Repository like \<org>/\<repo> |
| status | Workflow status |

Es:
Example:

```
# HELP github_workflow_usage Number of billable seconds used by a specific workflow during the current billing cycle. Any job re-runs are also included in the usage. Only apply to workflows in private repositories that use GitHub-hosted runners.
Expand Down
11 changes: 11 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -x

VERSION=`git branch | grep '*' | awk '{print $2}'`
if [[ $VERSION == "master" ]];
then
VERSION=`git describe --tags --abbrev=0`
fi

CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=$VERSION'" -o bin/app
56 changes: 0 additions & 56 deletions config/config.go

This file was deleted.

12 changes: 9 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
module github-actions-exporter

go 1.13
go 1.16

require (
github.com/prometheus/client_golang v1.4.0
github.com/urfave/cli v1.22.2
github.com/fasthttp/router v1.3.9 // indirect
github.com/google/go-github/v33 v33.0.1-0.20210311004518-0540c33dca8b // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/prometheus/client_golang v1.9.0 // indirect
github.com/urfave/cli/v2 v2.3.0 // indirect
github.com/valyala/fasthttp v1.22.0 // indirect
golang.org/x/oauth2 v0.0.0-20210311163135-5366d9dc1934 // indirect
)
Loading

0 comments on commit 41c3133

Please sign in to comment.