Skip to content
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @insightsengineering/idr
66 changes: 66 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Lint 🧶

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
workflow_dispatch:

concurrency:
group: lint-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Lint:
name: SuperLinter 🦸🏻‍♀️
runs-on: ubuntu-latest
steps:
- name: Checkout Repo 🛎
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Lint Code Base 🕵🏻‍♀️
uses: github/super-linter/slim@v4
env:
LINTER_RULES_PATH: /
VALIDATE_ALL_CODEBASE: false
VALIDATE_GITHUB_ACTIONS: true
VALIDATE_MARKDOWN: true
VALIDATE_DOCKERFILE_HADOLINT: true
VALIDATE_GITLEAKS: true
DEFAULT_BRANCH: main
VALIDATE_JSON: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GoLint:
name: Lint Go Code 🔍
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- 1.21.6
steps:
- name: Checkout Repo 🛎
uses: actions/checkout@v3

- name: Setup Go 🐹
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true
cache-dependency-path: go.sum

- name: Lint Go Code 🕵🏻‍♂️
uses: golangci/golangci-lint-action@v3
with:
version: latest
only-new-issues: false
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release 🎈

on:
push:
tags:
- 'v*'
workflow_dispatch:

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io

permissions: read-all

jobs:
release:
name: Create Release 🥇
permissions:
contents: write
packages: write
defaults:
run:
shell: bash
runs-on: ubuntu-latest
steps:
- name: Checkout Repo 🛎
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go 🐹
uses: actions/setup-go@v3
with:
go-version: 1.21.6
cache: true
cache-dependency-path: go.sum

- name: Log in to the Container registry 🗝
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser 🚀
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

109 changes: 109 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Test 🧪

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
workflow_dispatch:

concurrency:
group: test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test 🔍
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- 1.21.6
defaults:
run:
shell: bash
steps:
- name: Checkout Repo 🛎
uses: actions/checkout@v3

- name: Setup Go 🐹
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true
cache-dependency-path: go.sum

- name: Run Tests 🧨
run: make test

- name: Check whether JUnit XML report exists 🚦
id: check-junit-xml
uses: andstor/file-existence-action@v2
with:
files: junit-report.xml

- name: Publish Unit Test Summary 📑
uses: EnricoMi/publish-unit-test-result-action@v2
id: test-results
if: steps.check-junit-xml.outputs.files_exists == 'true' && github.event_name == 'pull_request'
with:
check_name: Unit Tests Summary
junit_files: junit-report.xml

- name: Check whether coverage reports exists 💭
id: check-coverage-reports
uses: andstor/file-existence-action@v2
with:
files: >-
coverage.xml,
coverage.html

- name: Post coverage report 🗞
if: steps.check-coverage-reports.outputs.files_exists == 'true'
uses: insightsengineering/coverage-action@v2
with:
path: coverage.xml
threshold: 80
fail: false
publish: true
diff: true
coverage-reduction-failure: true
new-uncovered-statements-failure: true
continue-on-error: true

- name: Upload report 🔼
if: steps.check-coverage-reports.outputs.files_exists == 'true'
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: |
coverage.html
continue-on-error: true

compilation:
name: Build 🏗
strategy:
matrix:
go-version:
- 1.21.6
runs-on: ubuntu-latest
steps:
- name: Checkout Repo 🛎
uses: actions/checkout@v3

- name: Setup Go 🐹
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true
cache-dependency-path: go.sum

- name: Check if compilation works 🧱
run: make build
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@

# Go workspace file
go.work

dist/

coverage.html
coverage.xml
junit-report.xml
test-results.txt
32 changes: 32 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
issues:
exclude-rules:
- path: _test\.go
linters:
- dupl
- gosec
- goconst
linters:
enable:
- gosec
- unconvert
- gocyclo
- goconst
- goimports
- gocritic
- govet
- revive
linters-settings:
errcheck:
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: true
govet:
# report about shadowed variables
check-shadowing: true
gocyclo:
# minimal code complexity to report, 30 by default
min-complexity: 15
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
40 changes: 40 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Customization options: https://goreleaser.com/customization/
project_name: git-synchronizer
before:
hooks:
- go mod tidy
- go generate ./...
builds:
- no_unique_dist_dir: false
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w
- -X go.szostok.io/version.version={{.Version}}
- -X go.szostok.io/version.buildDate={{.Date}}
checksum:
name_template: '{{ .ProjectName }}_checksums.txt'
algorithm: sha512
changelog:
sort: asc
dockers:
- goos: linux
goarch: amd64
image_templates:
- "ghcr.io/insightsengineering/{{ .ProjectName }}:{{ .Version }}"
- "ghcr.io/insightsengineering/{{ .ProjectName }}:latest"
skip_push: false
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--build-arg=PROJECT_NAME={{ .ProjectName }}"
- "--platform=linux/amd64"
58 changes: 58 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
exclude: "^dist"

# See https://pre-commit.com/#pre-commit-configyaml---repos
# for more information on the format of the content below
repos:
# -------------------------
# Standard pre-commit hooks
# -------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
exclude: ".devcontainer/devcontainer.json"
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
args: [--allow-multiple-documents]
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: [--remove]
- id: mixed-line-ending
args: [--fix=lf]
- id: no-commit-to-branch
- id: requirements-txt-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

# ---------------------------
# Extra hooks for go projects
# ---------------------------
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-vet
- id: go-lint
- id: go-imports
- id: go-cyclo
args: [-over=15]
- id: no-go-testing
- id: golangci-lint
- id: go-critic
- id: go-unit-tests
- id: go-build
- id: go-mod-tidy
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM scratch
ARG PROJECT_NAME="git-synchronizer"
ENV PROJECT_NAME=${PROJECT_NAME}
COPY ${PROJECT_NAME} /
WORKDIR /
# hadolint ignore=DL3025
ENTRYPOINT ${PROJECT_NAME}
Loading