-
Notifications
You must be signed in to change notification settings - Fork 0
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 503ea87
Showing
19 changed files
with
506 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,27 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
tab_width = 4 | ||
indent_size = 4 | ||
max_line_length = 120 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[{*.md,LICENSE}] | ||
max_line_length = 80 | ||
trim_trailing_whitespace = false | ||
|
||
[{*.yml,*.yaml,*.json,*.js,*.ts,.prettierrc,*.html,*.css,*.scss}] | ||
indent_size = 2 | ||
tab_width = 2 | ||
|
||
[{*.go}] | ||
# Go uses tabs and gofmt emits them by default. | ||
indent_style = tab | ||
|
||
[{Makefile,.gitmodules}] | ||
# Makefiles and .gitmodules must (!) use tabs. | ||
indent_style = tab |
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,34 @@ | ||
module.exports = { | ||
rules: { | ||
'body-leading-blank': [2, 'always'], | ||
'body-max-line-length': [2, 'always', 100], | ||
'header-max-length': [2, 'always', 100], | ||
'scope-case': [2, 'always', 'lower-case'], | ||
'subject-case': [ | ||
2, | ||
'never', | ||
['start-case', 'pascal-case', 'upper-case'], | ||
], | ||
'subject-empty': [2, 'never'], | ||
'subject-full-stop': [2, 'never', '.'], | ||
'type-enum': [ | ||
2, | ||
'always', | ||
[ | ||
'chore', | ||
'build', | ||
'ci', | ||
'docs', | ||
'feat', | ||
'feat!', | ||
'fix', | ||
'perf', | ||
'refactor', | ||
'test' | ||
], | ||
], | ||
'type-case': [2, 'always', 'lower-case'], | ||
'type-empty': [2, 'never'], | ||
'signed-off-by': [2, 'always'] | ||
} | ||
}; |
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,12 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/.github/workflows" | ||
schedule: | ||
interval: "daily" |
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,25 @@ | ||
name: Lint commit message | ||
|
||
on: | ||
push: | ||
branches: ["**"] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup node 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
check-latest: true | ||
|
||
- name: Install commitlint | ||
run: npm install -g @commitlint/cli @commitlint/config-conventional | ||
|
||
- name: Lint commit message | ||
run: echo "${{ github.event.head_commit.message }}" | commitlint --config .github/commitlint.config.js |
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,60 @@ | ||
name: Go Workflow (Push) | ||
|
||
on: | ||
push: | ||
branches: ["**"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23" | ||
check-latest: true | ||
|
||
- name: Build | ||
run: go build ./... | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23" | ||
check-latest: true | ||
|
||
- name: Test | ||
run: go test -json ./... | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23" | ||
check-latest: true | ||
|
||
- name: Format | ||
run: | | ||
OUT="$(go fmt $(go list ./... | grep -v /vendor/) 2>&1)" | ||
if [ -n "$OUT" ]; then | ||
echo "The following files are not correctly formatted" | ||
echo "${OUT}" | ||
exit 1 | ||
fi |
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,60 @@ | ||
name: Go Workflow (Release) | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23" | ||
check-latest: true | ||
|
||
- name: Build | ||
run: go build ./... | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23" | ||
check-latest: true | ||
|
||
- name: Test | ||
run: go test -json ./... | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23" | ||
check-latest: true | ||
|
||
- name: Format | ||
run: | | ||
OUT="$(go fmt $(go list ./... | grep -v /vendor/) 2>&1)" | ||
if [ -n "$OUT" ]; then | ||
echo "The following files are not correctly formatted" | ||
echo "${OUT}" | ||
exit 1 | ||
fi |
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,30 @@ | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
go.work.sum | ||
|
||
# env file | ||
.env | ||
|
||
.DS_Store | ||
.idea/ | ||
*.iml | ||
.settings |
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,12 @@ | ||
{ | ||
"recommendations": [ | ||
"streetsidesoftware.code-spell-checker", | ||
"editorconfig.editorconfig", | ||
"davidanson.vscode-markdownlint", | ||
"sonarsource.sonarlint-vscode", | ||
"wayou.vscode-todo-highlight", | ||
"redhat.vscode-yaml", | ||
"ms-vscode.makefile-tools", | ||
"golang.go" | ||
] | ||
} |
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,15 @@ | ||
{ | ||
"cSpell.language": "en,de", | ||
"cSpell.words": [ | ||
"commitlint", | ||
"github", | ||
"gomod", | ||
"yannickkirschen" | ||
], | ||
"editor.formatOnSave": true, | ||
"editor.wordWrap": "on", | ||
"editor.rulers": [ | ||
80, | ||
120 | ||
] | ||
} |
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,8 @@ | ||
{ | ||
"checkRunSettings": { | ||
"vulnerableCheckRunConclusionLevel": "failure" | ||
}, | ||
"issueSettings": { | ||
"minSeverityLevel": "LOW" | ||
} | ||
} |
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,5 @@ | ||
# Code of Conduct | ||
|
||
Actually, the author is hungry and does not want to write a novel here. So, | ||
please just act like a normal human and treat others the same way as you want to | ||
be treated. |
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,22 @@ | ||
# Contributing | ||
|
||
When contributing to this repository, please first discuss the change in the | ||
discussions. | ||
|
||
Please note we have a code of conduct, please follow it in all your interactions | ||
with the project. | ||
|
||
## Coding | ||
|
||
1. Fork the repository. | ||
2. Make your changes on a dedicated branch. | ||
3. Commit your changes according | ||
to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0). | ||
Please try to only make one commit. Squash/rebase if you made a bunch of | ||
fix-up-commits! Commits will be linted on every push. | ||
4. Open up a pull request. | ||
5. Merge the pull request and make a [release](#release) if required. | ||
|
||
## Release | ||
|
||
Ask the maintainer how to make a release. |
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,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
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,43 @@ | ||
# State Machine | ||
|
||
[![Lint commit message](https://github.com/yannickkirschen/state-machine/actions/workflows/commit-lint.yml/badge.svg)](https://github.com/yannickkirschen/state-machine/actions/workflows/commit-lint.yml) | ||
[![Push](https://github.com/yannickkirschen/state-machine/actions/workflows/push.yml/badge.svg)](https://github.com/yannickkirschen/state-machine/actions/workflows/push.yml) | ||
[![Release](https://github.com/yannickkirschen/state-machine/actions/workflows/release.yml/badge.svg)](https://github.com/yannickkirschen/state-machine/actions/workflows/release.yml) | ||
[![GitHub release](https://img.shields.io/github/release/yannickkirschen/state-machine.svg)](https://github.com/yannickkirschen/state-machine/releases/) | ||
|
||
State Machine is a Golang library implementing a [finite-state machine](https://en.wikipedia.org/wiki/Finite-state_machine). | ||
|
||
## Usage | ||
|
||
Basic usage works as follows: | ||
|
||
1. Create a machine with an initial state. | ||
2. Set all possible transitions between states. | ||
3. Optional: Set enter end exit actions. | ||
4. Transition from state to state ;) | ||
|
||
Here is an example code based on the very simple use-case of a door: | ||
|
||
```go | ||
// Signature: <initial state> | ||
machine := fsm.NewMachine("close") | ||
|
||
// Signature: <current state, input event, next state> | ||
machine.SetTransition("open", "close-door", "close") | ||
machine.SetTransition("close", "open-door", "open") | ||
|
||
machine.SetEnterAction(func(last, new fsm.State) error { | ||
fmt.Printf("Enter '%s' coming from '%s'\n", new, last) | ||
return nil | ||
}) | ||
|
||
machine.SetExitAction(func(current, next fsm.State) error { | ||
fmt.Printf("Leaving '%s' going to '%s'\n", current, next) | ||
return nil | ||
}) | ||
|
||
// Signature: <input event> | ||
if err := machine.Transition("open-door"); err != nil { | ||
panic(err) | ||
} | ||
``` |
Oops, something went wrong.