Skip to content

Commit

Permalink
update docs + fix githubactions (#862)
Browse files Browse the repository at this point in the history
* update docs
* fix GH CI
  • Loading branch information
dmachard authored Nov 5, 2024
1 parent 5cb029d commit d4e30e4
Show file tree
Hide file tree
Showing 19 changed files with 378 additions and 606 deletions.
24 changes: 8 additions & 16 deletions .github/workflows/bench-go.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: bench go
name: Go Benchmark

on:
push:
Expand All @@ -21,33 +21,25 @@ jobs:
dev:
strategy:
matrix:
os-version: ['ubuntu-22.04' ]
os-version: [ 'ubuntu-latest' ]
go-version: [ '1.21', '1.22', '1.23' ]
runs-on: ${{ matrix.os-version }}

steps:
- uses: actions/checkout@v4

- name: Configure environment to avoid toolchain installs
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"

- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "${{ matrix.go-version }}"

- name: Show Go version
run: |
go version
sudo go version
- name: Set up Go for root
if: runner.os != 'macOS'
run: |
which go
sudo which go
sudo ln -sf `which go` `sudo which go` || true
- name: Show Go version
run: |
go version
sudo go version
- name: Bench dnsutils
run: |
cd dnsutils/
Expand Down
48 changes: 0 additions & 48 deletions .github/workflows/benchmark.yml

This file was deleted.

133 changes: 47 additions & 86 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: go build
name: Go Cross-Platform Build

on:
push:
Expand All @@ -18,8 +18,7 @@ permissions:
contents: read

jobs:

makefile:
makefile-build:
runs-on: ubuntu-latest

strategy:
Expand All @@ -28,9 +27,14 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Configure environment to avoid toolchain installs
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"

- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "${{ matrix.go-version }}"

- name: build binary from makefile
run: make build
Expand All @@ -41,98 +45,55 @@ jobs:
- name: dep+build from makefile
run: make

go-ubuntu:
runs-on: ubuntu-latest

go-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ['1.21', '1.22', '1.23']
goos: [linux, freebsd, darwin, windows]
exclude:
- { os: macos-latest, goos: linux }
- { os: macos-latest, goos: freebsd }
- { os: macos-latest, goos: windows }
- { os: ubuntu-latest, goos: darwin }
- { os: ubuntu-latest, goos: windows }
- { os: windows-latest, goos: linux }
- { os: windows-latest, goos: freebsd }
- { os: windows-latest, goos: darwin }

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v4

- name: build binary
run: |
go mod edit -go=${{ matrix.go-version }}
go mod tidy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go
- name: Configure environment to avoid toolchain installs
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"

go-freebsd:
- uses: actions/setup-go@v5
with:
go-version: "${{ matrix.go-version }}"

- name: Build binary
run: |
if [[ "${{ matrix.os }}" == 'windows-latest' ]]; then
set CGO_ENABLED=0
go build -ldflags="-s -w" -o go-dnscollector.exe .
else
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go
fi
shell: bash

docker-build:
runs-on: ubuntu-latest

strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
platform: [linux/amd64, linux/386]

- name: build binary
run: |
go mod edit -go=${{ matrix.go-version }}
go mod tidy
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go
# for macos and window, limit the build to the latest version
go-macos:
runs-on: macos-latest

strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: build binary
run: |
go mod edit -go=${{ matrix.go-version }}
go mod tidy
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go
go-win:
runs-on: windows-latest

strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: build binary
run: |
set CGO_ENABLED=0
go mod edit -go=${{ matrix.go-version }}
go mod tidy
go build -ldflags="-s -w" -o go-dnscollector.exe .
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build the Docker image
run: |
docker build --build-arg VERSION=dev . --file Dockerfile -t go-dnscollector
docker32b:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Build the Docker image
run: |
docker build --build-arg VERSION=dev . --platform linux/386 --file Dockerfile -t go-dnscollector
- name: Build the Docker image
run: |
PLATFORM=${{ matrix.platform }}
TAG=$(echo "$PLATFORM" | tr '/' '-')
docker build --build-arg VERSION=dev . --platform $PLATFORM --file Dockerfile -t go-dnscollector:$TAG
18 changes: 10 additions & 8 deletions .github/workflows/golint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: go lint
name: Go Linter

on:
push:
Expand All @@ -15,21 +15,23 @@ on:
- main

permissions:
contents: read
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests

env:
GO_VERSION: "1.23"
GOLANGCI_LINT_VERSION: "v1.61.0"

jobs:
linter:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: "${{ env.GO_VERSION }}"
# workaround: when the files to be extracted are already present,
# tar extraction in Golangci Lint fails with the "File exists"
# https://github.com/golangci/golangci-lint-action/issues/807
Expand All @@ -38,6 +40,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: "v1.61.0"
version: "${{ env.GOLANGCI_LINT_VERSION }}"
args: --timeout 3m --verbose

7 changes: 5 additions & 2 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: go releaser
name: Go Releaser
on:
push:
tags:
Expand All @@ -7,6 +7,9 @@ on:
permissions:
contents: read

env:
GO_VERSION: "1.23"

jobs:
goreleaser:
permissions:
Expand All @@ -19,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
go-version: "${{ env.GO_VERSION }}"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: docker push
name: Docker Push

on:
release:
Expand Down
Loading

0 comments on commit d4e30e4

Please sign in to comment.