Skip to content

Commit 10dfe57

Browse files
authored
Initial implementation (#1)
* Init repo * Initial code * Initial implementation * Initial implementation * Initial implementation * Initial implementation
1 parent f29cb3c commit 10dfe57

23 files changed

Lines changed: 1251 additions & 297 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
If feasible/relevant, please provide a code snippet (inline or with Go playground) to reproduce the issue.
15+
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Additional context**
21+
Add any other context about the problem here.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Please use discussions https://github.com/bool64/throttle/discussions/categories/ideas to share feature ideas.

.github/ISSUE_TEMPLATE/question.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Question
3+
about: Any question about features or usage
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Please use discussions https://github.com/bool64/throttle/discussions/categories/q-a to make your question more discoverable by other folks.

.github/workflows/bench.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

.github/workflows/cloc.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,36 @@
22
name: cloc
33
on:
44
pull_request:
5+
6+
# Cancel the workflow in progress in newer build is about to start.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
511
jobs:
612
cloc:
713
runs-on: ubuntu-latest
814
steps:
915
- name: Checkout code
10-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1117
with:
1218
path: pr
1319
- name: Checkout base code
14-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
1521
with:
1622
ref: ${{ github.event.pull_request.base.sha }}
1723
path: base
18-
- name: Count Lines Of Code
24+
- name: Count lines of code
1925
id: loc
2026
run: |
21-
curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.1/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
27+
curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.3/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
28+
sccdiff_hash=$(git hash-object ./sccdiff)
29+
[ "$sccdiff_hash" == "ae8a07b687bd3dba60861584efe724351aa7ff63" ] || (echo "::error::unexpected hash for sccdiff, possible tampering: $sccdiff_hash" && exit 1)
2230
OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
2331
echo "${OUTPUT}"
24-
OUTPUT="${OUTPUT//$'\n'/%0A}"
25-
echo "::set-output name=diff::$OUTPUT"
32+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
2633
27-
- name: Comment Code Lines
34+
- name: Comment lines of code
2835
continue-on-error: true
2936
uses: marocchino/sticky-pull-request-comment@v2
3037
with:

.github/workflows/golangci-lint.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,22 @@ on:
88
- master
99
- main
1010
pull_request:
11+
12+
# Cancel the workflow in progress in newer build is about to start.
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
1117
jobs:
1218
golangci:
1319
name: golangci-lint
1420
runs-on: ubuntu-latest
1521
steps:
16-
- uses: actions/checkout@v2
22+
- uses: actions/setup-go@v5
23+
with:
24+
go-version: stable
25+
- uses: actions/checkout@v4
1726
- name: golangci-lint
18-
uses: golangci/golangci-lint-action@v2.5.2
27+
uses: golangci/golangci-lint-action@v9.2.0
1928
with:
20-
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
21-
version: v1.43.0
22-
23-
# Optional: working directory, useful for monorepos
24-
# working-directory: somedir
25-
26-
# Optional: golangci-lint command line arguments.
27-
# args: --issues-exit-code=0
28-
29-
# Optional: show only new issues if it's a pull request. The default value is `false`.
30-
# only-new-issues: true
31-
32-
# Optional: if set to true then the action will use pre-installed Go.
33-
# skip-go-installation: true
34-
35-
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
36-
# skip-pkg-cache: true
37-
38-
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
39-
# skip-build-cache: true
29+
version: v2.11.3

.github/workflows/gorelease.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,38 @@
22
name: gorelease
33
on:
44
pull_request:
5+
6+
# Cancel the workflow in progress in newer build is about to start.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
511
env:
6-
GO_VERSION: 1.17.x
12+
GO_VERSION: stable
713
jobs:
814
gorelease:
915
runs-on: ubuntu-latest
1016
steps:
11-
- name: Install Go stable
12-
if: env.GO_VERSION != 'tip'
13-
uses: actions/setup-go@v2
17+
- name: Install Go
18+
uses: actions/setup-go@v5
1419
with:
1520
go-version: ${{ env.GO_VERSION }}
16-
- name: Install Go tip
17-
if: env.GO_VERSION == 'tip'
18-
run: |
19-
curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz
20-
ls -lah gotip.tar.gz
21-
mkdir -p ~/sdk/gotip
22-
tar -C ~/sdk/gotip -xzf gotip.tar.gz
23-
~/sdk/gotip/bin/go version
24-
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
2521
- name: Checkout code
26-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
2723
- name: Gorelease cache
28-
uses: actions/cache@v2
24+
uses: actions/cache@v4
2925
with:
3026
path: |
3127
~/go/bin/gorelease
32-
key: ${{ runner.os }}-gorelease
28+
key: ${{ runner.os }}-gorelease-generic
3329
- name: Gorelease
3430
id: gorelease
3531
run: |
3632
test -e ~/go/bin/gorelease || go install golang.org/x/exp/cmd/gorelease@latest
37-
OUTPUT=$(gorelease || exit 0)
33+
OUTPUT=$(gorelease 2>&1 || exit 0)
3834
echo "${OUTPUT}"
39-
OUTPUT="${OUTPUT//$'\n'/%0A}"
40-
echo "::set-output name=report::$OUTPUT"
41-
- name: Comment Report
35+
echo "report<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
36+
- name: Comment report
4237
continue-on-error: true
4338
uses: marocchino/sticky-pull-request-comment@v2
4439
with:
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This script is provided by github.com/bool64/dev.
2+
3+
# This script uploads application binaries as GitHub release assets.
4+
name: release-assets
5+
on:
6+
release:
7+
types:
8+
- created
9+
10+
permissions:
11+
contents: write # Required to upload assets
12+
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
GO_VERSION: stable
16+
TAG_NAME: ${{ github.event.release.tag_name }}
17+
jobs:
18+
build:
19+
name: Upload Release Assets
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Install Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ env.GO_VERSION }}
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
- name: Build artifacts
29+
run: |
30+
make release-assets
31+
32+
- name: Upload linux_amd64.tar.gz
33+
if: hashFiles('linux_amd64.tar.gz') != ''
34+
run: gh release upload "$TAG_NAME" linux_amd64.tar.gz --clobber
35+
36+
- name: Upload linux_amd64_dbg.tar.gz
37+
if: hashFiles('linux_amd64_dbg.tar.gz') != ''
38+
run: gh release upload "$TAG_NAME" linux_amd64_dbg.tar.gz --clobber
39+
40+
- name: Upload linux_arm64.tar.gz
41+
if: hashFiles('linux_arm64.tar.gz') != ''
42+
run: gh release upload "$TAG_NAME" linux_arm64.tar.gz --clobber
43+
44+
- name: Upload linux_arm.tar.gz
45+
if: hashFiles('linux_arm.tar.gz') != ''
46+
run: gh release upload "$TAG_NAME" linux_arm.tar.gz --clobber
47+
48+
- name: Upload darwin_amd64.tar.gz
49+
if: hashFiles('darwin_amd64.tar.gz') != ''
50+
run: gh release upload "$TAG_NAME" darwin_amd64.tar.gz --clobber
51+
52+
- name: Upload darwin_arm64.tar.gz
53+
if: hashFiles('darwin_arm64.tar.gz') != ''
54+
run: gh release upload "$TAG_NAME" darwin_arm64.tar.gz --clobber
55+
56+
- name: Upload windows_amd64.zip
57+
if: hashFiles('windows_amd64.zip') != ''
58+
run: gh release upload "$TAG_NAME" windows_amd64.zip --clobber

0 commit comments

Comments
 (0)