Skip to content

Commit

Permalink
Merge branch 'main' into AdityaAtulTewari/http-request-cache-part1
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaAtulTewari committed Aug 21, 2024
2 parents c99282c + 03859f5 commit 30185d5
Show file tree
Hide file tree
Showing 598 changed files with 51,323 additions and 47,223 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ build --@dawn//src/tint:tint_build_wgsl_writer=True
# Our dependencies (ICU, zlib, etc.) produce a lot of these warnings, so we disable them. Depending
# on the clang version, zlib either produces warnings for -Wdeprecated-non-prototype or does not
# have that option, so disable -Wunknown-warning-option there too.
build --per_file_copt='external@-Wno-error'
build --per_file_copt='external/v8@-Wno-deprecated-declarations'
build --per_file_copt='external/com_googlesource_chromium_icu@-Wno-ambiguous-reversed-operator,-Wno-deprecated-declarations'
build --host_per_file_copt='external/com_googlesource_chromium_icu@-Wno-ambiguous-reversed-operator,-Wno-deprecated-declarations'
Expand Down
101 changes: 99 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,10 +1,107 @@
Language: Cpp
Standard: c++20
ColumnLimit: 100

WhitespaceSensitiveMacros:
# clang format doesn't understand TypeScript, so make sure it doesn't mangle
# overrides and additional definitions
- JSG_TS_OVERRIDE
- JSG_TS_DEFINE
- JSG_STRUCT_TS_OVERRIDE
- JSG_STRUCT_TS_DEFINE
PointerAlignment: Left
ColumnLimit: 100
AllowShortFunctionsOnASingleLine: Empty

# We should have "true" here but adding an include header would result in too many changed lines.
# Once we turn this on we should use IncludeCategories so that things are consistently sorted.
# For example, to protect against brittle headers (a header not including everything its using
# because existing users happened to include a dependency for it), one could use the following
# order:
# local folder files
# project files
# 3p dependency includes
# standard language headers (put kj/ here?)
# system headers
# While this would be ideal it's also important to note that this isn't the (non-documented) style
# that KJ uses, so it may be worth documenting the style & making it consistent.
SortIncludes: false

AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true

IndentWidth: 2
IndentCaseBlocks: false
IndentCaseLabels: true
PointerAlignment: Left
DerivePointerAlignment: true

# Really "Attach" but empty braces aren't split.
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false

Cpp11BracedListStyle: true

AlignAfterOpenBracket: DontAlign
AlignOperands: DontAlign
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakStringLiterals: false
BinPackArguments: true
BinPackParameters: false
BracedInitializerIndentWidth: 2
BreakInheritanceList: BeforeColon
ContinuationIndentWidth: 4
IfMacros:
[
"KJ_SWITCH_ONEOF",
"KJ_CASE_ONEOF",
"KJ_IF_MAYBE",
"KJ_IF_SOME",
"CFJS_RESOURCE_TYPE",
]
LambdaBodyIndentation: OuterScope
Macros:
- "KJ_MAP(x,y)=[y](auto x)"
- "JSG_VISITABLE_LAMBDA(x,y,z)=[x,y](z)"
# The WhitespaceSensitiveMacros solution is flaky, adding the following ensures no formatting:
- "JSG_TS_OVERRIDE(x)=enum class"
- "JSG_TS_DEFINE(x)=enum class"
- "JSG_STRUCT_TS_OVERRIDE(x)=enum class"
- "JSG_STRUCT_TS_DEFINE(x)=enum class"
PenaltyReturnTypeOnItsOwnLine: 1000
PackConstructorInitializers: CurrentLine
ReflowComments: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: false
SpacesBeforeTrailingComments: 2
---
# Some files with embedded typescript are incorrectly recognized by clang-format as Objective-C
# This is because the C/C++ macro expansion step happens after the language recognition step, so
# when trying to parse the file, the c++ parser fails with incorrect syntax and a fallback to
# the Objective-C parser is used.
# This is a workaround to hide the warning.
# TODO: Remove this once we have a better solution.
Language: ObjC
DisableFormat: true
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Apply prettier to the project
0523bf8b36a937348f1bb79eceda2463a5c220b5

# Apply clang-format to the project.
5e8537a77e760c160ace3dfe23ee8c76ee5aeeb3

# Apply ruff format to the project
d6d0607a845e6f71084ce272a1c1e8c50e244bdd
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint

