|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-and-test: |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - os: ubuntu-latest |
| 18 | + platform: linux |
| 19 | + arch: x64 |
| 20 | + mac_env: false |
| 21 | + - os: ubuntu-24.04-arm |
| 22 | + platform: linux |
| 23 | + arch: arm64 |
| 24 | + mac_env: false |
| 25 | + - os: macos-latest |
| 26 | + platform: darwin |
| 27 | + arch: arm64 |
| 28 | + mac_env: true |
| 29 | + - os: windows-latest |
| 30 | + platform: win32 |
| 31 | + arch: x64 |
| 32 | + mac_env: false |
| 33 | + steps: |
| 34 | + - name: Checkout nodejs_api |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + path: tools/nodejs_api |
| 38 | + |
| 39 | + - name: Fetch ladybug source archive |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + curl -fsSL https://github.com/LadybugDB/ladybug/archive/refs/heads/main.tar.gz \ |
| 43 | + | tar -xz --strip-components=1 --exclude='*/tools/nodejs_api' |
| 44 | + # Downloads the ladybug source tree (without a full clone) and extracts |
| 45 | + # it into the working directory, excluding tools/nodejs_api since we |
| 46 | + # already have it checked out there. |
| 47 | + |
| 48 | + - name: Fetch dataset archive |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + mkdir -p dataset |
| 52 | + curl -fsSL https://github.com/ladybugdb/dataset/archive/refs/heads/main.tar.gz \ |
| 53 | + | tar -xz --strip-components=1 -C dataset |
| 54 | + # Tests reference ../../dataset/ relative to tools/nodejs_api. |
| 55 | + |
| 56 | + - name: Install Node.js dependencies (non-Windows) |
| 57 | + if: ${{ matrix.platform != 'win32' }} |
| 58 | + working-directory: tools/nodejs_api |
| 59 | + run: npm i |
| 60 | + env: |
| 61 | + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.mac_env && '13.3' || '' }} |
| 62 | + ARCHFLAGS: ${{ matrix.mac_env && format('-arch {0}', matrix.arch) || '' }} |
| 63 | + |
| 64 | + - name: Install Node.js dependencies (Windows) |
| 65 | + if: ${{ matrix.platform == 'win32' }} |
| 66 | + working-directory: tools/nodejs_api |
| 67 | + run: npm i |
| 68 | + |
| 69 | + - name: Enable long paths (Windows) |
| 70 | + if: ${{ matrix.platform == 'win32' }} |
| 71 | + run: | |
| 72 | + New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force |
| 73 | + git config --system core.longpaths true |
| 74 | + shell: pwsh |
| 75 | + |
| 76 | + - name: Set up ccache (Windows) |
| 77 | + if: ${{ matrix.platform == 'win32' }} |
| 78 | + shell: cmd |
| 79 | + run: | |
| 80 | + choco install ccache -y |
| 81 | + echo CMAKE_C_COMPILER_LAUNCHER=ccache>> %GITHUB_ENV% |
| 82 | + echo CMAKE_CXX_COMPILER_LAUNCHER=ccache>> %GITHUB_ENV% |
| 83 | + echo CCACHE_DIR=D:\c>> %GITHUB_ENV% |
| 84 | + echo CCACHE_TEMPDIR=D:\t>> %GITHUB_ENV% |
| 85 | + if not exist D:\c mkdir D:\c |
| 86 | + if not exist D:\t mkdir D:\t |
| 87 | + ccache --set-config=max_size=2G |
| 88 | + ccache --set-config=compression=true |
| 89 | + ccache --set-config=cache_dir=D:\c |
| 90 | + ccache --set-config=temporary_dir=D:\t |
| 91 | + env: |
| 92 | + CMAKE_C_COMPILER_LAUNCHER: ccache |
| 93 | + CMAKE_CXX_COMPILER_LAUNCHER: ccache |
| 94 | + |
| 95 | + - name: Cache ccache directory (Windows) |
| 96 | + if: ${{ matrix.platform == 'win32' }} |
| 97 | + uses: actions/cache@v4 |
| 98 | + with: |
| 99 | + path: D:\c |
| 100 | + key: ${{ runner.os }}-ccache-node-${{ hashFiles('**/CMakeLists.txt', '**/*.cpp', '**/*.h', 'tools/nodejs_api/**') }} |
| 101 | + restore-keys: | |
| 102 | + ${{ runner.os }}-ccache-node- |
| 103 | +
|
| 104 | + - name: Build Node.js native module (Windows) |
| 105 | + if: ${{ matrix.platform == 'win32' }} |
| 106 | + shell: cmd |
| 107 | + run: | |
| 108 | + powershell.exe -Command "Add-MpPreference -ExclusionPath '${{ github.workspace }}'" |
| 109 | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" |
| 110 | + ccache -s |
| 111 | + make GEN=Ninja nodejs |
| 112 | + ccache -s |
| 113 | +
|
| 114 | + - name: Build Node.js native module (non-Windows) |
| 115 | + if: ${{ matrix.platform != 'win32' }} |
| 116 | + run: make GEN=Ninja nodejs |
| 117 | + env: |
| 118 | + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.mac_env && '13.3' || '' }} |
| 119 | + CMAKE_OSX_ARCHITECTURES: ${{ matrix.mac_env && matrix.arch || '' }} |
| 120 | + |
| 121 | + - name: Run Node.js tests |
| 122 | + working-directory: tools/nodejs_api |
| 123 | + run: npm test |
0 commit comments