-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ciro/fix-socket
- Loading branch information
Showing
179 changed files
with
3,300 additions
and
1,385 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,3 @@ | ||
Index: | ||
Background: Skip # Disable slow background indexing of these files. | ||
|
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
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
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
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
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
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,86 @@ | ||
name: lint | ||
|
||
permissions: | ||
contents: read | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- jarred/assert | ||
paths: | ||
- ".github/workflows/lint.yml" | ||
- "src/**/*.zig" | ||
- "src/*.zig" | ||
|
||
jobs: | ||
format: | ||
name: lint | ||
runs-on: ${{ vars.RUNNER_LINUX_X64 || 'ubuntu-latest' }} | ||
if: github.repository_owner == 'oven-sh' | ||
permissions: write-all | ||
outputs: | ||
text_output: ${{ steps.lint.outputs.text_output }} | ||
json_output: ${{ steps.lint.outputs.json_output }} | ||
count: ${{ steps.lint.outputs.count }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Bun | ||
uses: ./.github/actions/setup-bun | ||
with: | ||
bun-version: "1.1.3" | ||
- name: Install Dependencies | ||
run: | | ||
bun --cwd=./packages/bun-internal-test install | ||
- name: Lint | ||
id: lint | ||
run: | | ||
bun ./packages/bun-internal-test/src/linter.ts || true | ||
- uses: sarisia/actions-status-discord@v1 | ||
if: always() && steps.lint.outputs.text_output != '' && github.event_name == 'pull_request' | ||
with: | ||
title: "" | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
status: "failure" | ||
noprefix: true | ||
nocontext: true | ||
description: | | ||
Pull Request | ||
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}}) | ||
@${{ github.actor }}, there are ${{ steps.lint.outputs.count }} lint errors on ${{ github.ref_name }} | ||
${{ steps.lint.outputs.text_output }} | ||
**[View linter output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})** | ||
- name: Comment on PR | ||
if: steps.lint.outputs.text_output != '' && github.event_name == 'pull_request' | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
comment_tag: lint-failures | ||
message: | | ||
❌ @${{ github.actor }} ${{ steps.lint.outputs.count }} lint errors | ||
${{ steps.lint.outputs.text_output }} | ||
**[View linter output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})** | ||
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup> | ||
- name: Uncomment on PR | ||
if: steps.lint.outputs.text_output == '' && github.event_name == 'pull_request' | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
comment_tag: lint-failures | ||
mode: upsert | ||
create_if_not_exists: false | ||
message: | | ||
✅ lint failures have been resolved. Thank you. | ||
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup> | ||
- id: fail | ||
name: Fail the build | ||
if: steps.lint.outputs.text_output != '' | ||
run: exit 1 |
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
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,58 @@ | ||
Use the `--filter` flag to execute lifecycle scripts in multiple packages at once: | ||
|
||
```bash | ||
bun --filter <pattern> <script> | ||
``` | ||
|
||
Say you have a monorepo with two packages: `packages/api` and `packages/frontend`, both with a `dev` script that will start a local development server. Normally, you would have to open two separate terminal tabs, cd into each package directory, and run `bun dev`: | ||
|
||
```bash | ||
cd packages/api | ||
bun dev | ||
|
||
# in another terminal | ||
cd packages/frontend | ||
bun dev | ||
``` | ||
|
||
Using `--filter`, you can run the `dev` script in both packages at once: | ||
|
||
```bash | ||
bun --filter '*' dev | ||
``` | ||
|
||
Both commands will be run in parallel, and you will see a nice terminal UI showing their respective outputs: | ||
 | ||
