diff --git a/.github/workflows/install-shared-dependencies/action.yml b/.github/workflows/install-shared-dependencies/action.yml index 66dde73a34..982f0d7f77 100644 --- a/.github/workflows/install-shared-dependencies/action.yml +++ b/.github/workflows/install-shared-dependencies/action.yml @@ -16,7 +16,9 @@ inputs: defalt: "x86_64-unknown-linux-gnu" options: - x86_64-unknown-linux-gnu + - x86_64-unknown-linux-musl - aarch64-unknown-linux-gnu + - aarch64-unknown-linux-musl - x86_64-apple-darwin - aarch64-apple-darwin github-token: @@ -35,13 +37,22 @@ runs: brew upgrade || true brew install git gcc pkgconfig openssl redis coreutils - - name: Install software dependencies for Ubuntu + - name: Install software dependencies for Ubuntu GNU shell: bash - if: "${{ inputs.os == 'ubuntu' }}" + if: "${{ inputs.os == 'ubuntu' && (inputs.target == 'x86_64-unknown-linux-gnu' || inputs.target == 'aarch64-unknown-linux-gnu')}}" run: | sudo apt update -y sudo apt install -y git gcc pkg-config openssl libssl-dev + - name: Install software dependencies for Ubuntu MUSL + shell: bash + if: "${{ inputs.os == 'ubuntu' && (inputs.target == 'x86_64-unknown-linux-musl' || inputs.target == 'aarch64-unknown-linux-musl')}}" + run: | + apk update + wget -O - https://sh.rustup.rs | sh -s -- -y + source "$HOME/.cargo/env" + apk add protobuf-dev musl-dev make gcc redis + - name: Install software dependencies for Amazon-Linux shell: bash if: "${{ inputs.os == 'amazon-linux' }}" @@ -49,11 +60,13 @@ runs: yum install -y gcc pkgconfig openssl openssl-devel which curl redis6 gettext --allowerasing - name: Install Rust toolchain + if: "${{ inputs.target != 'x86_64-unknown-linux-musl' && inputs.target != 'aarch64-unknown-linux-musl'}}" uses: dtolnay/rust-toolchain@stable with: targets: ${{ inputs.target }} - name: Install protoc (protobuf) + if: "${{ inputs.target != 'x86_64-unknown-linux-musl' && inputs.target != 'aarch64-unknown-linux-musl'}}" uses: arduino/setup-protoc@v3 with: version: "25.1" diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index be56f3a23d..15a8981a6b 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -178,3 +178,52 @@ jobs: - name: Test compatibility run: npm test -- -t "set and get flow works" working-directory: ./node + start-self-hosted-runner: + if: github.repository_owner == 'aws' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Start self hosted EC2 runner + uses: ./.github/workflows/start-self-hosted-runner + with: + aws-access-key-id: ${{ secrets.AWS_EC2_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_EC2_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }} + + set-up-self-hosted-runner-access: + if: github.repository_owner == 'aws' + runs-on: self-hosted + steps: + - name: Setup self-hosted runner access + run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/glide-for-redis + + build-linux-musl-latest: + needs: [start-self-hosted-runner, set-up-self-hosted-runner-access] + runs-on: [self-hosted, Linux, ARM64] + timeout-minutes: 15 + + steps: + - name: install git + run: sudo apt-get install git + + - name: Checkout submodules + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git submodule update --init --recursive + + - name: run docker alpine image + uses: ./.github/workflows/run-alpine-image + + - name: Build Node wrapper + uses: ./.github/workflows/build-node-wrapper + with: + os: "ubuntu" + named_os: "linux" + target: "aarch64-unknown-linux-musl" + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Test compatibility + run: npm test -- -t "set and get flow works" + working-directory: ./node diff --git a/.github/workflows/npm-cd.yml b/.github/workflows/npm-cd.yml index e6a098ff66..d8a9c03bcd 100644 --- a/.github/workflows/npm-cd.yml +++ b/.github/workflows/npm-cd.yml @@ -47,6 +47,13 @@ jobs: ARCH: x64, TARGET: x86_64-unknown-linux-gnu, } + - { + OS: ubuntu, + NAMED_OS: linux, + RUNNER: ubuntu-latest, + ARCH: x64, + TARGET: x86_64-unknown-linux-musl, + } - { OS: ubuntu, NAMED_OS: linux, @@ -55,6 +62,14 @@ jobs: TARGET: aarch64-unknown-linux-gnu, CONTAINER: "2_28", } + - { + OS: ubuntu, + NAMED_OS: linux, + RUNNER: [self-hosted, Linux, ARM64], + ARCH: arm64, + TARGET: aarch64-unknown-linux-musl, + CONTAINER: "2_28", + } - { OS: macos, NAMED_OS: darwin, @@ -79,6 +94,10 @@ jobs: with: submodules: "true" + - name: run docker alpine image + if: ${{ contains(matrix.build.TARGET, 'musl') }} + uses: ./.github/workflows/run-alpine-image + - name: Set the release version shell: bash run: | diff --git a/.github/workflows/run-alpine-image/action.yml b/.github/workflows/run-alpine-image/action.yml new file mode 100644 index 0000000000..5a6372ea7f --- /dev/null +++ b/.github/workflows/run-alpine-image/action.yml @@ -0,0 +1,15 @@ +name: Run node alpine image + + +runs: + using: 'docker' + image: 'node:alpine' + using: "composite" + steps: + - name: Install git + run: apk add git + + - name: Checkout submodules + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git submodule update --init --recursive diff --git a/node/npm/glide/index.ts b/node/npm/glide/index.ts index 4891f8d224..3f5fd1c597 100644 --- a/node/npm/glide/index.ts +++ b/node/npm/glide/index.ts @@ -4,6 +4,7 @@ * Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ +import { GLIBC, MUSL, familySync } from "detect-libc"; import { arch, platform } from "process"; let globalObject = global as unknown; @@ -14,10 +15,30 @@ function loadNativeBinding() { case "linux": switch (arch) { case "x64": - nativeBinding = require("@scope/glide-for-redis-linux-x64"); + switch (familySync()) { + case GLIBC: + nativeBinding = require("@scope/glide-for-redis-linux-x64"); + break; + case MUSL: + nativeBinding = require("@scope/glide-for-redis-linux-musl-x64"); + break; + default: + nativeBinding = require("@scope/glide-for-redis-linux-x64"); + break; + } break; case "arm64": - nativeBinding = require("@scope/glide-for-redis-linux-arm64"); + switch (familySync()) { + case GLIBC: + nativeBinding = require("@scope/glide-for-redis-linux-arm64"); + break; + case MUSL: + nativeBinding = require("@scope/glide-for-redis-linux-musl-arm64"); + break; + default: + nativeBinding = require("@scope/glide-for-redis-linux-arm64"); + break; + } break; default: throw new Error( diff --git a/node/npm/glide/package.json b/node/npm/glide/package.json index b6ded308e1..d83fd12e09 100644 --- a/node/npm/glide/package.json +++ b/node/npm/glide/package.json @@ -43,7 +43,9 @@ "${scope}glide-for-redis-darwin-arm64": "${package_version}", "${scope}glide-for-redis-darwin-x64": "${package_version}", "${scope}glide-for-redis-linux-arm64": "${package_version}", - "${scope}glide-for-redis-linux-x64": "${package_version}" + "${scope}glide-for-redis-linux-x64": "${package_version}", + "${scope}glide-for-redis-linux-musl-arm64": "${package_version}", + "@scope/glide-for-redis-linux-musl-x64": "${package_version}" }, "eslintConfig": { "extends": [ @@ -58,5 +60,8 @@ "build-ts/*" ], "root": true + }, + "dependencies": { + "detect-libc": "^2.0.3" } }