Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.26 vngcloud v2 #3

Open
wants to merge 27 commits into
base: release-1.26
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/build-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Build and Release package
on:
push:
# Pattern matched against refs/tags
tags:
- "**" # Push events to every tag including hierarchical tags like v1.0/beta

jobs:
create_release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "${{ github.ref_name }}" \
--repo="$GITHUB_REPOSITORY" \
--title="${{ github.ref_name }}" \
--generate-notes

build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/[email protected]

- name: Install dependencies
run: sudo apt -y install rubygems && sudo gem install fpm && sudo apt install binutils && sudo apt-get install rpm -y

- name: Clear build directory
run: rm -rf ./build/

- name: Build
run: NIGHTLY=vmonitor make package include_packages="freebsd_amd64.tar.gz linux_amd64.tar.gz amd64.deb x86_64.rpm"
# run: NIGHTLY=vmonitor make package include_packages="freebsd_amd64.tar.gz linux_amd64.tar.gz amd64.deb x86_64.rpm linux_arm64.tar.gz arm64.deb aarch64.rpm freebsd_i386.tar.gz i386.deb linux_i386.tar.gz i386.rpm"

- name: Install Windows dependencies
run: go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest

- name: Debug
run: |
export PATH=${PATH}:~/go/bin
export PATH=${PATH}:`go env GOPATH`/bin
echo $PATH
goversioninfo -skip-versioninfo

- name: Build Windows package
run: |
export PATH=${PATH}:~/go/bin
export PATH=${PATH}:`go env GOPATH`/bin
echo $PATH
NIGHTLY=vmonitor make package include_packages="windows_amd64.zip"

# NIGHTLY=vmonitor make package include_packages="windows_i386.zip windows_amd64.zip windows_arm64.zip"

- name: Debug
run: ls -al ./build/dist/

- name: Upload files to a GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: for file in ./build/dist/*; do gh release upload "${{ github.ref_name }}" "$file" --repo="$GITHUB_REPOSITORY"; done

############## build and upload image
- name: Log in to the GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to the vCR
uses: docker/login-action@v3
with:
registry: vcr.vngcloud.vn
username: ${{ secrets.VCR_USER_PRO }}
password: ${{ secrets.VCR_PASSWORD_PRO }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
build-args: |
ARG_VERSION=${{ github.ref_name }}
ARG_GITHUB_REPOSITORY=${{ github.repository }}
context: ./docker
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.ref_name }}
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }}
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.ref_name }}
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }}
# labels: ${{ steps.metadata.outputs.labels }}

- name: Build and push Docker image Alpine
uses: docker/build-push-action@v5
with:
build-args: |
ARG_VERSION=${{ github.ref_name }}
ARG_GITHUB_REPOSITORY=${{ github.repository }}
context: ./docker/alpine
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.ref_name }}-alpine
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }}-alpine
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.ref_name }}-alpine
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }}-alpine
# labels: ${{ steps.metadata.outputs.labels }}
72 changes: 72 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI
on: push

env:
TMP_RELEASE: 1.26.0-1.0.0

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/[email protected]

- name: Install dependencies
run: sudo apt -y install rubygems && sudo gem install fpm && sudo apt install binutils && sudo apt-get install rpm -y

- name: Clear build directory
run: rm -rf ./build/

- name: Build
run: NIGHTLY=vmonitor make package include_packages="linux_amd64.tar.gz amd64.deb"

- name: Debug
run: ls -al ./build/dist/

- name: Upload files to a GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.TMP_RELEASE }}
run: for file in ./build/dist/*; do gh release upload "${{ env.TMP_RELEASE }}" "$file" --repo="$GITHUB_REPOSITORY" --clobber; done

############## build and upload image
- name: Log in to the GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to the vCR
uses: docker/login-action@v3
with:
registry: vcr.vngcloud.vn
username: ${{ secrets.VCR_USER_PRO }}
password: ${{ secrets.VCR_PASSWORD_PRO }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
build-args: |
ARG_VERSION=${{ env.TMP_RELEASE }}
ARG_GITHUB_REPOSITORY=${{ github.repository }}
context: ./docker
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }}
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }}
# labels: ${{ steps.metadata.outputs.labels }}

- name: Build and push Docker image Alpine
uses: docker/build-push-action@v5
with:
build-args: |
ARG_VERSION=${{ env.TMP_RELEASE }}
ARG_GITHUB_REPOSITORY=${{ github.repository }}
context: ./docker/alpine
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }}-alpine
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }}-alpine
# labels: ${{ steps.metadata.outputs.labels }}
13 changes: 2 additions & 11 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@ name: golangci-lint
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
# Trigger every day at 16:00 UTC
- cron: '0 16 * * *'
permissions:
contents: read # to fetch code (actions/checkout)
pull-requests: read # to fetch pull requests (golangci/golangci-lint-action)
- release-1.26-vngcloud-v2

jobs:
golangci:
Expand All @@ -20,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: "1.20"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ name: govulncheck
on:
push:
branches:
- master
schedule:
# Trigger every day at 16:00 UTC
- cron: '0 16 * * *'
- release-1.26-vngcloud-v2

jobs:
analyze:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Scan for Vulnerabilities in Code
uses: Templum/govulncheck-action@v0.10.0
uses: golang/govulncheck-action@v1
with:
go-version: '1.20'
vulncheck-version: v0.0.0-20230320232729-bfc1eaef17a4
package: ./...
go-version-input: 1.21.8
go-package: ./...
13 changes: 5 additions & 8 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ name: Lint Code Base
#############################
on:
push:
branches-ignore: [master, main]
# Remove the line above to run when pushing to master
pull_request:
branches: [master, main]
branches: ["release-1.26-vngcloud-v2"]

###############
# Set the Job #
Expand All @@ -45,7 +42,7 @@ jobs:
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
Expand All @@ -54,12 +51,12 @@ jobs:
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@v4.9.2
uses: super-linter/super-linter@v6.3.0
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
DEFAULT_BRANCH: release-1.26-vngcloud-v2
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: '.'
LINTER_RULES_PATH: "."
MARKDOWN_CONFIG_FILE: .markdownlint.yml
VALIDATE_MARKDOWN: true
VALIDATE_BASH: true
17 changes: 9 additions & 8 deletions .github/workflows/readme-linter.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: Lint plugin readmes
on:
# push:
# branches-ignore: master
pull_request:
branches: # Names of target branches, not source branches
- master
push:
branches:
- release-1.26-vngcloud-v2

jobs:
run-readme-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: "1.21.8"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34.4.2
uses: tj-actions/changed-files@v42
with:
base_sha: ${{ github.event.pull_request.base.sha }}
files: ./plugins/**/README.md
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/semantic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ jobs:
uses: influxdata/validate-semantic-github-messages/.github/workflows/semantic.yml@main
with:
CHECK_PR_TITLE_OR_ONE_COMMIT: true

