Skip to content

Commit

Permalink
Adding support for node:alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
avifenesh committed May 3, 2024
1 parent de07b3e commit b0f95ae
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 5 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/install-shared-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -35,25 +37,36 @@ 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' }}"
run: |
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"
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions .github/workflows/npm-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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: |
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/run-alpine-image/action.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 23 additions & 2 deletions node/npm/glide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down
7 changes: 6 additions & 1 deletion node/npm/glide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -58,5 +60,8 @@
"build-ts/*"
],
"root": true
},
"dependencies": {
"detect-libc": "^2.0.3"
}
}

0 comments on commit b0f95ae

Please sign in to comment.