|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + - grist-main |
| 9 | + - grist-main-dev |
| 10 | + tags: |
| 11 | + - '*' |
| 12 | +env: |
| 13 | + FORCE_COLOR: 1 |
| 14 | +concurrency: |
| 15 | + group: ${{ github.head_ref || github.run_id }} |
| 16 | + cancel-in-progress: true |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + os: |
| 24 | + - macos-latest |
| 25 | + - ubuntu-20.04 |
| 26 | + - windows-latest |
| 27 | + host: |
| 28 | + - x64 |
| 29 | + target: |
| 30 | + - x64 |
| 31 | + node: |
| 32 | + - 14 |
| 33 | + - 16 |
| 34 | + - 18 |
| 35 | + include: |
| 36 | + - os: windows-latest |
| 37 | + node: 16 |
| 38 | + host: x86 |
| 39 | + target: x86 |
| 40 | + # This is a self-hosted runner, github doesn't have this architecture yet. |
| 41 | + - os: macos-m1 |
| 42 | + node: 16 |
| 43 | + host: arm64 |
| 44 | + target: arm64 |
| 45 | + name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }}) |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v3 |
| 48 | + - uses: actions/setup-node@v3 |
| 49 | + with: |
| 50 | + node-version: ${{ matrix.node }} |
| 51 | + architecture: ${{ matrix.host }} |
| 52 | + |
| 53 | + - name: Add yarn (self-hosted) |
| 54 | + if: matrix.os == 'macos-m1' |
| 55 | + run: npm install -g yarn |
| 56 | + |
| 57 | + - name: Add msbuild to PATH |
| 58 | + |
| 59 | + if: contains(matrix.os, 'windows') |
| 60 | + with: |
| 61 | + msbuild-architecture: ${{ matrix.target }} |
| 62 | + |
| 63 | + - name: Install dependencies |
| 64 | + run: yarn install --ignore-scripts |
| 65 | + |
| 66 | + - name: Add env vars |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + echo "V=1" >> $GITHUB_ENV |
| 70 | +
|
| 71 | + if [ "${{ matrix.target }}" = "x86" ]; then |
| 72 | + echo "TARGET=ia32" >> $GITHUB_ENV |
| 73 | + else |
| 74 | + echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Add Linux env vars |
| 78 | + if: contains(matrix.os, 'ubuntu') |
| 79 | + run: | |
| 80 | + echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV |
| 81 | + echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV |
| 82 | +
|
| 83 | + - name: Configure build |
| 84 | + run: yarn node-pre-gyp configure --target_arch=${{ env.TARGET }} |
| 85 | + |
| 86 | + - name: Build binaries |
| 87 | + run: yarn node-pre-gyp build --target_arch=${{ env.TARGET }} |
| 88 | + |
| 89 | + - name: Print binary info |
| 90 | + if: contains(matrix.os, 'ubuntu') |
| 91 | + run: | |
| 92 | + ldd lib/binding/*/node_sqlite3.node |
| 93 | + echo "---" |
| 94 | + nm lib/binding/*/node_sqlite3.node | grep "GLIBC_" | c++filt || true |
| 95 | + echo "---" |
| 96 | + file lib/binding/napi-v*/* |
| 97 | +
|
| 98 | + - name: Run tests |
| 99 | + run: yarn test |
| 100 | + |
| 101 | + - name: Package prebuilt binaries |
| 102 | + run: yarn node-pre-gyp package --target_arch=${{ env.TARGET }} |
| 103 | + |
| 104 | + - name: Upload binaries to commit artifacts |
| 105 | + uses: actions/upload-artifact@v3 |
| 106 | + if: matrix.node == 16 |
| 107 | + with: |
| 108 | + name: prebuilt-binaries |
| 109 | + path: build/stage/*/* |
| 110 | + retention-days: 7 |
| 111 | + |
| 112 | + - name: Upload binaries to GitHub Release |
| 113 | + run: yarn node-pre-gyp-github publish |
| 114 | + if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/') |
| 115 | + env: |
| 116 | + NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }} |
| 117 | + build-qemu: |
| 118 | + runs-on: ubuntu-latest |
| 119 | + if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') |
| 120 | + strategy: |
| 121 | + fail-fast: false |
| 122 | + matrix: |
| 123 | + node: |
| 124 | + - 16 |
| 125 | + target: |
| 126 | + - linux/arm64 |
| 127 | + variant: |
| 128 | + - bullseye |
| 129 | + - alpine3.15 |
| 130 | + include: |
| 131 | + # musl x64 builds |
| 132 | + - target: linux/amd64 |
| 133 | + variant: alpine3.15 |
| 134 | + node: 16 |
| 135 | + name: ${{ matrix.variant }} (node=${{ matrix.node }}, target=${{ matrix.target }}) |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v3 |
| 138 | + |
| 139 | + - name: Set up QEMU |
| 140 | + uses: docker/setup-qemu-action@v2 |
| 141 | + |
| 142 | + - name: Setup Docker Buildx |
| 143 | + uses: docker/setup-buildx-action@v2 |
| 144 | + |
| 145 | + - name: Build binaries and test |
| 146 | + run: | |
| 147 | + docker buildx build \ |
| 148 | + --file ./tools/BinaryBuilder.Dockerfile \ |
| 149 | + --load \ |
| 150 | + --tag sqlite-builder \ |
| 151 | + --platform ${{ matrix.target }} \ |
| 152 | + --no-cache \ |
| 153 | + --build-arg VARIANT=${{ matrix.variant }} \ |
| 154 | + --build-arg NODE_VERSION=${{ matrix.node }} \ |
| 155 | + . |
| 156 | + CONTAINER_ID=$(docker create -it sqlite-builder) |
| 157 | + docker cp $CONTAINER_ID:/usr/src/build/build/ ./build |
| 158 | +
|
| 159 | + - name: Upload binaries to commit artifacts |
| 160 | + uses: actions/upload-artifact@v3 |
| 161 | + if: matrix.node == 16 |
| 162 | + with: |
| 163 | + name: prebuilt-binaries |
| 164 | + path: build/stage/*/* |
| 165 | + retention-days: 7 |
| 166 | + |
| 167 | + - name: Upload binaries to GitHub Release |
| 168 | + run: yarn install --ignore-scripts && yarn node-pre-gyp-github publish |
| 169 | + if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/') |
| 170 | + env: |
| 171 | + NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }} |
0 commit comments