Skip to content

Conversation

@ericsciple
Copy link
Collaborator

@ericsciple ericsciple commented Dec 5, 2025

Overview

This PR optimizes the webhook payload JSON files used for GitHub Actions autocompletion and hover documentation, achieving a 55% size reduction for these files:

Metric Before After Reduction
Minified 464 KB 209 KB 55%
Gzipped 63 KB 22 KB 65%

Changes

New Optimizations

  1. Compact array format — Params converted from verbose objects to type-dispatched arrays:

    // Before
    {"name": "issue", "description": "The issue itself.", "childParamsGroups": [...]}
    
    // After  
    ["issue", "The issue itself.", [...]]
  2. Object deduplication — Shared structures extracted to objects.json and referenced by index

  3. String interning — 414 duplicate property names stored in strings.json and referenced by index

Size Reduction

File Before After Gzip
webhooks 265 KB 141 KB 13 KB
objects 199 KB 62 KB 7 KB
strings 6 KB 2 KB
Total 464 KB 209 KB 22 KB

Testing

  • All 395 existing tests pass
  • Added validation test that compares optimized output against full source (webhooks.full.json) to ensure no data loss
  • Lint and format checks pass

Documentation

Updated docs/json-data-files.md with:

  • Compact format specification
  • String interning explanation
  • Deduplication details
  • Size reduction breakdown

@ericsciple ericsciple force-pushed the users/ericsciple/25-12-webhooks branch from bfb514f to 4dacd2c Compare December 6, 2025 05:53
@ericsciple ericsciple changed the title Add JSON optimization plan for webhooks/objects data files Optimize webhooks/objects JSON with string interning Dec 6, 2025
@ericsciple ericsciple changed the title Optimize webhooks/objects JSON with string interning Optimize webhooks JSON with compact structure and string interning Dec 6, 2025
@ericsciple ericsciple force-pushed the users/ericsciple/25-12-webhooks branch from 4dacd2c to 27aec5d Compare December 6, 2025 06:23
run: cd languageservice && npm test -- --testPathPattern=eventPayloads
- name: Verify validation tests ran
run: |
if [ ! -f languageservice/src/context-providers/events/webhooks.full.validation-complete ]; then
Copy link
Collaborator Author

@ericsciple ericsciple Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the test is normally skipped when the full webhooks file doesn't exist, I made the test write a marker file. With the marker file, we can be sure the test actually ran.

The full webhooks file (unoptimized) is written above by the script npm run update-webhooks

exit 1
fi
validate-webhooks:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this job to validate the optimized webhooks JSON is equivalent to the full webhooks JSON file.

Refer changes to the file eventPayloads.test.ts in this PR

@ericsciple ericsciple force-pushed the users/ericsciple/25-12-webhooks branch from 27aec5d to 8fbd093 Compare December 6, 2025 06:32
@@ -1,310 +0,0 @@
import {promises as fs} from "fs";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed this file to update-webhooks.ts but there were also significant updates anyway

@@ -1,7 +1,8 @@
import {data, DescriptionDictionary} from "@actions/expressions";

Copy link
Collaborator Author

@ericsciple ericsciple Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eventsPayloads.ts reads the compact webhook JSON files which contains the keys and descriptions for each GitHub event payload. This information is used to validate github.event.* syntax and provide descriptions on hover.

A unit test that runs during CI validates the compact webhook JSON files are parsed into a form that exactly matches the full unoptimized webhooks JSON.

The script update-webhooks.ts downloads the full webhook JSON from the GitHub REST API description repository:

import schemaImport from "rest-api-description/descriptions/api.github.com/dereferenced/api.github.com.deref.json";

@ericsciple ericsciple force-pushed the users/ericsciple/25-12-webhooks branch from 8fbd093 to b541ddf Compare December 6, 2025 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants