Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental committed Jan 1, 2024
2 parents f0a5ab1 + a7ac0a6 commit 450f22e
Show file tree
Hide file tree
Showing 9 changed files with 385 additions and 242 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ indent_style = tab

[Makefile]
indent_style = tab

[*.yaml]
indent_size = 2
37 changes: 37 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Docker
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: read
packages: write
jobs:
image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/xperimental/freifunk-exporter
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
29 changes: 29 additions & 0 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Go
on:
push: { }
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Test
run: make test
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM golang:1.15.6 AS builder
FROM golang:1.19-alpine AS builder

RUN apk add make git bash

WORKDIR /build

Expand All @@ -7,7 +9,7 @@ RUN go mod download
RUN go mod verify

COPY . /build/
RUN make
RUN make build-binary

FROM busybox
LABEL maintainer="Robert Jacob <[email protected]>"
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
.PHONY: all test build-binary install clean

SHELL = bash
DOCKER ?= docker
GO ?= go
GO_CMD := CGO_ENABLED=0 $(GO)
GIT_VERSION := $(shell git describe --tags --dirty || git rev-parse --short HEAD)
VERSION := $(GIT_VERSION:v%=%)
GIT_COMMIT := $(shell git rev-parse HEAD)

.PHONY: all
all: test build-binary

.PHONY: test
test:
$(GO_CMD) test -cover ./...

.PHONY: build-binary
build-binary:
$(GO_CMD) build -tags netgo -ldflags "-w -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT)" -o freifunk-exporter .

install:
install -D -t $(DESTDIR)/usr/bin/ freifunk-exporter
install -D -m 0644 -t $(DESTDIR)/lib/systemd/system/ contrib/freifunk-exporter.service
.PHONY: build-image
build-image:
$(DOCKER) build -t ghcr.io/xperimental/freifunk-exporter:$(VERSION) .

.PHONY: clean
clean:
rm -f freifunk-exporter
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is a small program to extract some metrics from a Freifunk network. It gath

## Usage

To compile the tool, first check that you have a recent Go installation (1.14 at the time of this writing). Then clone the repository and run `make` which will run the tests and compile the binary.
To compile the tool, first check that you have a recent Go installation (1.19 at the time of this writing). Then clone the repository and run `make` which will run the tests and compile the binary.

The tool accepts a few parameters, only the `--source-url` is required:

Expand Down
19 changes: 14 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
module github.com/xperimental/freifunk-exporter

go 1.15
go 1.19

require (
github.com/prometheus/client_golang v1.9.0
github.com/prometheus/procfs v0.3.0 // indirect
github.com/prometheus/client_golang v1.13.0
github.com/spf13/pflag v1.0.5
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
515 changes: 287 additions & 228 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
prefix = "freifunk_"

collectorUpDesc = prometheus.NewDesc(
prefix+"_collector_up",
prefix+"collector_up",
"Is set to 1 when the collector is able to get information.",
[]string{}, nil)
collectorTimestampDesc = prometheus.NewDesc(
Expand Down

0 comments on commit 450f22e

Please sign in to comment.