Skip to content

Commit

Permalink
Merge branch 'release/v1.7.0-beta1'
Browse files Browse the repository at this point in the history
  • Loading branch information
moutonjeremy committed Mar 26, 2021
2 parents e54fbdd + 41c3133 commit 5148952
Show file tree
Hide file tree
Showing 21 changed files with 1,111 additions and 500 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
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
64 changes: 0 additions & 64 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
)
608 changes: 599 additions & 9 deletions go.sum

Large diffs are not rendered by default.

55 changes: 12 additions & 43 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,59 +1,28 @@
/*
Main application package
*/
package main

import (
"fmt"
"log"
"net/http"
"os"
"strconv"

"github.com/prometheus/client_golang/prometheus"
"github.com/urfave/cli/v2"

"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/urfave/cli"

"github-actions-exporter/config"
"github-actions-exporter/metrics"
"github-actions-exporter/pkg/config"
"github-actions-exporter/pkg/server"
)

var version = "v1.6.0"
var (
version = "development"
)

// main init configuration
func main() {
app := cli.NewApp()
app.Name = "github-actions-exporter"
app.Flags = config.NewContext()
app.Action = runWeb
app.Flags = config.InitConfiguration()
app.Version = version
app.Action = server.RunServer

app.Run(os.Args)
}

// runWeb start http server
func runWeb(ctx *cli.Context) {
go metrics.WorkflowsCache()
go metrics.GetRunnersFromGithub()
go metrics.GetRunnersOrganizationFromGithub()
go metrics.GetWorkflowRunsFromGithub()
go metrics.GetBillableFromGithub()

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "/metrics")
})
http.Handle("/metrics", promhttp.Handler())
log.Printf("starting exporter with port %v", config.Port)
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(config.Port), nil))
}

// init prometheus metrics
func init() {
prometheus.MustRegister(metrics.RunnersGauge)
prometheus.MustRegister(metrics.RunnersOrganizationGauge)
prometheus.MustRegister(metrics.WorkflowRunStatusGauge)
prometheus.MustRegister(metrics.WorkflowRunStatusDeprecatedGauge)
prometheus.MustRegister(metrics.WorkflowRunDurationGauge)
prometheus.MustRegister(metrics.WorkflowBillGauge)
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
73 changes: 0 additions & 73 deletions metrics/get_billable_from_github.go

This file was deleted.

70 changes: 0 additions & 70 deletions metrics/get_runners_from_github.go

This file was deleted.

Loading

0 comments on commit 5148952

Please sign in to comment.