Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
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
36 changes: 0 additions & 36 deletions .github/workflows/autorelease.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/build-test.yml

This file was deleted.

113 changes: 113 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Code Quality

on:
workflow_call:
inputs:
create_pr:
description: 'Create a pull request from the current branch to the target branch'
required: false
type: boolean
default: false
pr_target_branch:
description: 'Target branch for the created PR'
required: false
type: string
default: 'develop'
upload_executable:
description: 'Upload test executable as artifact'
required: false
type: boolean
default: false
secrets:
REPO_PAT:
description: 'Optional Personal Access Token to create pull requests when GITHUB_TOKEN is restricted'
required: false

permissions:
contents: write
pull-requests: write

jobs:
code-quality:
name: Code Quality Validation
runs-on: ${{ matrix.os }}
outputs:
has_warnings: ${{ steps.set-has-warnings.outputs.has_warnings }}
warnings_count: ${{ steps.set-has-warnings.outputs.warnings_count }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: [1.21.x]
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Check out code
uses: actions/checkout@v4

- name: Build
run: go build .
working-directory: cmd/hednsextractor/

- name: Test
run: go test ./...
working-directory: .

- name: Install
run: go install
working-directory: cmd/hednsextractor/

- name: Race Condition Tests
if: matrix.os == 'ubuntu-latest'
run: go build -race .
working-directory: cmd/hednsextractor/

- name: Install golangci-lint
if: matrix.os == 'ubuntu-latest'
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin v1.59.0
shell: bash

- name: Run golangci-lint and generate warnings
if: matrix.os == 'ubuntu-latest'
id: run-lint
run: |
set -euo pipefail
golangci-lint run ./... --out-format tab > all-warnings.md || true
shell: bash

- name: Expose Warnings Flag
id: set-has-warnings
if: always()
run: |
if [ -f all-warnings.md ] && [ -s all-warnings.md ]; then
echo "has_warnings=true" >> $GITHUB_OUTPUT
echo "warnings_count=$(wc -l < all-warnings.md | tr -d ' ')" >> $GITHUB_OUTPUT
else
echo "has_warnings=false" >> $GITHUB_OUTPUT
echo "warnings_count=0" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Upload Warnings Report
if: steps.set-has-warnings.outputs.has_warnings == 'true'
uses: actions/upload-artifact@v4
with:
name: warnings-report
path: all-warnings.md

sonarqube:
name: SonarQube Analysis
runs-on: ubuntu-latest
needs: code-quality
steps:
- name: Check out code
uses: actions/checkout@v4

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

26 changes: 0 additions & 26 deletions .github/workflows/dep-auto-merge.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/develop-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Develop Branch CI

permissions:
contents: write
pull-requests: write

on:
push:
branches: [develop]
pull_request:
branches: [main]

jobs:
quality-check:
uses: ./.github/workflows/code-quality.yml
with:
create_pr: true
pr_target_branch: main
permissions:
contents: write
pull-requests: write
21 changes: 21 additions & 0 deletions .github/workflows/feature-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Feature Branch CI

permissions:
contents: write
pull-requests: write

on:
push:
branches: ["feature/**"]
pull_request:
branches: [develop]

jobs:
quality-check:
uses: ./.github/workflows/code-quality.yml
with:
create_pr: true
pr_target_branch: develop
permissions:
contents: write
pull-requests: write
16 changes: 16 additions & 0 deletions .github/workflows/main-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Main Branch CI

on:
pull_request:
branches: [main]

permissions:
contents: write
pull-requests: write

jobs:
quality-check:
uses: ./.github/workflows/code-quality.yml
permissions:
contents: write
pull-requests: write
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
name: Semantic Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github

- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release

# Observações:
# - semantic-release começará a partir da tag v1.0.7 já existente na main.
# - Releases automáticos apenas em main.
# - Plugins changelog/git/github já incluídos para integração completa.
# - Certifique-se de que o GITHUB_TOKEN tem permissões de write:packages, write:repo_hook, etc.
22 changes: 22 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "bash ./update_version.sh ${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
"assets": ["utils/banner.go", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}
],
"@semantic-release/github"
]
}
14 changes: 7 additions & 7 deletions cmd/hednsextractor/hednsextractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ func main() {
if utils.OptionCmd.Vtscore {
virustotal := utils.Virustotal{}
result.VtScore = virustotal.GetVtReport(result.Domain)
if score, err := strconv.ParseUint(utils.OptionCmd.VtscoreValue, 10, 64); err == nil {
if result.VtScore < score {
continue
}
} else {
score, err := strconv.ParseUint(utils.OptionCmd.VtscoreValue, 10, 64)
if err != nil {
gologger.Fatal().Msg("Invalid parameter value for vt-score")
}
if result.VtScore < score {
continue
}
}

var output = prepareOutput(result, bMatchedDomain, bMatchedPTR)
Expand All @@ -86,9 +86,9 @@ func main() {

for _, output := range outputs {
if utils.OptionCmd.Silent {
gologger.Silent().Msgf(output)
gologger.Silent().Msgf("%s", output)
} else {
gologger.Info().Msgf(output)
gologger.Info().Msgf("%s", output)
}
}
}
Expand Down
Loading
Loading