20 changes: 17 additions & 3 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
.PHONY: build-package
build-package:
rm -rf ./build/
NIGHTLY=vmonitor make package include_packages="amd64.deb"

runn:
# ./telegraf --config telegraf_pro.conf
make build && ./telegraf --config telegraf_pro.conf

ifneq (,$(filter $(OS),Windows_NT Windows))
EXEEXT=.exe
endif
Expand Down Expand Up @@ -119,8 +128,12 @@ embed_readme_%:

.PHONY: config
config:
@echo "generating default config"
go run ./cmd/telegraf config > etc/telegraf.conf
@echo "generating default config $(GOOS)"
# go run ./cmd/telegraf config > etc/telegraf.conf

@if [ $(GOOS) != "windows" ]; then cp -rf etc/telegraf_linux.conf etc/telegraf.conf; fi
@if [ $(GOOS) = "windows" ]; then cp -rf etc/telegraf_windows.conf etc/telegraf.conf; fi


.PHONY: docs
docs: build_tools embed_readme_inputs embed_readme_outputs embed_readme_processors embed_readme_aggregators embed_readme_secretstores
Expand Down Expand Up @@ -333,10 +346,11 @@ darwin-arm64:
include_packages := $(mips) $(mipsel) $(arm64) $(amd64) $(armel) $(armhf) $(riscv64) $(s390x) $(ppc64le) $(i386) $(windows) $(darwin-amd64) $(darwin-arm64)

.PHONY: package
package: docs config $(include_packages)
package: docs $(include_packages)

.PHONY: $(include_packages)
$(include_packages):
@$(MAKE) config
if [ "$(suffix $@)" = ".zip" ]; then go generate cmd/telegraf/telegraf_windows.go; fi

@$(MAKE) install
Expand Down
31 changes: 31 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM buildpack-deps:bullseye-curl

RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends iputils-ping snmp procps lm-sensors libcap2-bin && \
rm -rf /var/lib/apt/lists/*

ARG ARG_VERSION
ENV TELEGRAF_VERSION $ARG_VERSION

ARG ARG_GITHUB_REPOSITORY
ENV GITHUB_REPOSITORY $ARG_GITHUB_REPOSITORY

RUN echo ${TELEGRAF_VERSION}

RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" && \
case "${dpkgArch##*-}" in \
amd64) ARCH='amd64';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armhf';; \
armel) ARCH='armel';; \
*) echo "Unsupported architecture: ${dpkgArch}"; exit 1;; \
esac && \
wget --no-verbose https://github.com/${GITHUB_REPOSITORY}/releases/download/${TELEGRAF_VERSION}/telegraf_nightly_${ARCH}.deb && \
dpkg -i telegraf_nightly_${ARCH}.deb && \
rm -f telegraf_nightly_${ARCH}.deb*

EXPOSE 8125/udp 8092/udp 8094

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf"]
Loading
Loading