-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6c47439
Showing
78 changed files
with
4,896 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: usememos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Backend Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- "go.mod" | ||
- "go.sum" | ||
- "**.go" | ||
|
||
jobs: | ||
go-static-checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.21 | ||
check-latest: true | ||
cache: true | ||
- name: Verify go.mod is tidy | ||
run: | | ||
go mod tidy -go=1.21 | ||
git diff --exit-code | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.54.1 | ||
args: --verbose --timeout=3m | ||
skip-cache: true | ||
|
||
go-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.21 | ||
check-latest: true | ||
cache: true | ||
- name: Run all tests | ||
run: go test -v ./... | tee test.log; exit ${PIPESTATUS[0]} | ||
- name: Pretty print tests running time | ||
run: grep --color=never -e '--- PASS:' -e '--- FAIL:' test.log | sed 's/[:()]//g' | awk '{print $2,$3,$4}' | sort -t' ' -nk3 -r | awk '{sum += $3; print $1,$2,$3,sum"s"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
# ******** NOTE ******** | ||
# We have attempted to detect the languages in your repository. Please check | ||
# the `language` matrix defined below to confirm you have the correct set of | ||
# supported CodeQL languages. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [main] | ||
paths: | ||
- "go.mod" | ||
- "go.sum" | ||
- "**.go" | ||
- "proto/**" | ||
- "web/**" | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: ["go", "javascript"] | ||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] | ||
# Learn more about CodeQL language support at https://git.io/codeql-language-support | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
# queries: ./path/to/local/query, your-org/your-repo/queries@main | ||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 https://git.io/JvXDl | ||
|
||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||
# and modify them (or add more) to build your code if your project | ||
# uses a compiled language | ||
|
||
#- run: | | ||
# make bootstrap | ||
# make release | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
run: | ||
timeout: 10m | ||
linters: | ||
enable: | ||
- errcheck | ||
- goimports | ||
- revive | ||
- govet | ||
- staticcheck | ||
- misspell | ||
- gocritic | ||
- sqlclosecheck | ||
- rowserrcheck | ||
- nilerr | ||
- godot | ||
- forbidigo | ||
- mirror | ||
- bodyclose | ||
|
||
issues: | ||
include: | ||
# https://golangci-lint.run/usage/configuration/#command-line-options | ||
exclude: | ||
- Rollback | ||
- logger.Sync | ||
- pgInstance.Stop | ||
- fmt.Printf | ||
- Enter(.*)_(.*) | ||
- Exit(.*)_(.*) | ||
|
||
linters-settings: | ||
goimports: | ||
# Put imports beginning with prefix after 3rd-party packages. | ||
local-prefixes: github.com/usememos/gomark | ||
revive: | ||
# Default to run all linters so that new rules in the future could automatically be added to the static check. | ||
enable-all-rules: true | ||
rules: | ||
# The following rules are too strict and make coding harder. We do not enable them for now. | ||
- name: file-header | ||
disabled: true | ||
- name: line-length-limit | ||
disabled: true | ||
- name: function-length | ||
disabled: true | ||
- name: max-public-structs | ||
disabled: true | ||
- name: function-result-limit | ||
disabled: true | ||
- name: banned-characters | ||
disabled: true | ||
- name: argument-limit | ||
disabled: true | ||
- name: cognitive-complexity | ||
disabled: true | ||
- name: cyclomatic | ||
disabled: true | ||
- name: confusing-results | ||
disabled: true | ||
- name: add-constant | ||
disabled: true | ||
- name: flag-parameter | ||
disabled: true | ||
- name: nested-structs | ||
disabled: true | ||
- name: import-shadowing | ||
disabled: true | ||
- name: early-return | ||
disabled: true | ||
- name: use-any | ||
disabled: true | ||
- name: exported | ||
disabled: true | ||
- name: unhandled-error | ||
disabled: true | ||
- name: if-return | ||
disabled: true | ||
gocritic: | ||
disabled-checks: | ||
- ifElseChain | ||
govet: | ||
settings: | ||
printf: # The name of the analyzer, run `go tool vet help` to see the list of all analyzers | ||
funcs: # Run `go tool vet help printf` to see the full configuration of `printf`. | ||
- common.Errorf | ||
enable-all: true | ||
disable: | ||
- fieldalignment | ||
- shadow | ||
forbidigo: | ||
forbid: | ||
- 'fmt\.Errorf(# Please use errors\.Wrap\|Wrapf\|Errorf instead)?' | ||
- 'ioutil\.ReadDir(# Please use os\.ReadDir)?' |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# These owners will be the default owners for everything in the repo. | ||
* @boojack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# gomark | ||
|
||
A markdown parser for memos. WIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package ast | ||
|
||
type NodeType uint32 | ||
|
||
const ( | ||
UnknownNode NodeType = iota | ||
// Block nodes. | ||
LineBreakNode | ||
ParagraphNode | ||
CodeBlockNode | ||
HeadingNode | ||
HorizontalRuleNode | ||
BlockquoteNode | ||
OrderedListNode | ||
UnorderedListNode | ||
TaskListNode | ||
MathBlockNode | ||
TableNode | ||
EmbeddedContentNode | ||
// Inline nodes. | ||
TextNode | ||
BoldNode | ||
ItalicNode | ||
BoldItalicNode | ||
CodeNode | ||
ImageNode | ||
LinkNode | ||
AutoLinkNode | ||
TagNode | ||
StrikethroughNode | ||
EscapingCharacterNode | ||
MathNode | ||
HighlightNode | ||
SubscriptNode | ||
SuperscriptNode | ||
ReferencedContentNode | ||
) | ||
|
||
type Node interface { | ||
// Type returns a node type. | ||
Type() NodeType | ||
|
||
// Restore returns a string representation of this node. | ||
Restore() string | ||
|
||
// PrevSibling returns a previous sibling node of this node. | ||
PrevSibling() Node | ||
|
||
// NextSibling returns a next sibling node of this node. | ||
NextSibling() Node | ||
|
||
// SetPrevSibling sets a previous sibling node to this node. | ||
SetPrevSibling(Node) | ||
|
||
// SetNextSibling sets a next sibling node to this node. | ||
SetNextSibling(Node) | ||
} | ||
|
||
type BaseNode struct { | ||
prevSibling Node | ||
|
||
nextSibling Node | ||
} | ||
|
||
func (n *BaseNode) PrevSibling() Node { | ||
return n.prevSibling | ||
} | ||
|
||
func (n *BaseNode) NextSibling() Node { | ||
return n.nextSibling | ||
} | ||
|
||
func (n *BaseNode) SetPrevSibling(node Node) { | ||
n.prevSibling = node | ||
} | ||
|
||
func (n *BaseNode) SetNextSibling(node Node) { | ||
n.nextSibling = node | ||
} | ||
|
||
func IsBlockNode(node Node) bool { | ||
switch node.Type() { | ||
case ParagraphNode, CodeBlockNode, HeadingNode, HorizontalRuleNode, BlockquoteNode, OrderedListNode, UnorderedListNode, TaskListNode, MathBlockNode, TableNode, EmbeddedContentNode: | ||
return true | ||
default: | ||
return false | ||
} | ||
} |
Oops, something went wrong.