Skip to content
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

Add snapshot check for workers-types #3188

Merged
merged 7 commits into from
Nov 29, 2024
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
47 changes: 47 additions & 0 deletions .github/workflows/type-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Check @cloudflare/workers-types snapshot

on:
pull_request:
paths-ignore:
- 'doc/**'
push:
branches:
- main

concurrency:
# Cancel existing builds for the same PR.
# Otherwise, all other builds will be allowed to run through.
group: type-snapshot.yml-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
check-snapshot:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Cache
id: cache
uses: actions/cache@v4
# Use same cache and build configuration as release build, this allows us to keep download
# sizes small and generate types with optimization enabled, should be slightly faster.
with:
path: ~/bazel-disk-cache
key: bazel-disk-cache-release-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }}
- 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 16
sudo apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-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
- name: build types
run: |
bazel build --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux //types:types
- name: Check snapshot diff
run: |
diff -r bazel-bin/types/definitions/ types/generated-snapshot
8 changes: 5 additions & 3 deletions types/defines/d1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface D1Response {

type D1Result<T = unknown> = D1Response & {
results: T[];
}
};

interface D1ExecResult {
count: number;
Expand All @@ -36,6 +36,8 @@ declare abstract class D1PreparedStatement {
first<T = Record<string, unknown>>(): Promise<T | null>;
run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
raw<T = unknown[]>(options: {columnNames: true}): Promise<[string[], ...T[]]>;
raw<T = unknown[]>(options?: {columnNames?: false}): Promise<T[]>;
raw<T = unknown[]>(options: {
columnNames: true;
}): Promise<[string[], ...T[]]>;
raw<T = unknown[]>(options?: { columnNames?: false }): Promise<T[]>;
}
Loading