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

Project revamp #109

Merged
merged 10 commits into from
Jan 28, 2024
Merged
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
6 changes: 6 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "v$version"
version_scheme = "semver"
version = "1.16.4"
update_changelog_on_bump = true
34 changes: 34 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:mantic

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends \
ca-certificates=20230311ubuntu1 \
apt-utils=2.7.3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update \
&& apt-get -y install --no-install-recommends \
git=1:2.40.1-1ubuntu1 \
golang=2:1.21~2 \
zsh=5.9-5ubuntu1 \
tree=2.1.1-1 \
neovim=0.7.2-7 \
wget=1.21.3-1ubuntu1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN export GOBIN=/usr/local/bin \
&& go install github.com/golangci/golangci-lint/cmd/[email protected] \
&& go install golang.org/x/tools/[email protected] \
&& go install github.com/goreleaser/[email protected] \
&& go install github.com/go-delve/delve/cmd/[email protected]

RUN wget -q -O /usr/local/bin/hadolint \
https://github.com/hadolint/hadolint/releases/download/v2.8.0/hadolint-Linux-x86_64 \
&& chmod +x /usr/local/bin/hadolint

ENV DEBIAN_FRONTEND=dialog

SHELL ["/bin/zsh", "-c"]
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Dnsdock dev container",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "zsh",
"icon": "terminal-bash"
}
}
},
"extensions": [
"ms-azuretools.vscode-docker",
"premparihar.gotestexplorer",
"golang.go",
"github.vscode-github-actions",
"KnisterPeter.vscode-commitizen",
"eamodio.gitlens",
"mhutchie.git-graph",
"yzhang.markdown-all-in-one",
"esbenp.prettier-vscode"
]
}
}
}
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

[*.go]
insert_final_newline = ignore
indent_style = tabs

[*.json]
insert_final_newline = ignore

[*.md]
trim_trailing_whitespace = false

File renamed without changes.
64 changes: 64 additions & 0 deletions .github/workflows/commit_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Commit Checks

on:
workflow_call:
inputs:
base_sha:
description: 'Base SHA to check from'
required: true
type: string
head_sha:
description: 'Head SHA to check until'
required: true
type: string

jobs:
commit_messages_checks:
name: Commit messages checks
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install devbox
uses: jetpack-io/[email protected]
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Check commit messages
run: devbox run -- cz check --rev-range ${{ inputs.base_sha }}..${{ inputs.head_sha }}

code_lint_checks:
name: Code lint checks
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/[email protected]
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Lint code
run: devbox run lint

test_checks:
name: Test checks
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/[email protected]
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Run tests
run: devbox run test
15 changes: 15 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: main branch workflow

on:
push:
branches:
- master

jobs:
commit_checks:
name: Commit checks
uses: ./.github/workflows/commit_checks.yml
with:
base_sha: ${{ github.event.before }}
head_sha: ${{ github.event.after }}

15 changes: 15 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: PR workflow

on:
pull_request:
branches:
- master

jobs:
commit_checks:
name: Commit checks
uses: ./.github/workflows/commit_checks.yml
with:
base_sha: ${{ github.event.pull_request.base.sha }}
head_sha: ${{ github.event.pull_request.head.sha }}

30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release workflow

on:
push:
branches-ignore:
- '**'
tags:
- 'v*'

permissions:
contents: write

jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/[email protected]
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Publish release
run: devbox run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/release.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release workflow

on:
push:
tags:
- "v*.*.*"

jobs:
release:
runs-on: ubuntu-latest
steps:

- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
changelog_increment_filename: CHANGELOG.md

- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: "CHANGELOG.md"
tag_name: ${{ env.REVISION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
dnsdock
dnsdock
.go
.devbox
dist/
60 changes: 60 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 1

before:
hooks:
- devbox run test
- devbox run lint

builds:
- env:
- CGO_ENABLED=0
main: ./cmd/dnsdock
goarch:
- amd64
- arm
goos:
- linux

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{ .Version }}_
{{ .Os }}_
{{ .Arch }}{{ if eq .Arch "arm" }}v{{ .Arm }}l{{ end }}

release:
prerelease: auto
draft: true
github:
owner: aacebedo
name: dnsdock

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

dockers:
- id: amd64 image
goos: linux

goarch: amd64

image_templates:
- aacebedo/dnsdock:latest
- aacebedo/dnsdock:{{ .Tag }}

# hooks:
# pre: docker login -u $DOCKER_USER -p $DOCKER_PASS
# post: docker push aacebedo/dnsdock:latest && docker push aacebedo/dnsdock:{{ .Tag }}
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
hooks:
- id: commitizen
18 changes: 0 additions & 18 deletions .project

This file was deleted.

3 changes: 0 additions & 3 deletions .tm_properties

This file was deleted.

15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run dnsdock",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "cmd/dnsdock/dnsdock.go"
}
]
}
Loading
Loading