-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Markus Blaschke <[email protected]>
- Loading branch information
0 parents
commit 278b331
Showing
21 changed files
with
1,219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor/ | ||
/myuplink-exporter | ||
/example | ||
/release-assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[{*.yml,*.yaml}] | ||
indent_size = 2 | ||
|
||
[*.conf] | ||
indent_size = 2 | ||
|
||
[*.go] | ||
indent_size = 4 | ||
indent_style = tab | ||
ij_continuation_indent_size = 4 | ||
ij_go_GROUP_CURRENT_PROJECT_IMPORTS = true | ||
ij_go_add_leading_space_to_comments = true | ||
ij_go_add_parentheses_for_single_import = true | ||
ij_go_call_parameters_new_line_after_left_paren = true | ||
ij_go_call_parameters_right_paren_on_new_line = true | ||
ij_go_call_parameters_wrap = off | ||
ij_go_fill_paragraph_width = 80 | ||
ij_go_group_stdlib_imports = true | ||
ij_go_import_sorting = goimports | ||
ij_go_keep_indents_on_empty_lines = false | ||
ij_go_local_group_mode = project | ||
ij_go_move_all_imports_in_one_declaration = true | ||
ij_go_move_all_stdlib_imports_in_one_group = true | ||
ij_go_remove_redundant_import_aliases = false | ||
ij_go_run_go_fmt_on_reformat = true | ||
ij_go_use_back_quotes_for_imports = false | ||
ij_go_wrap_comp_lit = off | ||
ij_go_wrap_comp_lit_newline_after_lbrace = true | ||
ij_go_wrap_comp_lit_newline_before_rbrace = true | ||
ij_go_wrap_func_params = off | ||
ij_go_wrap_func_params_newline_after_lparen = true | ||
ij_go_wrap_func_params_newline_before_rparen = true | ||
ij_go_wrap_func_result = off | ||
ij_go_wrap_func_result_newline_after_lparen = true | ||
ij_go_wrap_func_result_newline_before_rparen = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "ci/docker" | ||
|
||
on: [pull_request, workflow_dispatch] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set Swap Space | ||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c | ||
with: | ||
swap-size-gb: 12 | ||
|
||
- name: Run Golangci lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
args: --print-resources-usage | ||
|
||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ github.repository }},quay.io/${{ github.repository }} | ||
labels: | | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: false | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: "release/assets" | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set Swap Space | ||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c | ||
with: | ||
swap-size-gb: 12 | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
check-latest: true | ||
|
||
- name: Build | ||
run: | | ||
make release-assets | ||
- name: Upload assets to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ./release-assets/* | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
file_glob: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: "release/docker" | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'feature-**' | ||
- 'bugfix-**' | ||
tags: | ||
- '*.*.*' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set Swap Space | ||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c | ||
with: | ||
swap-size-gb: 12 | ||
|
||
- name: Run Golangci lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
args: --print-resources-usage | ||
|
||
build: | ||
name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}" | ||
needs: lint | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- | ||
Dockerfile: Dockerfile | ||
target: "final-static" | ||
suffix: "" | ||
latest: "auto" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set Swap Space | ||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c | ||
with: | ||
swap-size-gb: 12 | ||
|
||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ github.repository }},quay.io/${{ github.repository }} | ||
labels: | | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md | ||
flavor: | | ||
latest=${{ matrix.latest }} | ||
suffix=${{ matrix.suffix }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to Quay | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./${{ matrix.Dockerfile }} | ||
target: ${{ matrix.target }} | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: "schedule/docker" | ||
|
||
on: | ||
schedule: | ||
- cron: '0 6 * * 1' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set Swap Space | ||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c | ||
with: | ||
swap-size-gb: 12 | ||
|
||
- name: Run Golangci lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
args: --print-resources-usage | ||
|
||
build: | ||
name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}" | ||
needs: lint | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- | ||
Dockerfile: Dockerfile | ||
target: "final-static" | ||
suffix: "" | ||
latest: "auto" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set Swap Space | ||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c | ||
with: | ||
swap-size-gb: 12 | ||
|
||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ github.repository }},quay.io/${{ github.repository }} | ||
labels: | | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md | ||
flavor: | | ||
latest=${{ matrix.latest }} | ||
suffix=${{ matrix.suffix }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to Quay | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./${{ matrix.Dockerfile }} | ||
target: ${{ matrix.target }} | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor/ | ||
/myuplink-exporter | ||
/*.exe | ||
/release-assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
run: | ||
timeout: 120m | ||
|
||
linters: | ||
enable: | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- errorlint | ||
- exportloopref | ||
- gofmt | ||
- goimports | ||
- gosec | ||
|
||
linters-settings: | ||
gosec: | ||
excludes: [] | ||
confidence: low | ||
config: | ||
global: | ||
audit: true | ||
|
||
issues: {} | ||
|
||
output: | ||
sort-results: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
############################################# | ||
# Build | ||
############################################# | ||
FROM --platform=$BUILDPLATFORM golang:1.21-alpine as build | ||
|
||
RUN apk upgrade --no-cache --force | ||
RUN apk add --update build-base make git | ||
|
||
WORKDIR /go/src/github.com/webdevops/myuplink-exporter | ||
|
||
# Dependencies | ||
COPY go.mod go.sum . | ||
RUN go mod download | ||
|
||
# Compile | ||
COPY . . | ||
RUN make test | ||
ARG TARGETOS TARGETARCH | ||
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build | ||
|
||
############################################# | ||
# Test | ||
############################################# | ||
FROM gcr.io/distroless/static as test | ||
USER 0:0 | ||
WORKDIR /app | ||
COPY --from=build /go/src/github.com/webdevops/myuplink-exporter/myuplink-exporter . | ||
RUN ["./myuplink-exporter", "--help"] | ||
|
||
############################################# | ||
# Final | ||
############################################# | ||
FROM gcr.io/distroless/static as final-static | ||
ENV LOG_JSON=1 | ||
WORKDIR / | ||
COPY --from=test /app . | ||
USER 1000:1000 | ||
ENTRYPOINT ["/myuplink-exporter"] |
Oops, something went wrong.