Skip to content

Commit 4a278e0

Browse files
committed
gitpkg
0 parents  commit 4a278e0

36 files changed

+4530
-0
lines changed

.cursor/rules/tests.mdc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
Tests are written using vitest and live in the `spec` dir. Run all the tests with `pnpm test`. Run one test with `pnpm test -- -t "should respect maxRate limit"`

.envrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
2+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
3+
fi
4+
5+
use flake
6+
7+
source_env_if_exists .envrc.local

.eslintrc.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
module.exports = {
2+
extends: "@gadgetinc/eslint-config",
3+
parserOptions: {
4+
tsconfigRootDir: __dirname,
5+
project: ["tsconfig.json"],
6+
},
7+
rules: {
8+
"lodash/import-scope": "off",
9+
"lodash/callback-binding": "off",
10+
"lodash/chain-style": "off",
11+
"lodash/collection-method-value": "off",
12+
"lodash/collection-ordering": "off",
13+
"lodash/collection-return": "off",
14+
"lodash/consistent-compose": "off",
15+
"lodash/identity-shorthand": "off",
16+
"lodash/matches-prop-shorthand": "off",
17+
"lodash/matches-shorthand": "off",
18+
"lodash/no-commit": "off",
19+
"lodash/no-double-unwrap": "off",
20+
"lodash/no-extra-args": "off",
21+
"lodash/no-unbound-this": "off",
22+
"lodash/path-style": "off",
23+
"lodash/prefer-compact": "off",
24+
"lodash/prefer-constant": "off",
25+
"lodash/prefer-filter": "off",
26+
"lodash/prefer-find": "off",
27+
"lodash/prefer-flat-map": "off",
28+
"lodash/prefer-get": "off",
29+
"lodash/prefer-includes": "off",
30+
"lodash/prefer-is-nil": "off",
31+
"lodash/prefer-lodash-chain": "off",
32+
"lodash/prefer-lodash-method": "off",
33+
"lodash/prefer-lodash-typecheck": "off",
34+
"lodash/prefer-map": "off",
35+
"lodash/prefer-matches": "off",
36+
"lodash/prefer-noop": "off",
37+
"lodash/prefer-over-quantifier": "off",
38+
"lodash/prefer-reject": "off",
39+
"lodash/prefer-startswith": "off",
40+
"lodash/prefer-thru": "off",
41+
"lodash/prefer-times": "off",
42+
"lodash/prefer-wrapper-method": "off",
43+
"lodash/prop-shorthand": "off",
44+
"lodash/unwrap": "off",
45+
"@typescript-eslint/no-unsafe-argument": "off",
46+
"@typescript-eslint/no-non-null-assertion": "off",
47+
"@typescript-eslint/ban-types": [
48+
"error",
49+
{
50+
extendDefaults: true,
51+
types: {
52+
Function: false,
53+
"{}": false,
54+
},
55+
},
56+
],
57+
"jest/no-disabled-tests": "off",
58+
"jest/no-focused-tests": "off",
59+
"jest/no-identical-title": "off",
60+
"jest/prefer-to-have-length": "off",
61+
"jest/valid-expect": "off",
62+
"jest/expect-expect": "off",
63+
"jest/no-alias-methods": "off",
64+
"jest/no-commented-out-tests": "off",
65+
"jest/no-conditional-expect": "off",
66+
"jest/no-deprecated-functions": "off",
67+
"jest/no-done-callback": "off",
68+
"jest/no-duplicate-hooks": "off",
69+
"jest/no-export": "off",
70+
"jest/no-hooks": "off",
71+
"jest/no-if": "off",
72+
"jest/no-interpolation-in-snapshots": "off",
73+
"jest/no-jasmine-globals": "off",
74+
"jest/no-jest-import": "off",
75+
"jest/no-large-snapshots": "off",
76+
"jest/no-mocks-import": "off",
77+
"jest/no-restricted-matchers": "off",
78+
"jest/no-standalone-expect": "off",
79+
"jest/no-test-prefixes": "off",
80+
"jest/no-test-return-statement": "off",
81+
"jest/prefer-called-with": "off",
82+
"jest/prefer-expect-assertions": "off",
83+
"jest/prefer-hooks-on-top": "off",
84+
"jest/prefer-spy-on": "off",
85+
"jest/prefer-strict-equal": "off",
86+
"jest/prefer-to-be": "off",
87+
"jest/prefer-to-contain": "off",
88+
"jest/prefer-todo": "off",
89+
"jest/require-hook": "off",
90+
"jest/require-to-throw-message": "off",
91+
"jest/require-top-level-describe": "off",
92+
"jest/valid-describe-callback": "off",
93+
"jest/valid-title": "off",
94+
},
95+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Setup test environment"
2+
description: ""
3+
inputs: {}
4+
outputs: {}
5+
runs:
6+
using: "composite"
7+
steps:
8+
- uses: cachix/install-nix-action@v18
9+
with:
10+
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
11+
- run: |
12+
source <(nix print-dev-env --show-trace)
13+
output_file="nix-env.txt"
14+
15+
# Clear the output file
16+
> $output_file
17+
18+
# Loop over each variable in the environment
19+
while IFS='=' read -r -d '' name value; do
20+
# Skip if the variable is a function or read-only or non-alphanumeric
21+
[[ "$(declare -p $name)" =~ "declare -[a-z]*r[a-z]* " ]] && continue
22+
[[ ! $name =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]] && continue
23+
24+
# Check if the variable value contains a newline
25+
if [[ "$value" != *$'\n'* ]]; then
26+
# It doesn't, so write the variable and its value (stripping quotes) to the file
27+
echo "${name}=${value//\"/}" >> $output_file
28+
fi
29+
done < <(env -0)
30+
31+
# useful for debugging what env is exported
32+
# cat nix-env.txt
33+
shell: bash
34+
- run: cat nix-env.txt >> "$GITHUB_ENV"
35+
shell: bash
36+
37+
- name: Get pnpm store directory
38+
id: pnpm-cache
39+
shell: bash
40+
run: |
41+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
42+
43+
- uses: actions/cache@v3
44+
name: Setup pnpm cache
45+
with:
46+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
47+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
48+
restore-keys: |
49+
${{ runner.os }}-pnpm-store-
50+
51+
- name: Install dependencies
52+
shell: bash
53+
run: pnpm install

.github/workflows/benchmark.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Benchmark"
2+
on:
3+
push:
4+
workflow_call:
5+
workflow_dispatch:
6+
jobs:
7+
bench:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/[email protected]
11+
- uses: ./.github/actions/setup-test-env
12+
- name: Run benchmarks
13+
shell: bash
14+
run: pnpm x spec/bench/aimd-bucket.bench.ts

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "package.json"
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
uses: ./.github/workflows/test.yml
13+
release:
14+
needs: test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: ./.github/actions/setup-test-env
19+
- id: npm-publish
20+
name: Publish to npm
21+
uses: JS-DevTools/npm-publish@v1
22+
with:
23+
token: ${{ secrets.NPM_TOKEN }}
24+
access: public
25+
- name: Publish release to github
26+
uses: softprops/action-gh-release@v1
27+
if: ${{ steps.npm-publish.outputs.type != 'none' }}
28+
with:
29+
tag_name: ${{ steps.npm-publish.outputs.version }}
30+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Test"
2+
on:
3+
push:
4+
workflow_call:
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/[email protected]
10+
- uses: ./.github/actions/setup-test-env
11+
- name: Build
12+
shell: bash
13+
run: pnpm build
14+
- name: Test
15+
shell: bash
16+
run: pnpm test
17+
18+
lint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/[email protected]
22+
- uses: ./.github/actions/setup-test-env
23+
- name: Lint
24+
shell: bash
25+
run: pnpm lint

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@gadgetinc/prettier-config"

LICENSE.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014-2017 Martin Andert
4+
Copyright (c) 2005-2017 David Heinemeier Hansson
5+
Copyright (c) 2008 The Ruby I18n team
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

0 commit comments

Comments
 (0)