Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/github.com/prometheu…
Browse files Browse the repository at this point in the history
…s/common-0.61.0
  • Loading branch information
MGSousa authored Dec 18, 2024
2 parents 12b894f + df1ce04 commit fcfd9ba
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 30 deletions.
28 changes: 2 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,17 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Prepare
id: prepare
if: ${{ !env.ACT }}
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Build image
id: build
if: ${{ env.ACT }}
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: prom-exporter:test

- name: Test Execution
if: ${{ env.ACT }}
run: |
timeout 10s docker run --rm prom-exporter:test \
-listen-address ":9201" \
-service-name "test" -service-uri "test" -service-port "5066" -service-metrics-path "stats" || code=$?
if [[ $code -ne 124 ]]; then
echo "Exporter stopped with ${code}. It was expected to run forever."
exit 1;
fi
- name: Release
if: ${{ !env.ACT }}
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean --timeout=5m
Expand All @@ -71,8 +48,7 @@ jobs:
VERSION: ${{ steps.prepare.outputs.tag_name }}

- name: Build and push
if: ${{ !env.ACT }}
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.release
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test prom-exporter

on:
pull_request:

permissions:
contents: write

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.21.x

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
id: build
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: prom-exporter:test

- name: Test Execution
run: |
timeout 10s docker run --rm prom-exporter:test \
-listen-address ":9201" \
-service-name "test" -service-uri "test" -service-port "5066" -service-metrics-path "stats" || code=$?
if [[ $code -ne 124 ]]; then
echo "Exporter stopped with ${code}. It was expected to run forever."
exit 1;
fi
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ archives:
checksum:
disable: true
snapshot:
name_template: "{{ .Tag }}"
version_template: "{{ .Tag }}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:alpine as build
FROM golang:alpine AS build

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ACT_URL = https://raw.githubusercontent.com/nektos/act/master/install.sh
ACT := $(shell command -v act)

test_ci:
@[ ! -x "$(ACT)" ] && (curl --proto '=https' --tlsv1.2 -sSf $(ACT_URL) | sudo bash) || true
@act push --rm
@[ ! -x "$(ACT)" ] && (curl --proto '=https' --tlsv1.2 -sSf $(ACT_URL) | sudo bash && sudo install ./bin/act /usr/local/bin/) || true
@act push --rm -j "test"

docker_build:
@docker build --no-cache -t $(BINARY) .
Expand Down

0 comments on commit fcfd9ba

Please sign in to comment.