Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 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
36 changes: 36 additions & 0 deletions .github/workflows/check-js-generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Check Generated JS

on:
push:
paths-ignore: ['**.md']
branches-ignore: [staging]
pull_request:
paths-ignore: ['**.md']
branches-ignore: [staging]

permissions:
contents: read

jobs:
check-js-generated:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Install dependencies
run: |
corepack enable
corepack prepare yarn@4.14.1 --activate
yarn install --immutable

- name: Regenerate js/ outputs
run: yarn run build:javascript

- name: Fail if generated files are stale
run: ./ci/check-js-generated.sh
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ scan-build --keep-empty -internal-stats -stats -v -v -v -o check ninja.exe
```
Step with `"fixing"` errors is important as code base and especially third-party code are not ready to be build with clang. And files which failed to compile will not be scanned for errors.

#### Generated JS surface (`js/module.{js,d.ts}`)

`js/module.ts` is the source of truth. `js/module.js` and `js/module.d.ts` (and the `index.*` / `type_check.*` siblings) are tsc outputs of `js/tsconfig.json` — the npm package ships them as-is, so they're committed. Regenerate with `yarn build:javascript`. `yarn local:build` already chains it. CI rejects stale outputs via `.github/workflows/check-js-generated.yml` (`ci/check-js-generated.sh`).

### Tests

The tests for obs studio node are written in Typescript and use Mocha as test framework, with electron-mocha pacakage to make Mocha run in Electron, and Chai as assertion framework.
Expand Down
18 changes: 18 additions & 0 deletions ci/check-js-generated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Verify that the committed tsc outputs under js/ match what regenerating
# from js/module.ts would produce. CI runs `yarn build:javascript` first,
# so any change under js/ at this point is a stale generated file.
dirty=$(git status --porcelain -- js/)

set +x
if [[ $dirty ]]; then
Comment thread
summeroff marked this conversation as resolved.
Comment on lines +1 to +9
echo "================================================="
echo "Generated JS files are stale. Run locally:"
echo " yarn build:javascript"
echo "and commit the regenerated files."
echo ""
echo "Stale files:"
echo "$dirty"
echo "================================================="
exit 1
fi
Loading
Loading