From b9a3931da48f550197db6df930f4be728b9a89db Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Fri, 23 Sep 2022 19:31:08 -0400 Subject: [PATCH] Improved node release workflow with arm support --- .github/workflows/node-ci.yml | 34 ++++++----- .github/workflows/node-release.yml | 95 +++++++++++++++++++----------- package-lock.json | 72 +++++++++++----------- package.json | 2 +- platform/node/scripts/publish.sh | 10 +++- 5 files changed, 124 insertions(+), 89 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 6fe1af267..c936a25f6 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -73,14 +73,17 @@ concurrency: jobs: test: + runs-on: ${{ matrix.runs-on }} strategy: + fail-fast: false matrix: - os: - - macos-12 - - ubuntu-20.04 - node: [ 14, 16, 18 ] - name: OS ${{ matrix.os }} Node ${{ matrix.node }} - runs-on: ${{ matrix.os }} + include: + - runs-on: ubuntu-20.04 + arch: x86_64 + - runs-on: macos-12 + arch: x86_64 + - runs-on: macos-12-arm + arch: arm64 continue-on-error: true env: BUILDTYPE: ${{github.ref == 'refs/heads/main' && 'Release' || 'Debug'}} @@ -96,7 +99,15 @@ jobs: submodules: recursive fetch-depth: 0 - - name: Install dependencies + - name: Get OS Architecture + run: uname -m + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install dependencies macOS if: runner.os == 'macOS' env: HOMEBREW_NO_AUTO_UPDATE: 1 @@ -109,7 +120,7 @@ jobs: brew list glfw || brew install glfw brew list libuv || brew install libuv - - name: Install dependencies + - name: Install dependencies Linux if: runner.os == 'Linux' env: DEBIAN_FRONTEND: noninteractive @@ -128,11 +139,6 @@ jobs: libc++-9-dev \ libc++abi-9-dev /usr/sbin/update-ccache-symlinks - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - name: npm ci run: npm ci --ignore-scripts @@ -159,7 +165,7 @@ jobs: ccache --show-stats --set-config cache_dir=~/.ccache - name: CMake - if: runner.os == 'macOS' + if: runner.os == 'MacOS' run: | cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} -DMBGL_WITH_COVERAGE=ON diff --git a/.github/workflows/node-release.yml b/.github/workflows/node-release.yml index 37885fc93..5ae7af498 100644 --- a/.github/workflows/node-release.yml +++ b/.github/workflows/node-release.yml @@ -42,14 +42,17 @@ jobs: git push build: + runs-on: ${{ matrix.runs-on }} strategy: + fail-fast: false matrix: - os: - - macos-12 - - ubuntu-20.04 - node: [ 14, 16, 18 ] - name: OS ${{ matrix.os }} Node ${{ matrix.node }} - runs-on: ${{ matrix.os }} + include: + - runs-on: ubuntu-20.04 + arch: x86_64 + - runs-on: macos-12 + arch: x86_64 + - runs-on: macos-12-arm + arch: arm64 needs: bump_version continue-on-error: true env: @@ -69,7 +72,15 @@ jobs: - name: Get Latest Version run: git pull - - name: Install dependencies + - name: Get OS Architecture + run: uname -m + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install dependencies macOS if: runner.os == 'macOS' env: HOMEBREW_NO_AUTO_UPDATE: 1 @@ -79,10 +90,10 @@ jobs: brew list ccache || brew install ccache brew list ninja || brew install ninja brew list pkg-config || brew install pkg-config - brew list glfw3 || brew install glfw3 + brew list glfw || brew install glfw brew list libuv || brew install libuv - - name: Install dependencies + - name: Install dependencies Linux if: runner.os == 'Linux' env: DEBIAN_FRONTEND: noninteractive @@ -101,11 +112,6 @@ jobs: libc++-9-dev \ libc++abi-9-dev /usr/sbin/update-ccache-symlinks - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - name: npm ci run: npm ci --ignore-scripts @@ -114,7 +120,7 @@ jobs: run: ccache --clear --set-config cache_dir=~/.ccache - name: Cache ccache - uses: actions/cache@v2 + uses: actions/cache@v3 env: cache-name: ccache-v1 with: @@ -132,11 +138,9 @@ jobs: ccache --show-stats --set-config cache_dir=~/.ccache - name: CMake - if: runner.os == 'macOS' + if: runner.os == 'MacOS' run: | cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} -DMBGL_WITH_COVERAGE=ON - sed -i -e 's/$(ARCHS_STANDARD)/x86_64/g' build/build.ninja - sed -i -e 's/-arch arm64e/-arch x86_64/g' build/build.ninja - name: CMake if: runner.os == 'Linux' @@ -147,26 +151,48 @@ jobs: run: | cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null) - - name: Test - if: runner.os == 'Linux' - run: xvfb-run --auto-servernum npm test + #- name: Run render tests on macOS + # if: runner.os == 'macOS' + # run: ./build/mbgl-render-test-runner --manifestPath metrics/macos-xcode11-release-style.json - - name: Test - if: runner.os == 'macOS' - run: npm test + #- name: Upload render test artifacts + # uses: actions/upload-artifact@v3 + # if: always() + # with: + # name: render-query-test-results + # path: metrics/macos-xcode11-release-style.html - - name: Pack - if: github.ref != 'refs/heads/main' - run: | - npm pack --dry-run + #- name: Test + # if: runner.os == 'Linux' + # run: xvfb-run --auto-servernum npm test - - name: Publish Release to Github - if: github.ref == 'refs/heads/main' - run: | - npm run package - npm run release + #- name: Test + # if: runner.os == 'macOS' && matrix.arch != 'arm64' + # run: npm test + + # On PRs make sure that the npm package can be packaged. + #- name: Pack + # if: github.ref != 'refs/heads/main' + # run: | + # npm pack --dry-run + + - name: Publish X64 Release to Github + if: github.ref == 'refs/heads/main' && matrix.arch == 'x86_64' env: + PUBLISH: true + BUILDTYPE: RelWithDebInfo NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.NODE_PRE_GYP_GITHUB_TOKEN }} + run: | + ./platform/node/scripts/publish.sh + + - name: Publish ARM Release to Github + if: github.ref == 'refs/heads/main' && matrix.arch == 'arm64' + env: + PUBLISH: true + BUILDTYPE: RelWithDebInfo + NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.NODE_PRE_GYP_GITHUB_TOKEN }} + run: | + ./platform/node/scripts/publish.sh --target_arch=arm64 - name: Publish to NPM (release) if: matrix.os == 'ubuntu-20.04' && matrix.node == '18' && github.ref == 'refs/heads/main' && github.event.inputs.version != 'prerelease' @@ -182,5 +208,4 @@ jobs: npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} npm publish --tag next --access public env: - NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }} - + NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f5cd1c4e6..e4f1cb07d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,9 @@ "hasInstallScript": true, "license": "BSD-2-Clause", "dependencies": { + "@acalcutt/node-pre-gyp": "^1.0.10", "@acalcutt/node-pre-gyp-github": "1.4.8", "@mapbox/cmake-node-module": "^1.2.0", - "@mapbox/node-pre-gyp": "^1.0.10", "minimatch": "^5.1.0", "npm-run-all": "^4.0.2" }, @@ -47,6 +47,25 @@ "node": ">=6" } }, + "node_modules/@acalcutt/node-pre-gyp": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@acalcutt/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", + "integrity": "sha512-vA48avL6+DaEznRusKKSgzNKp/2+KhG1UHwGU8ALUUpcV+L+WZzzUgRdpF5dP9Mb4k5/B0cJIxUYIlvqoPE4rQ==", + "dependencies": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + } + }, "node_modules/@acalcutt/node-pre-gyp-github": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/@acalcutt/node-pre-gyp-github/-/node-pre-gyp-github-1.4.8.tgz", @@ -166,25 +185,6 @@ "protocol-buffers-schema": "^3.3.2" } }, - "node_modules/@mapbox/node-pre-gyp": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", - "integrity": "sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==", - "dependencies": { - "detect-libc": "^2.0.0", - "https-proxy-agent": "^5.0.0", - "make-dir": "^3.1.0", - "node-fetch": "^2.6.7", - "nopt": "^5.0.0", - "npmlog": "^5.0.1", - "rimraf": "^3.0.2", - "semver": "^7.3.5", - "tar": "^6.1.11" - }, - "bin": { - "node-pre-gyp": "bin/node-pre-gyp" - } - }, "node_modules/@mapbox/point-geometry": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz", @@ -4212,6 +4212,22 @@ } }, "dependencies": { + "@acalcutt/node-pre-gyp": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@acalcutt/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", + "integrity": "sha512-vA48avL6+DaEznRusKKSgzNKp/2+KhG1UHwGU8ALUUpcV+L+WZzzUgRdpF5dP9Mb4k5/B0cJIxUYIlvqoPE4rQ==", + "requires": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + } + }, "@acalcutt/node-pre-gyp-github": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/@acalcutt/node-pre-gyp-github/-/node-pre-gyp-github-1.4.8.tgz", @@ -4311,22 +4327,6 @@ "protocol-buffers-schema": "^3.3.2" } }, - "@mapbox/node-pre-gyp": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", - "integrity": "sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==", - "requires": { - "detect-libc": "^2.0.0", - "https-proxy-agent": "^5.0.0", - "make-dir": "^3.1.0", - "node-fetch": "^2.6.7", - "nopt": "^5.0.0", - "npmlog": "^5.0.1", - "rimraf": "^3.0.2", - "semver": "^7.3.5", - "tar": "^6.1.11" - } - }, "@mapbox/point-geometry": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz", diff --git a/package.json b/package.json index 0ef66dc19..7026483f8 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "license": "BSD-2-Clause", "dependencies": { "@mapbox/cmake-node-module": "^1.2.0", - "@mapbox/node-pre-gyp": "^1.0.10", + "@acalcutt/node-pre-gyp": "^1.0.10", "@acalcutt/node-pre-gyp-github": "1.4.8", "minimatch": "^5.1.0", "npm-run-all": "^4.0.2" diff --git a/platform/node/scripts/publish.sh b/platform/node/scripts/publish.sh index 20cf5ae62..79f2eb042 100755 --- a/platform/node/scripts/publish.sh +++ b/platform/node/scripts/publish.sh @@ -9,11 +9,15 @@ if [[ "${CIRCLE_TAG}" == "node-v${PACKAGE_JSON_VERSION}" ]] || [[ "${PUBLISH:-}" # Changes to the version targets here should happen in tandem with updates to the # EXCLUDE_NODE_ABIS property in cmake/node.cmake and the "node" engines property in # package.json. - for TARGET in 6.0.0 8.0.0 10.0.0; do + for TARGET in 14.0.0 16.0.0 18.0.0; do + rm -rf build/stage + if [[ "${BUILDTYPE}" == "RelWithDebInfo" ]]; then - ./node_modules/.bin/node-pre-gyp package publish info --target="${TARGET}" + ./node_modules/.bin/node-pre-gyp package --target="${TARGET}" $@ + ./node_modules/.bin/node-pre-gyp-github publish --release elif [[ "${BUILDTYPE}" == "Debug" ]]; then - ./node_modules/.bin/node-pre-gyp package publish info --target="${TARGET}" --debug + ./node_modules/.bin/node-pre-gyp package --target="${TARGET}" --debug $@ + ./node_modules/.bin/node-pre-gyp-github publish --release else echo "error: must provide either Debug or RelWithDebInfo for BUILDTYPE" exit 1