Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
twelvelabs committed Jun 27, 2023
0 parents commit 0bb3fde
Show file tree
Hide file tree
Showing 51 changed files with 1,874 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See: https://editorconfig.org for info and editor plugins
root = true

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

[*.go]
indent_style = tab

[*.md]
indent_size = 2

[{Makefile,*.mk}]
indent_style = tab

[*.{yml,yaml}]
indent_size = 2
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax

* @twelvelabs
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
commit-message:
prefix: chore
include: scope

- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
commit-message:
prefix: fix
include: scope
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: build

on:
pull_request:
push:
branches:
- main
workflow_dispatch:


permissions:
contents: read
packages: write # if pushing docker images

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3.5.2
with:
fetch-depth: 0
# Need a PAT so that `make release-tag` will trigger the release workflow.
# See: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
token: ${{ github.ref_name == 'main' && secrets.GH_PAT || secrets.GITHUB_TOKEN }}

- name: Set up Homebrew
uses: homebrew/actions/setup-homebrew@a1377360f443cba4201fe7a591d1c60ba7ddab7a # pin@master

- name: Set up Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # pin@v4.0.0
with:
go-version-file: go.mod

- name: Install dependencies
run: make setup

- name: Build
run: make build

- name: Lint
run: make lint

- name: Test
run: make test

- name: Coverage
uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # pin@v3.1.3

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549 # pin@v5.2.0
with:
gpg_private_key: ${{ secrets.GH_COMMIT_SIGNING_KEY }}
passphrase: ${{ secrets.GH_COMMIT_SIGNING_PASS }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true

- name: Create release tag
# Change to support different release channels
# Versions from a non-main branch will look like: `v.0.0.0-branch-name`.
if: contains(fromJSON('["main", "beta"]'), github.ref_name)
run: make release-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: release

on:
push:
tags:
- "v*"

permissions:
contents: read

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3.5.2
with:
fetch-depth: 0

- name: Set up Homebrew
uses: homebrew/actions/setup-homebrew@a1377360f443cba4201fe7a591d1c60ba7ddab7a # pin@master

- name: Set up Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # pin@v4.0.0
with:
go-version-file: go.mod

- name: Install dependencies
run: make setup

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549 # pin@v5.2.0
with:
gpg_private_key: ${{ secrets.GH_COMMIT_SIGNING_KEY }}
passphrase: ${{ secrets.GH_COMMIT_SIGNING_PASS }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true

- name: Release
run: make release-publish
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
.cspellcache
.env
coverage.out
build/
dist/
57 changes: 57 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
linters:
enable-all: true
disable:
- cyclop
- dupl
- goerr113
- exhaustruct
- forbidigo
- forcetypeassert
- funlen
- gochecknoinits
- gochecknoglobals
- gocognit
- gocyclo
- godox
- gofumpt
- gomnd
- nlreturn
- paralleltest
- tagliatelle
- testpackage
- varnamelen
- wrapcheck
- wsl
# deprecated
- exhaustivestruct
- deadcode
- golint
- ifshort
- interfacer
- maligned
- nosnakecase
- scopelint
- structcheck
- varcheck

linters-settings:
exhaustive:
default-signifies-exhaustive: true

gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/twelvelabs/schemadoc) # Custom section: groups all imports with the specified Prefix.

lll:
line-length: 120

staticcheck:
checks:
- "all"
- "-SA5001"

severity:
case-sensitive: false
default-severity: error
89 changes: 89 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
project_name: schemadoc

before:
hooks:
- go mod tidy
- go generate ./...
- ./bin/build-completions.sh {{ .ProjectName }}
- ./bin/build-manpages.sh {{ .ProjectName }}

builds:
- env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
# `flags`, `ldflags`, and `mod_timestamp` are configured for reproducible builds.
# See: https://goreleaser.com/customization/builds/#reproducible-builds
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}}
mod_timestamp: "{{ .CommitTimestamp }}"

archives:
- id: default
builds_info:
group: root
owner: root
files:
- README.md
- LICENSE
- src: build/completions/*
dst: completions
strip_parent: true
- src: build/manpages/*
dst: manpages
strip_parent: true
format: tar.gz
format_overrides:
- goos: windows
format: zip
rlcp: true

brews:
- tap:
owner: twelvelabs
name: homebrew-tap
branch: main
folder: Formula
homepage: "https://github.com/twelvelabs/schemadoc"
description: "Generate markdown documents from JSON schema files"
license: "MIT"
install: |-
bin.install "schemadoc"
bash_completion.install "completions/schemadoc.bash" => "schemadoc"
zsh_completion.install "completions/schemadoc.zsh" => "_envctl"
fish_completion.install "completions/schemadoc.fish"
man1.install "manpages/schemadoc.1.gz"
test: |
system "#{bin}/schemadoc --version"
checksum:
name_template: "checksums.txt"
algorithm: sha256

gomod:
proxy: true

report_sizes: true

snapshot:
name_template: "{{ incpatch .Version }}-next" # cspell: disable-line

changelog:
use: github
sort: asc
groups:
- title: New features
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: Bug fixes
regexp: "^.*fix[(\\w)]*:+.*$"
order: 10
- title: Other work
order: 99
44 changes: 44 additions & 0 deletions .stylist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
excludes:
- build/**
- dist/**
- .cspellcache
output:
show_context: true
show_url: true
syntax_highlight: true
processors:
- preset: cspell
- preset: gitleaks
- preset: markdownlint
- preset: shellcheck
- preset: shfmt
- preset: gofmt
- preset: golangci-lint

- name: actionlint
includes:
- ".github/workflows/*.{yaml,yml}"
check:
command: "actionlint --format '{{json .}}'"
input: variadic
output: stdout
format: json
mapping:
level: "error"
path: "{{ .filepath }}"
start_line: "{{ .line }}"
start_column: "{{ .column }}"
end_line: "{{ .line }}"
end_column: "{{ .end_column }}"
rule_id: "{{ .kind }}"
rule_name: "{{ .kind }}"
rule_description: "{{ .message }}"

- name: pin-github-action
includes:
- ".github/workflows/*.{yaml,yml}"
fix:
command: pin-github-action
input: variadic
output: stdout
format: none
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"davidanson.vscode-markdownlint",
"editorconfig.editorconfig",
"foxundermoon.shell-format",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"timonwong.shellcheck",
"golang.Go"
]
}
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": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
Loading

0 comments on commit 0bb3fde

Please sign in to comment.