Skip to content

Commit

Permalink
ci: add github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kilianpaquier committed Feb 26, 2024
1 parent f278105 commit d3d6fc2
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .craft
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
license: mit
ci: github
maintainers:
- url: kilianpaquier.com
name: kilianpaquier
no_api: true
no_chart: true
no_ci: true
no_sonar: true
25 changes: 25 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Code generated by craft; DO NOT EDIT.

name: Go Dependency Submission
run-name: Go Dependency Submission

on:
push:
branches:
- main

permissions:
contents: write

jobs:

go-dependencies-submission:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/go-dependency-submission@v2
with:
go-mod-path: go.mod
81 changes: 81 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Code generated by craft; DO NOT EDIT.

name: Go Integration
run-name: Go Integration

on:
- push
- workflow_dispatch

jobs:

version:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.semantic_release.outputs.new_release_version }}
steps:
- uses: actions/checkout@v4
- id: sha
run: echo "sha=$(echo "${{ github.ref_name }}" | sha256sum | cut -c -8)" >> $GITHUB_OUTPUT
- id: semantic_release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/commit-analyzer
@semantic-release/exec
@semantic-release/git
@semantic-release/github
@semantic-release/release-notes-generator
conventional-changelog-conventionalcommits
semantic-release-license
ci: false
dry_run: true
tag_format: v${version}
branches: |
[
"(master|main)",
"v+([0-9])?(.{+([0-9]),x}).x",
{ "name": "next", "prerelease": true },
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true },
{ "name": "staging", "prerelease": "beta" },
{ "name": "develop", "prerelease": "alpha" },
{ "name": "${{ github.ref_name }}", "prerelease": "${{ steps.sha.outputs.sha }}" }
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo ${{ steps.semantic_release.outputs.new_release_version }}

go-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
- uses: golangci/golangci-lint-action@v4
with:
args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format colored-line-number

go-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
- run: CGO_ENABLED="0" go test ./... -coverpkg=./... -covermode=count -coverprofile=coverage.out
- uses: codecov/codecov-action@v4
with:
disable_search: true
fail_ci_if_error: true
file: coverage.out
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Code generated by craft; DO NOT EDIT.

name: Release
run-name: Release

on:
workflow_dispatch:

jobs:

release:
runs-on: ubuntu-latest
environment: release
if: github.ref_protected == true
permissions:
contents: write
issues: write
env:
GIT_AUTHOR_NAME: ${{ github.triggering_actor }}
GIT_AUTHOR_EMAIL: ${{ github.triggering_actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.triggering_actor }}
GIT_COMMITTER_EMAIL: ${{ github.triggering_actor }}@users.noreply.github.com
steps:
- uses: actions/checkout@v4
- id: sha
run: echo "sha=$(echo "${{ github.ref_name }}" | sha256sum | cut -c -8)" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
name: executables
- id: semantic-release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/commit-analyzer
@semantic-release/exec
@semantic-release/git
@semantic-release/github
@semantic-release/release-notes-generator
conventional-changelog-conventionalcommits
semantic-release-license
tag_format: v${version}
branches: |
[
"(master|main)",
"v+([0-9])?(.{+([0-9]),x}).x",
{ "name": "next", "prerelease": true },
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true },
{ "name": "staging", "prerelease": "beta" },
{ "name": "develop", "prerelease": "alpha" },
{ "name": "${{ github.ref_name }}", "prerelease": "${{ steps.sha.outputs.sha }}" }
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ issues:
- funlen
- goconst
- maintidx
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter: 0
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 0

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
Expand Down
54 changes: 54 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Code generated by craft; DO NOT EDIT.

plugins:
- - "@semantic-release/commit-analyzer"
- releaseRules:
- { breaking: true, release: major }
- { revert: true, release: patch }
- { type: feat, release: minor }
- { type: fix, release: patch }
- { type: revert, release: patch }
- { type: perf, release: patch }
- { type: docs, release: patch }
- { type: chore, release: patch }
- { type: refactor, release: minor }
- { scope: release, release: false }
parserOpts:
noteKeywords:
- BREAKING CHANGE
- BREAKING CHANGES
- BREAKING
- - "@semantic-release/release-notes-generator"
- preset: conventionalcommits
presetConfig:
types:
- { type: feat, section: Features }
- { type: fix, section: Bug Fixes }
- { type: revert, section: Reverts }
- { type: perf, section: Performance Improvements }
- { type: docs, section: Documentation }
- { type: chore, section: Chores }
- { type: refactor, section: Code Refactoring }

- { type: build, section: Build System, hidden: true }
- { type: ci, section: Continuous Integration, hidden: true }
- { type: style, section: Styles, hidden: true }
- { type: test, section: Tests, hidden: true }
parserOpts:
noteKeywords:
- BREAKING CHANGE
- BREAKING CHANGES
- BREAKING
- "@semantic-release/changelog"
- "semantic-release-license"
- - "@semantic-release/git"
- assets: [ "CHANGELOG.md", "LICENSE" ]
message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
- - "@semantic-release/github"
- assets:
- { path: CHANGELOG.md, label: CHANGELOG.md }
- { path: checksums.txt }
- { path: dist/* }
failComment: false,
successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉
- "@semantic-release/exec"
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,44 @@ When sending a function into the pooler (with the appropriate channel), this fun

```go
func main() {
log := logrus.WithContext(context.Background())

pooler, err := pooling.NewPoolerBuilder().
SetSizes(10, 500, ...). // each size will initialize a pool with given size
SetOptions(ants.WithLogger(log)).
Build()
if err != nil {
panic(err)
}
defer pooler.Close()

input := ReadFrom()

// Read function is blocking until input is closed
// and all running routines have ended
pooler.Read(input)
log := logrus.WithContext(context.Background())

pooler, err := pooling.NewPoolerBuilder().
SetSizes(10, 500, ...). // each size will initialize a pool with given size
SetOptions(ants.WithLogger(log)).
Build()
if err != nil {
panic(err)
}
defer pooler.Close()

input := ReadFrom()

// Read function is blocking until input is closed
// and all running routines have ended
pooler.Read(input)
}

func ReadFrom() <-chan pooling.PoolerFunc {
input := make(chan pooling.PoolerFunc)
input := make(chan pooling.PoolerFunc)

go func() {
// close input to stop blocking function Read once all elements are sent to input
defer close(input)
go func() {
// close input to stop blocking function Read once all elements are sent to input
defer close(input)

// do something populating input channel
for i := range 100 {
input <- HandleInt(i)
}
}()
// do something populating input channel
for i := range 100 {
input <- HandleInt(i)
}
}()

return input
return input
}

func HandleInt(i int) pooling.PoolerFunc {
return func(funcs chan<- pooling.PoolerFunc) {
// you may handle the integer whichever you want
// funcs channel is present to dispatch again some elements into a channel handled by the pooler
}
return func(funcs chan<- pooling.PoolerFunc) {
// you may handle the integer whichever you want
// funcs channel is present to dispatch again some elements into a channel handled by the pooler
}
}
```
13 changes: 0 additions & 13 deletions sonar.properties

This file was deleted.

0 comments on commit d3d6fc2

Please sign in to comment.