Skip to content

Migrate to Bun, remove unused scripts and speed up builds #21

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

Merged
merged 40 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8d83c4f
refactor: clean up repo a bit
pepperoni505 Apr 3, 2025
46077ed
refactor: move js -> ts folder & use bun
SkySails Apr 4, 2025
bba03cc
chore: remove leftover config
SkySails Apr 4, 2025
7b10c9f
style: format example
SkySails Apr 4, 2025
177373c
chore: run lint autofix
SkySails Apr 4, 2025
36ae9dd
chore: manual lint fixes
SkySails Apr 4, 2025
510ba68
build: better typechecking
SkySails Apr 4, 2025
61aef12
ci: use bun
SkySails Apr 4, 2025
9cbc646
fix: re-add `config.toml`
pepperoni505 Apr 7, 2025
e2fe15f
chore: change to text lockfile
pepperoni505 Apr 7, 2025
e40f73a
feat: add wasm build script
pepperoni505 Apr 7, 2025
c9fadd8
fix invalid actions
pepperoni505 Apr 7, 2025
eaef05b
fix indent
pepperoni505 Apr 7, 2025
af08f94
don't install bun in named step
pepperoni505 Apr 7, 2025
1fbfde3
Merge branch 'main' into bun
pepperoni505 Apr 7, 2025
a74dad4
fix: move `navigraph` folder
pepperoni505 Apr 7, 2025
57b7e85
fix: download in chunks
pepperoni505 Apr 4, 2025
eac4adc
feat: report download percent
pepperoni505 Apr 7, 2025
0f995e4
feat: include chunk number in download report
pepperoni505 Apr 7, 2025
44de7a8
chore: get rid of type/lint errors
SkySails Apr 7, 2025
22fdb94
chore: use parseArgs
SkySails Apr 7, 2025
9eb6333
chore: build without cache
SkySails Apr 7, 2025
4b18d09
style: formatting
SkySails Apr 7, 2025
35ab95c
chore: make sample typecheck successfully
SkySails Apr 7, 2025
1a09011
build: another typecheck fix attempt
SkySails Apr 7, 2025
dd7c8e0
build: add `@microsoft/msfs-types` to deps
SkySails Apr 7, 2025
7b4ad63
ci: disable builds
SkySails Apr 7, 2025
5ac6305
chore: more attempts
SkySails Apr 7, 2025
d3d1a03
ci: reenable builds
SkySails Apr 7, 2025
df7c7e1
Merge pull request #20 from Navigraph/chunked-downloads
pepperoni505 Apr 8, 2025
8135cf1
build: update lockfile
SkySails Apr 8, 2025
2ac1291
feat: enable parallel builds
SkySails Apr 8, 2025
6c04c51
ci: separate build & package
SkySails Apr 8, 2025
dfd0b3e
ci: add cache
SkySails Apr 8, 2025
185dca8
ci: save built docker image
SkySails Apr 8, 2025
11cc1f6
ci: use color to separate build logs
SkySails Apr 8, 2025
e8de612
ci: remove unnecessary
SkySails Apr 8, 2025
a4b4013
ci: add cache to release workflows
SkySails Apr 8, 2025
81240c7
Merge branch 'main' into bun
SkySails Apr 8, 2025
1efe5d0
ci: remove unnecessary step
SkySails Apr 8, 2025
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
27 changes: 3 additions & 24 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
[target.wasm32-wasip1]
rustflags = [
"-Ctarget-feature=-crt-static,+bulk-memory",
"-Clink-self-contained=no",
"-Clink-arg=-l",
"-Clink-arg=c",
"-Clink-arg=/workdir/MSFS_SDK/WASM/wasi-sysroot/lib/wasm32-wasi/libclang_rt.builtins-wasm32.a",
"-Clink-arg=-L",
"-Clink-arg=/workdir/MSFS_SDK/WASM/wasi-sysroot/lib/wasm32-wasi",
"-Clink-arg=--export-table",
"-Clink-arg=--allow-undefined",
"-Clink-arg=--export-dynamic",
"-Clink-arg=--export=__wasm_call_ctors",
"-Clink-arg=--export=malloc",
"-Clink-arg=--export=free",
"-Clink-arg=--export=mark_decommit_pages",
"-Clink-arg=--export=mallinfo",
"-Clink-arg=--export=mchunkit_begin",
"-Clink-arg=--export=mchunkit_next",
"-Clink-arg=--export=get_pages_state",
]

[build]
target = "wasm32-wasip1"
[build]
target = "wasm32-wasip1"
target-dir = "targets/2020"
4 changes: 0 additions & 4 deletions .dockerignore

This file was deleted.

43 changes: 0 additions & 43 deletions .eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Store rust cache

# This workflow is needed since any cache created
# This workflow is needed since any cache created
# on a feature-branch will NOT be available on any other ref.
# See: https://github.com/actions/cache/issues/79

Expand Down Expand Up @@ -48,4 +48,4 @@ jobs:
key: rust-targets

