From 302bcfea1483e93e918f350b514ad69384fb1c02 Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Thu, 16 Feb 2023 22:32:31 -0500 Subject: [PATCH] Update node (ubuntu-20.04, arm64) docker build workflow (#804) --- .github/workflows/node-ci.yml | 32 +++++++++++++++---- .github/workflows/node-release.yml | 26 +++++++++++---- platform/node/scripts/Dockerfile_Build | 6 ++-- .../node/scripts/docker_build_entrypoint.sh | 7 ++-- 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 74acfdb8a..6f26a91d2 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -130,11 +130,11 @@ jobs: cache-name: ccache-v1 with: path: ~/.ccache - key: ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} + key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} restore-keys: | - ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} - ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }} - ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }} + ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} + ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }} + ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }} - name: Clear ccache statistics run: | @@ -182,8 +182,10 @@ jobs: npm pack --dry-run test_linux_arm: - runs-on: macos-12-arm + runs-on: ubuntu-latest name: test (ubuntu-20.04, arm64) + env: + DOCKERTAG: node-test-${{ github.run_id }}-${{ github.run_attempt }} steps: - name: Checkout uses: actions/checkout@v3 @@ -191,6 +193,12 @@ jobs: submodules: recursive fetch-depth: 0 + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v2 + with: + platforms: 'arm64' + - name: Install dependencies macOS if: runner.os == 'macOS' env: @@ -208,9 +216,19 @@ jobs: context: . platforms: linux/arm64 file: platform/node/scripts/Dockerfile_Build - tags: build + tags: ${{ env.DOCKERTAG }} push: false load: true - name: Run the docker build image and create node libs - run: docker run --rm -v $(pwd):/data build + run: docker run --rm -v $(pwd):/data ${{ env.DOCKERTAG }} + + - name: Clean up the docker build image + if: always() + run: docker rmi $(docker images | grep ${{ env.DOCKERTAG }} | tr -s ' ' | cut -d ' ' -f 3) --force + + # On PRs make sure that the npm package can be packaged. + - name: Pack + if: github.ref != 'refs/heads/main' + run: | + npm pack --dry-run diff --git a/.github/workflows/node-release.yml b/.github/workflows/node-release.yml index b5da78a41..85a5872fd 100644 --- a/.github/workflows/node-release.yml +++ b/.github/workflows/node-release.yml @@ -131,11 +131,11 @@ jobs: cache-name: ccache-v1 with: path: ~/.ccache - key: ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} + key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} restore-keys: | - ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} - ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }} - ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }} + ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} + ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }} + ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }} - name: Clear ccache statistics run: | @@ -239,9 +239,11 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }} publish_binary_linux_arm64: - runs-on: macos-12-arm + runs-on: ubuntu-latest needs: bump_version name: publish_binary (ubuntu-20.04, arm64) + env: + DOCKERTAG: node-build-${{ github.run_id }}-${{ github.run_attempt }} steps: - name: Checkout uses: actions/checkout@v3 @@ -252,6 +254,12 @@ jobs: - name: Get Latest Version run: git pull + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v2 + with: + platforms: 'arm64' + - name: Install dependencies macOS if: runner.os == 'macOS' env: @@ -269,12 +277,16 @@ jobs: context: . platforms: linux/arm64 file: platform/node/scripts/Dockerfile_Build - tags: build + tags: ${{ env.DOCKERTAG }} push: false load: true - name: Run the docker build image and create node libs - run: docker run --rm -v $(pwd):/data build + run: docker run --rm -v $(pwd):/data ${{ env.DOCKERTAG }} + + - name: Clean up the docker build image + if: always() + run: docker rmi $(docker images | grep ${{ env.DOCKERTAG }} | tr -s ' ' | cut -d ' ' -f 3) --force - name: Setup node uses: actions/setup-node@v3 diff --git a/platform/node/scripts/Dockerfile_Build b/platform/node/scripts/Dockerfile_Build index fe02f48e8..f6433cb6d 100644 --- a/platform/node/scripts/Dockerfile_Build +++ b/platform/node/scripts/Dockerfile_Build @@ -27,6 +27,6 @@ RUN set -ex; \ VOLUME /data RUN mkdir -p /usr/src/app -COPY / /usr/src/app -ENTRYPOINT ["/usr/src/app/platform/node/scripts/docker_build_entrypoint.sh"] -RUN ["chmod", "+x", "/usr/src/app/platform/node/scripts/docker_build_entrypoint.sh"] \ No newline at end of file +COPY /platform/node/scripts/docker_build_entrypoint.sh /usr/src/app/docker_build_entrypoint.sh +ENTRYPOINT ["/usr/src/app/docker_build_entrypoint.sh"] +RUN ["chmod", "+x", "/usr/src/app/docker_build_entrypoint.sh"] \ No newline at end of file diff --git a/platform/node/scripts/docker_build_entrypoint.sh b/platform/node/scripts/docker_build_entrypoint.sh index 580ecbbe6..2c9e930c0 100644 --- a/platform/node/scripts/docker_build_entrypoint.sh +++ b/platform/node/scripts/docker_build_entrypoint.sh @@ -4,12 +4,13 @@ node -v cat /etc/os-release uname -m -cd /usr/src/app +#build lib files +cd /data/ npm ci --ignore-scripts ccache --clear --set-config cache_dir=~/.ccache cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null) -cp -R ./lib/ /data/lib/ -xvfb-run --auto-servernum ./build/mbgl-render-test-runner --manifestPath metrics/macos-xcode11-release-style.json +#Test +xvfb-run --auto-servernum ./build/mbgl-render-test-runner --manifestPath metrics/linux-gcc8-release-style.json xvfb-run --auto-servernum npm test \ No newline at end of file