Introducing better Workers AI types #257
Workflow file for this run
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
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 > types.diff | |
- name: 'Put diff on the environment' | |
if: failure() | |
id: types_diff | |
run: | | |
{ | |
echo 'TYPES_DIFF<<EOF' | |
cat types.diff | |
echo EOF | |
} >> "$GITHUB_ENV" | |
- uses: actions/upload-artifact@v4 | |
id: artifact-upload-step | |
if: failure() | |
with: | |
name: generated-snapshot | |
path: bazel-bin/types/definitions/ | |
- name: 'Comment on PR with error details' | |
if: failure() | |
uses: marocchino/sticky-pull-request-comment@daa4a82a0a3f6c162c02b83fa44b3ab83946f7cb | |
with: | |
message: | | |
The generated output of `@cloudflare/workers-types` has been changed by this PR. If this is intentional, run `bazel build //types && rm -rf types/generated-snapshot && cp -r bazel-bin/types/definitions types/generated-snapshot` to update the snapshot. Alternatively, you can download the full generated types: ${{ steps.artifact-upload-step.outputs.artifact-url }} | |
<details> | |
<summary>Full Type Diff</summary> | |
```diff | |
${{ env.TYPES_DIFF }} | |
``` | |
</details> | |
- name: 'Comment on PR with error details' | |
if: success() | |
uses: marocchino/sticky-pull-request-comment@daa4a82a0a3f6c162c02b83fa44b3ab83946f7cb | |
with: | |
only_update: true | |
message: | | |
The generated output of `@cloudflare/workers-types` matches the snapshot in `types/generated-snapshot` :tada: |