|
1 | | -name: 🚀 CI |
| 1 | +name: CI |
2 | 2 | env: |
3 | 3 | DEBUG: napi:* |
4 | | - APP_NAME: cel-typescript |
5 | 4 | MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 5 | + RUST_BACKTRACE: 1 |
6 | 6 |
|
7 | 7 | on: |
8 | 8 | push: |
|
14 | 14 |
|
15 | 15 | jobs: |
16 | 16 | build: |
17 | | - name: 🔨 Build - ${{ matrix.settings.target }} - node@18 |
| 17 | + name: Build - ${{ matrix.target }} |
18 | 18 | if: "!contains(github.event.head_commit.message, 'skip ci')" |
19 | 19 | strategy: |
20 | 20 | fail-fast: false |
21 | 21 | matrix: |
22 | | - settings: |
23 | | - - host: macos-latest |
24 | | - target: aarch64-apple-darwin |
25 | | - build: | |
26 | | - npm install |
27 | | - npx @napi-rs/cli build --platform aarch64-apple-darwin |
28 | | - echo "Binary after build:" |
29 | | - ls -la *.node |
30 | | - strip -x *.node |
31 | | - echo "Binary after strip:" |
32 | | - ls -la *.node |
33 | | - runs-on: ${{ matrix.settings.host }} |
| 22 | + target: [aarch64-apple-darwin, x86_64-unknown-linux-gnu] |
| 23 | + include: |
| 24 | + - target: aarch64-apple-darwin |
| 25 | + os: macos-latest |
| 26 | + - target: x86_64-unknown-linux-gnu |
| 27 | + os: ubuntu-latest |
| 28 | + runs-on: ${{ matrix.os }} |
34 | 29 |
|
35 | 30 | steps: |
36 | 31 | - uses: actions/checkout@v4 |
37 | 32 | with: |
38 | 33 | submodules: recursive |
39 | 34 | fetch-depth: 0 |
40 | 35 |
|
41 | | - - name: Debug - List submodules |
42 | | - run: | |
43 | | - git submodule status |
44 | | - ls -la |
45 | | - ls -la cel-rust/ |
46 | | - ls -la cel-rust/interpreter/ |
47 | | - shell: bash |
48 | | - |
49 | 36 | - name: Setup node |
50 | 37 | uses: actions/setup-node@v4 |
51 | | - if: ${{ !matrix.settings.docker }} |
52 | 38 | with: |
53 | 39 | node-version: 18 |
54 | | - check-latest: true |
55 | 40 | cache: npm |
56 | 41 |
|
57 | | - - name: Install |
| 42 | + - name: Install Rust |
58 | 43 | uses: dtolnay/rust-toolchain@stable |
59 | | - if: ${{ !matrix.settings.docker }} |
60 | 44 | with: |
61 | | - targets: ${{ matrix.settings.target }} |
| 45 | + toolchain: stable |
| 46 | + targets: ${{ matrix.target }} |
| 47 | + |
| 48 | + - name: Cache NPM dependencies |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: node_modules |
| 52 | + key: npm-cache-${{ matrix.target }}-node@18-${{ hashFiles('package-lock.json') }} |
62 | 53 |
|
63 | | - - name: 💾 Cache cargo |
| 54 | + - name: Cache Rust dependencies |
64 | 55 | uses: actions/cache@v4 |
65 | 56 | with: |
66 | 57 | path: | |
67 | 58 | ~/.cargo/registry/index/ |
68 | 59 | ~/.cargo/registry/cache/ |
69 | 60 | ~/.cargo/git/db/ |
70 | | - .cargo-cache |
71 | 61 | target/ |
72 | | - key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} |
73 | | - |
74 | | - - uses: goto-bus-stop/setup-zig@v2 |
75 | | - if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} |
76 | | - with: |
77 | | - version: 0.11.0 |
78 | | - |
79 | | - - name: 🔧 Setup toolchain |
80 | | - if: ${{ matrix.settings.docker }} |
81 | | - uses: actions-rs/toolchain@v1 |
82 | | - with: |
83 | | - toolchain: stable |
84 | | - target: ${{ matrix.settings.target }} |
85 | | - override: true |
86 | | - |
87 | | - - name: Cache NPM dependencies |
88 | | - uses: actions/cache@v4 |
89 | | - with: |
90 | | - path: node_modules |
91 | | - key: npm-cache-${{ matrix.settings.target }}-${{ hashFiles('package-lock.json') }} |
| 62 | + key: rust-cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} |
92 | 63 |
|
93 | 64 | - name: Install dependencies |
94 | | - run: npm ci |
95 | | - |
96 | | - - name: 🐳 Build in docker |
97 | | - uses: addnab/docker-run-action@v3 |
98 | | - if: ${{ matrix.settings.docker }} |
99 | | - with: |
100 | | - image: ${{ matrix.settings.docker }} |
101 | | - options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build |
102 | | - run: ${{ matrix.settings.build }} |
103 | | - |
104 | | - - name: Build |
105 | | - if: ${{ !matrix.settings.docker }} |
106 | | - run: ${{ matrix.settings.build }} |
| 65 | + run: npm install |
107 | 66 | shell: bash |
108 | 67 |
|
109 | | - - name: 🔍 Debug - List files after build |
110 | | - run: | |
111 | | - echo "Current directory:" |
112 | | - pwd |
113 | | - echo "\nFiles in current directory:" |
114 | | - ls -la |
115 | | - echo "\nNode files:" |
116 | | - find . -name "*.node" |
| 68 | + - name: Build |
| 69 | + run: npx nx build:native -- --platform ${{ matrix.target }} |
117 | 70 | shell: bash |
118 | 71 |
|
119 | | - - name: 📤 Upload artifact |
| 72 | + - name: Upload artifact |
120 | 73 | uses: actions/upload-artifact@v4 |
121 | 74 | with: |
122 | | - name: bindings-${{ matrix.settings.target }} |
| 75 | + name: bindings-${{ matrix.target }} |
123 | 76 | path: | |
124 | | - *.node |
| 77 | + **/*.node |
| 78 | + !node_modules/**/*.node |
125 | 79 | !target/**/*.node |
126 | 80 | if-no-files-found: error |
127 | 81 | retention-days: 1 |
128 | 82 |
|
129 | 83 | test: |
130 | | - name: 🧪 Test ${{ matrix.platform.name }} - node@${{ matrix.node }} |
| 84 | + name: Test ${{ matrix.platform.name }} - node@${{ matrix.node }} |
131 | 85 | needs: |
132 | 86 | - build |
133 | 87 | strategy: |
@@ -171,59 +125,16 @@ jobs: |
171 | 125 | ${{ hashFiles('package-lock.json', '**/Cargo.lock') }} |
172 | 126 |
|
173 | 127 | - name: Install dependencies |
174 | | - run: npm ci |
175 | | - |
176 | | - - name: 🖥️ Setup QEMU |
177 | | - if: matrix.platform.qemu |
178 | | - uses: docker/setup-qemu-action@v3 |
179 | | - with: |
180 | | - platforms: ${{ matrix.platform.qemu }} |
181 | | - |
182 | | - - name: 📱 Install Android NDK |
183 | | - if: matrix.platform.android |
184 | | - run: | |
185 | | - wget https://dl.google.com/android/repository/android-ndk-r25c-linux.zip |
186 | | - unzip android-ndk-r25c-linux.zip |
187 | | - echo "ANDROID_NDK_HOME=$PWD/android-ndk-r25c" >> $GITHUB_ENV |
188 | | -
|
189 | | - - name: 📥 Download artifacts |
190 | 128 | uses: actions/download-artifact@v4 |
191 | 129 | with: |
192 | | - name: bindings-${{ matrix.platform.target }} |
193 | | - path: . |
| 130 | + name: bindings-${{ matrix.target }} |
194 | 131 |
|
195 | | - - name: List files |
196 | | - run: ls -R . |
197 | | - shell: bash |
| 132 | + - name: Install dependencies |
| 133 | + run: npm install |
198 | 134 |
|
199 | | - - name: Test bindings (native) |
200 | | - if: "!matrix.platform.docker" |
| 135 | + - name: Test |
201 | 136 | run: npm test |
202 | 137 |
|
203 | | - - name: Test bindings (Docker) |
204 | | - if: matrix.platform.docker |
205 | | - run: | |
206 | | - docker run --rm ${{ matrix.platform.qemu && format('--platform linux/{0}', matrix.platform.qemu) || '' }} \ |
207 | | - -v $(pwd):/build -w /build node:${{ matrix.node }}-slim bash -c ' |
208 | | - # Install Rust |
209 | | - apt-get update && apt-get install -y curl build-essential |
210 | | - curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
211 | | - export PATH="/root/.cargo/bin:$PATH" |
212 | | -
|
213 | | - # Fix npm optional dependencies on ARM64 |
214 | | - if [[ "${{ matrix.platform.target }}" == *"aarch64"* ]]; then |
215 | | - # Ensure clean state |
216 | | - rm -rf node_modules |
217 | | - # Install dependencies with --no-optional to skip problematic deps |
218 | | - npm install --no-optional |
219 | | - # Now install only the required optional deps |
220 | | - npm install @rollup/rollup-linux-arm64-gnu |
221 | | - fi |
222 | | -
|
223 | | - # Run tests |
224 | | - npm test |
225 | | - ' |
226 | | -
|
227 | 138 | dry-run-publish: |
228 | 139 | name: Dry Run Publish |
229 | 140 | runs-on: ubuntu-latest |
|
0 commit comments