|
||
|
||
## Matching | ||
|
||
`--filter` accepts a pattern to match specific packages, either by name or by path. Patterns have full support for glob syntax. | ||
|
||
### Package Name `--filter <pattern>` | ||
|
||
Name patterns select packages based on the package name, as specified in `package.json`. For example, if you have packages `pkga`, `pkgb` and `other`, you can match all packages with `*`, only `pkga` and `pkgb` with `pkg*`, and a specific package by providing the full name of the package. | ||
|
||
### Package Path `--filter ./<glob>` | ||
|
||
Path patterns are specified by starting the pattern with `./`, and will select all packages in directories that match the pattern. For example, to match all packages in subdirectories of `packages`, you can use `--filter './packages/**'`. To match a package located in `pkgs/foo`, use `--filter ./pkgs/foo`. | ||
|
||
## Workspaces | ||
|
||
Filters respect your [workspace configuration](/docs/install/workspaces.md): If you have a `package.json` file that specifies which packages are part of the workspace, | ||
`--filter` will be restricted to only these packages. Also, in a workspace you can use `--filter` to run scripts in packages that are located anywhere in the workspace: | ||
|
||
```bash | ||
# Packages | ||
# src/foo | ||
# src/bar | ||
|
||
# in src/bar: runs myscript in src/foo, no need to cd! | ||
bun run --filter foo myscript | ||
``` | ||
|
||
## Dependency Order | ||
Bun will respect package dependency order when running scripts. Say you have a package `foo` that depends on another package `bar` in your workspace, and both packages have a `build` script. When you run `bun --filter '*' build`, you will notice that `foo` will only start running once `bar` is done. | ||
|
||
### Cyclic Dependencies | ||
|
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
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
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
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
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,7 @@ | ||
{ | ||
"std.debug.assert": "Use bun.assert instead", | ||
"@import(\"root\").bun.": "Only import 'bun' once", | ||
"std.mem.indexOfAny": "Use bun.strings.indexAny or bun.strings.indexAnyComptime", | ||
"std.debug.print": "Don't let this be committed", | ||
"": "" | ||
} |
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,72 @@ | ||
import { $ } from "bun"; | ||
import BANNED from "./banned.json"; | ||
import * as action from "@actions/core"; | ||
|
||
const IGNORED_FOLDERS = [ | ||
// list of folders to ignore | ||
"windows-shim", | ||
]; | ||
|
||
const ci = !!process.env["GITHUB_ACTIONS"]; | ||
process.chdir(require("path").join(import.meta.dir, "../../../")); | ||
let bad = []; | ||
let report = ""; | ||
const write = (text: string) => { | ||
process.stdout.write(text); | ||
report += text; | ||
}; | ||
for (const [banned, suggestion] of Object.entries(BANNED)) { | ||
if (banned.length === 0) continue; | ||
// Run git grep to find occurrences of std.debug.assert in .zig files | ||
// .nothrow() is here since git will exit with non-zero if no matches are found. | ||
let stdout = await $`git grep -n -F "${banned}" "src/**/**.zig" | grep -v -F '//' | grep -v -F bench` | ||
.nothrow() | ||
.text(); | ||
|
||
stdout = stdout.trim(); | ||
if (stdout.length === 0) continue; | ||
|
||
let lines = stdout.split("\n"); | ||
// Parse each line to extract filename and line number | ||
const matches = lines | ||
.filter(line => !IGNORED_FOLDERS.some(folder => line.includes(folder))) | ||
.map(line => { | ||
const [path, lineNumber, ...text] = line.split(":"); | ||
return { path, lineNumber, banned, suggestion, text: text.join(":") }; | ||
}); | ||
// Check if we got any output | ||
// Split the output into lines | ||
if (matches.length === 0) continue; | ||
|
||
write(`Banned **'${banned}'** found in the following locations:` + "\n"); | ||
matches.forEach(match => { | ||
write(`${match.path}:${match.lineNumber}: ${match.text.trim()}` + "\n"); | ||
}); | ||
bad = bad.concat(matches); | ||
} | ||
|
||
if (report.length === 0) { | ||
process.exit(0); | ||
} | ||
|
||
function link({ path, lineNumber, suggestion, banned }) { | ||
action.error(`Lint failure: ${banned} is banned, ${suggestion}`, { | ||
file: path, | ||
startLine: Number(lineNumber), | ||
endLine: Number(lineNumber), | ||
}); | ||
return `[\`${path}:${lineNumber}\`](https://github.com/oven-sh/bun/blob/${process.env.GITHUB_SHA}/${path}#L${lineNumber})`; | ||
} | ||
|
||
if (ci) { | ||
if (report.length > 0) { | ||
action.setFailed(`${bad.length} lint failures`); | ||
} | ||
action.setOutput("count", bad.length); | ||
action.setOutput("text_output", bad.map(m => `- ${link(m)}: ${m.banned} is banned, ${m.suggestion}`).join("\n")); | ||
action.setOutput("json_output", JSON.stringify(bad)); | ||
action.summary.addRaw(report); | ||
await action.summary.write(); | ||
} | ||
|
||
process.exit(1); |
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
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
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
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
Oops, something went wrong.