Skip to content

🏗️ Upgrade workflows and enable erasableSyntaxOnly #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/authorized_keys

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
version: latest
- uses: actions/setup-node@v4
with:
node-version: 21
node-version: 23
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run docs
Expand Down
74 changes: 69 additions & 5 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Node.js CI

on:
push:
branches: main
merge_group:
branches:
- main
pull_request:
branches: main
branches:
- main
push:
branches:
- main

jobs:
test:
Expand All @@ -17,9 +22,68 @@ jobs:
version: latest
- uses: actions/setup-node@v4
with:
node-version: 21
node-version: 23
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm install --frozen-lockfile --strict-peer-dependencies
- run: pnpm run build --noEmit
- run: pnpm run lint
- run: pnpm run test

fix:
runs-on: ubuntu-latest

permissions:
contents: write

if: failure() && github.event_name != 'merge_group' && github.actor != 'github-actions[bot]' && github.actor != 'nektos/act'

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: pnpm/action-setup@v4
with:
version: latest
- uses: actions/setup-node@v4
with:
cache: pnpm
node-version: 23

- run: |
pnpm install --fix-lockfile --no-frozen-lockfile
git add .
- id: commit-lockfile
uses: qoomon/actions--create-commit@v1
with:
message: |
📌 pnpm install --fix-lockfile

[dependabot skip]
skip-empty: true

- run: |
pnpm run format
git add .
- id: commit-format
uses: qoomon/actions--create-commit@v1
with:
message: |
🎨 pnpm run format

[dependabot skip]
skip-empty: true

- run: |
pnpm run lint:fix
git add .
- id: commit-lint
uses: qoomon/actions--create-commit@v1
with:
message: |
🚨 pnpm run lint:fix

[dependabot skip]
skip-empty: true

- if: steps.commit-lockfile.outputs.commit || steps.commit-format.outputs.commit || steps.commit-lint.outputs.commit
run: git push
11 changes: 2 additions & 9 deletions .github/workflows/pnpm-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: pnpm
node-version: 21
node-version: 23
- run: pnpm install
- run: pnpm build

Expand All @@ -43,13 +43,6 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.CODERABBIT_NPMTOKEN }}

- run: pnpm pack --pack-gzip-level 9
- name: Sign
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.DEPLOY_KEY_PRIVATE }}'
echo '${{ vars.DEPLOY_KEY_PUBLIC }}' > '${{ runner.temp }}/DEPLOY_KEY_PUBLIC.pub'
ssh-keygen -Y sign -f '${{ runner.temp }}/DEPLOY_KEY_PUBLIC.pub' -n file coderabbitai-openai-chat-tokens-*.tgz
ssh-keygen -Y verify -f ./.github/authorized_keys -I '41898282+github-actions[bot]@users.noreply.github.com' -n file -s coderabbitai-openai-chat-tokens-*.tgz.sig < coderabbitai-openai-chat-tokens-*.tgz
- run: gh release upload ${{ github.ref_name }} coderabbitai-openai-chat-tokens-*.tgz coderabbitai-openai-chat-tokens-*.tgz.sig
- run: gh release upload ${{ github.ref_name }} coderabbitai-openai-chat-tokens-*.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 14 additions & 20 deletions .github/workflows/pnpm-version-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,29 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY_PRIVATE }}
ref: ${{ github.ref }}
- uses: pnpm/action-setup@v4
with:
version: latest
- uses: actions/setup-node@v4
with:
cache: pnpm
node-version: 21
- name: Configure Git, patch, release and push
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'

git config commit.gpgsign true
git config gpg.format ssh
git config push.gpgSign 'if-asked'
git config tag.gpgSign true
git config user.signingkey 'key::${{ vars.DEPLOY_KEY_PUBLIC }}'
node-version: 23

eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.DEPLOY_KEY_PRIVATE }}'
- id: patch
run: |
echo "VERSION=$(pnpm version patch --no-git-tag-version)" >> "$GITHUB_OUTPUT"
git add .

VERSION=$(pnpm version patch --no-git-tag-version)
- id: commit
uses: qoomon/actions--create-commit@v1
with:
message: 🔖 ${{ steps.patch.outputs.VERSION }}

git commit --all --message "🔖 $VERSION"
git tag --annotate --message "🔖 $VERSION" --sign $VERSION
- run: |
git push
git push --tags

gh release create $VERSION --generate-notes --title $VERSION --verify-tag
gh release create "$VERSION" --generate-notes --target "$COMMIT" --title "$VERSION"
env:
COMMIT: ${{ steps.commit.outputs.commit }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.patch.outputs.VERSION }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This library handles both of those cases, as well as a minor adjustment needed f
## Usage

```typescript
import { promptTokensEstimate } from "openai-chat-tokens"
import { promptTokensEstimate } from "@coderabbitai/openai-chat-tokens"

const estimate = promptTokensEstimate({
messages: [
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"format": "prettier --write .",
"lint": "eslint . && prettier --check .",
"lint:fix": "eslint --fix .; prettier --list-different --write .",
"test": "vitest",
"test:watch": "vitest --watch"
"test": "vitest run",
"test:watch": "vitest"
},
"devDependencies": {
"@eslint/js": "^9.9.1",
Expand All @@ -30,7 +30,7 @@
"openai": "^4.56.0",
"prettier": "^3.3.3",
"typedoc": "^0.26.6",
"typescript": "5.7.3",
"typescript": "5.8.0-beta",
"typescript-eslint": "^8.2.0",
"vite": "^6.0.7",
"vitest": "^3.0.5"
Expand Down
70 changes: 35 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"isolatedModules": true,
"verbatimModuleSyntax": true,
"isolatedDeclarations": true,
"erasableSyntaxOnly": true,
"forceConsistentCasingInFileNames": true,

/* Type Checking */
Expand Down