on:
pull_request:
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Setup Linux
run: |
export DEBIAN_FRONTEND=noninteractive
wget https://apt.llvm.org/llvm.sh
sed -i '/apt-get install/d' llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
sudo apt-get install -y --no-install-recommends clang-format-18
- name: Install pnpm
uses: pnpm/action-setup@v4
# The pnpm version will be determined by the `packageManager` field in `.npmrc`
- name: Install project deps with pnpm
run: |
pnpm i
- name: Install Ruff
run: |
pip install ruff
- name: Lint
run: |
python3 ./tools/cross/format.py --check
env:
CLANG_FORMAT: clang-format-18
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ jobs:
repository: cloudflare/workers-sdk

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: ^9.1.3
uses: pnpm/action-setup@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ jobs:
sudo apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-16-dev libclang-rt-16-dev
echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc
echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc
echo "build:linux --copt='-Werror'" >> .bazelrc
echo "build:linux --copt='-Wno-error=#warnings'" >> .bazelrc
echo "build:linux --copt='-Wno-error=deprecated-declarations'" >> .bazelrc
sed -i -e "s%llvm-symbolizer%/usr/lib/llvm-16/bin/llvm-symbolizer%" .bazelrc
- name: Setup macOS
if: matrix.os.name == 'macOS'
Expand Down
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ref: https://pnpm.io/npmrc#manage-package-manager-versions
# When enabled, pnpm will automatically download and run the version of pnpm
# specified in the packageManager field of package.json.
manage-package-manager-versions = true
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
samples/nodejs-compat-streams-split2/split2.js
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "es5"
}
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,21 @@
"hide": false,
"type": "shell",
"problemMatcher": []
},
{
"label": "Format all",
"command": "python3",
"args": [ "${workspaceFolder}/tools/cross/format.py" ],
"group": "build",
"problemMatcher": [],
"presentation": {
"reveal": "never",
"focus": false,
"panel": "shared",
},
"runOptions": {
"reevaluateOnRerun": true,
}
}
]
}
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ npm_link_package(
package = "@workerd/jsg",
)

# The @workerd/test package provides a small library to manage workerd subprocesses in js_test()
# targets.
npm_link_package(
name = "node_modules/@workerd/test",
src = "//src/workerd/server/tests:test_js",
package = "@workerd/test",
)