- name: Build WASM
run: bun run build:wasm && bun run package
run: bun run build:wasm
62 changes: 51 additions & 11 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,34 @@ jobs:
if: ${{ needs.filter.outputs.js-interface == 'true' && !github.event.pull_request.draft && !contains(github.event.pull_request.labels.*.name , 'release') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4

- uses: oven-sh/setup-bun@v2
with:
node-version: "18"
cache: "npm"
bun-version: latest

- name: Install node modules
run: npm ci
run: bun i --frozen-lockfile

- name: Run linting
run: npm run lint:js -- --max-warnings 0
run: bun lint --max-warnings 0

typecheck:
name: Check types 🕵️‍♂️
runs-on: ubuntu-latest
needs: [filter]
if: ${{ needs.filter.outputs.js-interface == 'true' && !github.event.pull_request.draft && !contains(github.event.pull_request.labels.*.name , 'release') }}
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install node modules
run: bun i --frozen-lockfile

- name: Check types
run: bun typecheck

build-test:
name: Build & test 🛠️
Expand All @@ -63,15 +80,38 @@ jobs:
echo NAVIGATION_DATA_SIGNED_URL=${{ secrets.NAVIGATION_DATA_SIGNED_URL }} >> .env
echo SENTRY_URL=${{ secrets.SENTRY_URL }} >> .env

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install node modules
run: bun i --frozen-lockfile

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build cargo-msfs image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
tags: navigation-data-interface-wasm-build:latest
load: true
cache-from: type=gha
cache-to: type=gha

- name: Cache target directories
uses: actions/cache@v4
with:
path: targets
key: rust-targets

- name: Build WASM
run: ./scripts/workflow.sh
run: bun run build:wasm && bun run package


- name: Upload WASM module to GitHub
uses: actions/upload-artifact@v4
with:
name: msfs_navigation_data_interface
name: wasm
path: |
./2020.zip
./2024.zip
./wasm.zip
33 changes: 29 additions & 4 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,40 @@ jobs:
run: |
echo SENTRY_URL=${{ secrets.SENTRY_URL }} >> .env

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install node modules
run: bun i --frozen-lockfile

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build cargo-msfs image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
tags: navigation-data-interface-wasm-build:latest
load: true
cache-from: type=gha
cache-to: type=gha

- name: Cache target directories
uses: actions/cache@v4
with:
path: targets
key: rust-targets

- name: Build WASM
run: ./scripts/workflow.sh
run: bun run build:wasm && bun run package

- name: Pre-Release
uses: softprops/action-gh-release@v1
with:
files: |
./2020.zip
./2024.zip
./wasm.zip
prerelease: true
generate_release_notes: true

Expand All @@ -51,4 +76,4 @@ jobs:
# - name: Publish to NPM
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# run: cd src/js && npm publish --tag next
# run: cd src/js && npm publish --tag next
47 changes: 35 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- "!v*-rc*"
- "!v*-alpha*"
- "!v*-beta*"

name: Create release
run-name: Create release for `${{ github.ref_name }}`

Expand All @@ -19,15 +19,40 @@ jobs:
run: |
echo SENTRY_URL=${{ secrets.SENTRY_URL }} >> .env

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install node modules
run: bun i --frozen-lockfile

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build cargo-msfs image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
tags: navigation-data-interface-wasm-build:latest
load: true
cache-from: type=gha
cache-to: type=gha

- name: Cache target directories
uses: actions/cache@v4
with:
path: targets
key: rust-targets

- name: Build WASM
run: ./scripts/workflow.sh
run: bun run build:wasm && bun run package

- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
./2020.zip
./2024.zip
./wasm.zip
generate_release_notes: true

# Enable in future to automate publishing of NPM package
Expand All @@ -36,19 +61,17 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v2
with:
node-version: "18"
registry-url: 'https://registry.npmjs.org'
cache: "npm"
bun-version: latest

- name: Install node modules
run: npm ci
run: bun i --frozen-lockfile

- name: Build JS Interface
run: cd src/js && npm run build
run: cd src/ts && bun run build

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: cd src/js && npm publish
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
run: cd src/ts && bun publish
17 changes: 5 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@ _PackageInt
tsconfig.tsbuildinfo
.vs
examples/aircraft/NavigationDataInterfaceAircraftProject.xml.user
examples/aircraft/PackageSources/html_ui/Pages/VCockpit/Instruments/Navigraph/NavigationDataInterfaceSample
examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel/msfs_navigation_data_interface.wasm
out
out20
out24
example/aircraft/PackageSources/html_ui/Pages/VCockpit/Instruments/Navigraph/NavigationDataInterfaceSample
example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel/msfs_navigation_data_interface.wasm

# Rust
# will have compiled files and executables
debug/
target/
targets

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
# Cargo.lock
# Who put this here

# These are backup files generated by rustfmt
**/*.rs.bk
Expand All @@ -32,5 +25,5 @@ target/
*.local
.DS_Store

test_work/
dist
dist

8 changes: 0 additions & 8 deletions .prettierignore

This file was deleted.

16 changes: 7 additions & 9 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"trailingComma": "all",
"printWidth": 120,
"singleQuote": false,
"arrowParens": "avoid",
"semi": false,
"endOfLine": "auto",
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"importOrder": ["<THIRD_PARTY_MODULES>", "@[A-Z](.*)", "^[./]"]
}
"trailingComma": "all",
"printWidth": 120,
"singleQuote": false,
"arrowParens": "avoid",
"semi": true,
"endOfLine": "auto"
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.84
FROM rust:1.84.1

# Install needed packages and clean up
RUN apt update && \
Expand All @@ -19,6 +19,9 @@ RUN rustup target install wasm32-wasip1
# Install cargo-msfs
RUN cargo install --git https://github.com/navigraph/cargo-msfs

# Cache bust arg to re-install both SDKs
ARG CACHEBUST

# Install MSFS2020 and MSFS2024 SDK
RUN cargo-msfs install msfs2020 && \
cargo-msfs install msfs2024
Loading