Skip to content

Commit 3874a16

Browse files
feat: unit tests and project refactor (#1)
* start node running of interface * refactors * fix: update `memoryBuffer` after `malloc` * refactor: add `test_out` directory, fix our path type implementation * refactor: project structure * feat: jest test environment * fix: stop lifecycle once tests completed * feat: automatic download * remove unnecessary package * refactor: Cleanup setup.ts * fix: make sh files executable * fix: have build run with docker * feat: test workflow * fix: make test.sh executable * Update test.sh * test * Update setup.ts * Create push.yml * Update push.yml * general fixes * fix: workspace issues --------- Co-authored-by: Jack Lavigne <[email protected]>
1 parent 827de97 commit 3874a16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6538
-4278
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
[target.wasm32-wasi]
2-
rustflags = [
3-
"-Clink-arg=--export-table",
4-
"-Clink-arg=--export=malloc",
5-
"-Clink-arg=--export=free",
6-
"-Clink-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/wasi",
7-
"-Clink-arg=-lclang_rt.builtins-wasm32"
8-
]
9-
10-
[build]
1+
[target.wasm32-wasi]
2+
rustflags = [
3+
"-Clink-arg=--export-table",
4+
"-Clink-arg=--export=malloc",
5+
"-Clink-arg=--export=free",
6+
"-Clink-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/wasi",
7+
"-Clink-arg=-lclang_rt.builtins-wasm32"
8+
]
9+
10+
[build]
1111
target = "wasm32-wasi"

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
ignorePatterns: [".eslintrc.js", "src/wasm_navdata_interface/", "msfstypes/"],
3+
ignorePatterns: [".eslintrc.js", "src/wasm/", "msfstypes/"],
44
env: { browser: true, commonjs: true, es6: true },
55
plugins: ["@typescript-eslint"],
66
extends: [
@@ -11,7 +11,7 @@ module.exports = {
1111
],
1212
parserOptions: {
1313
tsconfigRootDir: __dirname,
14-
project: ["./examples/gauge/tsconfig.json"],
14+
project: ["./tsconfig.json"],
1515
ecmaVersion: 2022,
1616
sourceType: "module",
1717
ecmaFeatures: { jsx: true },

.github/workflows/pr.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v2
15-
- name: Build WASM module
15+
- name: create env file
1616
run: |
17-
./src/wasm_navdata_interface/scripts/run_docker_cmd.sh ./scripts/build.sh
17+
touch .env
18+
echo NAVDATA_SIGNED_URL=${{ secrets.NAVDATA_SIGNED_URL }} >> .env
19+
- name: Build WASM module
20+
run: npm run build:wasm-workflow
21+
- name: Test
22+
run: npm run test-workflow
1823
- name: Upload WASM module to GitHub
1924
uses: actions/upload-artifact@v2
2025
with:
21-
name: navdata_interface.wasm
22-
path: ./src/wasm_navdata_interface/out/navdata_interface.wasm
26+
name: msfs_navdata_interface.wasm
27+
path: ./out/msfs_navdata_interface.wasm

.github/workflows/pre-release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v2
1414
- name: Build WASM module
15-
run: |
16-
./src/wasm_navdata_interface/scripts/run_docker_cmd.sh ./scripts/build.sh
15+
run: npm run build:wasm-workflow
1716
- name: Pre-Release
1817
uses: softprops/action-gh-release@v1
1918
with:
20-
files: ./src/wasm_navdata_interface/out/navdata_interface.wasm
19+
files: ./out/msfs_navdata_interface.wasm
2120
prerelease: true

.github/workflows/push.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: create env file
13+
run: |
14+
touch .env
15+
echo NAVDATA_SIGNED_URL=${{ secrets.NAVDATA_SIGNED_URL }} >> .env
16+
- name: Build WASM module
17+
run: npm run build:wasm-workflow
18+
- name: Test
19+
run: npm run test-workflow
20+
- name: Upload WASM module to GitHub
21+
uses: actions/upload-artifact@v2
22+
with:
23+
name: msfs_navdata_interface.wasm
24+
path: ./out/msfs_navdata_interface.wasm

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v2
1515
- name: Build WASM module
16-
run: |
17-
./src/wasm_navdata_interface/scripts/run_docker_cmd.sh ./scripts/build.sh
16+
run: npm run build:wasm-workflow
1817
- name: Release
1918
uses: softprops/action-gh-release@v1
2019
with:
21-
files: ./src/wasm_navdata_interface/out/navdata_interface.wasm
20+
files: ./out/msfs_navdata_interface.wasm

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ _PackageInt
55
tsconfig.tsbuildinfo
66
.vs
77
examples/aircraft/PackageSources/html_ui/Pages/VCockpit/Instruments/Navigraph/NavdataInterfaceSample
8-
examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel/navdata_interface.wasm
9-
src/wasm_navdata_interface/out
8+
examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel/msfs_navdata_interface.wasm
9+
out
1010

1111
# Rust
1212
# will have compiled files and executables
@@ -27,3 +27,5 @@ Cargo.lock
2727
.env
2828
*.local
2929
.DS_Store
30+
31+
test_work/

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# @Navigraph/app-dev will be requested for
44
# review when someone opens a pull request.
55
* @pepperoni505
6+
* @professoralex13

Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[workspace]
2+
resolver = "2"
3+
4+
members = ["src/wasm"]
5+
6+
[profile.release]
7+
lto = true
8+
strip = true
9+
10+
[patch.crates-io]
11+
rusqlite = { git = "https://github.com/navigraph/rusqlite", rev = "7921774" }

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ Here's an overview on the structure of this repository, which is designed to be
1313
- `aircraft/` includes a base aircraft to test in the sim
1414
- `gauge/` includes a very simple TypeScript instrument to communicate with the WASM module
1515
- `src/`
16-
- Contains the source for the navdata interface (and soon the JS library)
17-
- `wasm_navdata_interface` includes the Rust source code for the WASM module
16+
- `js` Includes source code for the JS interface for using the sdk
17+
- `test` Includes code for testing the JS and Rust code using a Node runtime
18+
- `wasm` includes the Rust source code for the WASM module which handles the database interface
1819

1920
## Including in Your Aircraft
2021

@@ -44,7 +45,6 @@ Before building, make sure you have properly created and set an `.env` file in `
4445
## Building the WASM Module Yourself
4546

4647
1. [Download](https://www.docker.com/products/docker-desktop/) Docker Desktop
47-
2. Open the `src/wasm_navdata_interface` folder in a terminal
48-
3. Run `.\build.bat` (must be on Windows)
48+
2. Run `npm run build:wasm` (must be on Windows)
4949
- This will take a while to download and build the first time, but subsequent runs will be quicker
50-
4. The compiled WASM module will be copied to `src/wasm_navdata_interface/out` **and** `examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel`
50+
3. The compiled WASM module will be copied to `out` **and** `examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel`

0 commit comments

Comments
 (0)