capnpc_ts_bin.capnpc_ts_binary(
name = "capnpc_ts",
visibility = ["//visibility:public"],
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ COPY . .
RUN echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc
RUN echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc
COPY .bazel-cache /bazel-disk-cache
RUN npm install -g pnpm@latest-7
# pnpm version will be different depending on the value of `packageManager` field in package.json
RUN npm install -g pnpm@latest
RUN pnpm install

RUN pnpm exec bazelisk build --disk_cache=/bazel-disk-cache --config=release_linux //src/workerd/server:workerd
Expand Down
52 changes: 23 additions & 29 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ workspace(name = "workerd")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

NODE_VERSION = "20.14.0"

http_archive(
name = "bazel_skylib",
sha256 = "9f38886a40548c6e96c106b752f242130ee11aaa068a56ba7e56f4511f33e4f2",
Expand Down Expand Up @@ -141,7 +143,7 @@ http_archive(
urls = ["https://github.com/dom96/pyodide_packages/releases/download/just-stdlib/pyodide_packages.tar.zip"],
)

load("//:build/pyodide_bucket.bzl", "PYODIDE_LOCK_SHA256", "PYODIDE_GITHUB_RELEASE_URL", "PYODIDE_ALL_WHEELS_ZIP_SHA256")
load("//:build/pyodide_bucket.bzl", "PYODIDE_ALL_WHEELS_ZIP_SHA256", "PYODIDE_GITHUB_RELEASE_URL", "PYODIDE_LOCK_SHA256")

http_file(
name = "pyodide-lock.json",
Expand All @@ -151,15 +153,15 @@ http_file(

http_archive(
name = "all_pyodide_wheels",
sha256 = PYODIDE_ALL_WHEELS_ZIP_SHA256,
urls = [PYODIDE_GITHUB_RELEASE_URL + "all_wheels.zip"],
build_file_content = """
filegroup(
name = "whls",
srcs = glob(["*"]),
visibility = ["//visibility:public"]
)
"""
""",
sha256 = PYODIDE_ALL_WHEELS_ZIP_SHA256,
urls = [PYODIDE_GITHUB_RELEASE_URL + "all_wheels.zip"],
)

# ========================================================================================
Expand Down Expand Up @@ -220,9 +222,9 @@ git_repository(

git_repository(
name = "fp16",
commit = "0a92994d729ff76a58f692d3028ca1b64b145d91",
build_file_content = "exports_files(glob([\"**\"]))",
remote = "https://chromium.googlesource.com/external/github.com/Maratyszcza/FP16.git"
commit = "0a92994d729ff76a58f692d3028ca1b64b145d91",
remote = "https://chromium.googlesource.com/external/github.com/Maratyszcza/FP16.git",
)

# Bindings for abseil libraries used by V8
Expand Down Expand Up @@ -373,9 +375,9 @@ rules_rust_dependencies()

rust_register_toolchains(
edition = "2021",
versions = ["1.77.0"], # LLVM 17
# Rust registers wasm targets by default which we don't need, workerd is only built for its native platform.
extra_target_triples = [],
versions = ["1.77.0"], # LLVM 17
)

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
Expand All @@ -395,52 +397,44 @@ rust_analyzer_dependencies()
#
# workerd uses Node.js scripts for generating TypeScript types.

# Fetch rules_nodejs before aspect_rules_js, otherwise we'll get an outdated rules_nodejs version.
http_archive(
name = "rules_nodejs",
integrity = "sha256-h8YXHFvntpU41Gldne0priYmxe12qa3u3ON7Y8c772c=",
strip_prefix = "rules_nodejs-6.2.0",
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.2.0/rules_nodejs-v6.2.0.tar.gz",
)

http_archive(
name = "aspect_rules_js",
integrity = "sha256-/GiHCR7jJDZh+1Mv0yRCMLbhk8IlZqA4yf10jKaPuIA=",
strip_prefix = "rules_js-1.42.3",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.42.3.tar.gz",
sha256 = "6b7e73c35b97615a09281090da3645d9f03b2a09e8caa791377ad9022c88e2e6",
strip_prefix = "rules_js-2.0.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0/rules_js-v2.0.0.tar.gz",
)

http_archive(
name = "aspect_rules_ts",
integrity = "sha256-9ppkUrEp052bBfPf+LEFcYW7GVtNrwz/QZmI3nV8bDE=",
strip_prefix = "rules_ts-2.4.2",
url = "https://github.com/aspect-build/rules_ts/archive/refs/tags/v2.4.2.tar.gz",
sha256 = "ee7dcc35faef98f3050df9cf26f2a72ef356cab8ad927efb1c4dc119ac082a19",
strip_prefix = "rules_ts-3.0.0",
url = "https://github.com/aspect-build/rules_ts/releases/download/v3.0.0/rules_ts-v3.0.0.tar.gz",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains")

nodejs_register_toolchains(
name = "nodejs",
rules_js_register_toolchains(
node_urls = [
# github workflows may substitute a mirror URL here to avoid fetch failures.
# "WORKERS_MIRROR_URL/https://nodejs.org/dist/v{version}/{filename}",
"https://nodejs.org/dist/v{version}/{filename}",
],
node_version = "20.14.0",
node_version = NODE_VERSION,
)

load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies", TS_LATEST_VERSION = "LATEST_TYPESCRIPT_VERSION")
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")

rules_ts_dependencies(ts_version = TS_LATEST_VERSION)
rules_ts_dependencies(ts_version_from = "//:package.json")

load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
patch_args = {
"capnp-ts@0.7.0": ["-p1"],
},
Expand Down Expand Up @@ -472,6 +466,7 @@ npm_repositories()

http_archive(
name = "v8",
integrity = "sha256-yoLczQj1XEZL4EHVRjAwpVjgr9/q0YlRGnNX47Ke2ws=",
patch_args = ["-p1"],
patches = [
"//:patches/v8/0001-Allow-manually-setting-ValueDeserializer-format-vers.patch",
Expand All @@ -498,7 +493,6 @@ http_archive(
"//:patches/v8/0019-wasm-Fix-more-code-logging-races.patch",
"//:patches/v8/0020-wasm-Remove-destructor-of-LogCodesTask.patch",
],
integrity = "sha256-yoLczQj1XEZL4EHVRjAwpVjgr9/q0YlRGnNX47Ke2ws=",
strip_prefix = "v8-12.8.374.10",
url = "https://github.com/v8/v8/archive/refs/tags/12.8.374.10.tar.gz",
)
Expand Down
Loading

0 comments on commit 30185d5

Please sign in to comment.