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 8, 2024
1 parent de07b3e commit 7af9112
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-node-wrapper/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ runs:
named_os: ${{ inputs.named_os }}
arch: ${{ inputs.arch }}
npm_scope: ${{ inputs.npm_scope }}
target: ${{ inputs.target }}

- name: npm install
shell: bash
working-directory: ./node
run: |
rm -rf node_modules && npm install --frozen-lockfile
cd rust-client
npm install
npm install --frozen-lockfile
- name: Build
shell: bash
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/install-rust-and-protoc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Install Rust tool chain and protoc

inputs:
target:
description: "Specified target for rust toolchain, ex. x86_64-apple-darwin"
type: string
required: false
defalt: "x86_64-unknown-linux-gnu"
options:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl


runs:
using: "composite"
steps:
- 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"
repo-token: ${{ inputs.github-token }}
30 changes: 19 additions & 11 deletions .github/workflows/install-shared-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ inputs:
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl
github-token:
description: "GITHUB_TOKEN, GitHub App installation access token"
required: true
type: string



runs:
using: "composite"
steps:
Expand All @@ -35,26 +39,30 @@ 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-musl' && inputs.target != 'aarch64-unknown-linux-musl'}}"
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.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
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ inputs.target }}

- name: Install protoc (protobuf)
uses: arduino/setup-protoc@v3
- name: Install Rust toolchain and protoc
if: "${{ inputs.target != 'x86_64-unknown-linux-musl' && inputs.target != 'aarch64-unknown-linux-musl' }}"
uses: ./.github/workflows/install-rust-and-protoc
with:
version: "25.1"
repo-token: ${{ inputs.github-token }}
target: ${{ inputs.target }}
8 changes: 7 additions & 1 deletion .github/workflows/node-create-package-file/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ inputs:
required: false
type: string
default: "@aws"
target:
description: "Specified target for rust toolchain, ex. x86_64-apple-darwin"
type: string
required: true

runs:
using: "composite"
Expand All @@ -42,6 +46,8 @@ runs:
shell: bash
working-directory: ./node
run: |
# echo -musl if inputs.target is musl
export MUSL_FLAG=`if [[ "${{ inputs.target }}" =~ .*"musl".* ]]; then echo "-musl"; fi`
# set the package name
name="glide-for-redis"
# derive the OS and architecture from the inputs
Expand All @@ -50,7 +56,7 @@ runs:
# set the version
export package_version="${{ inputs.release_version }}"
# set the package name
export pkg_name="${name}-${node_os}-${node_arch}"
export pkg_name="${name}-${node_os}-${node_arch}${MUSL_FLAG}"
# set the scope
export scope=`if [ "${{ inputs.npm_scope }}" != '' ]; then echo "${{ inputs.npm_scope }}/"; fi`
# set the registry scope
Expand Down
81 changes: 80 additions & 1 deletion .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,83 @@ jobs:
- name: Test compatibility
run: npm test -- -t "set and get flow works"
working-directory: ./node
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-gitconfig-for-cotntainer:
if: github.repository_owner == 'aws'
needs: start-self-hosted-runner
runs-on: [self-hosted, Linux, ARM64]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup self-hosted runner access
run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/glide-for-redis

- name: Set up Git config for build-linux-musl-latest
run: |
mkdir -p $HOME/musl-test-workspace
cp $GITHUB_WORKSPACE/* $HOME/musl-test-workspace
env:
GITHUB_WORKSPACE: ${{ github.workspace }}

build-linux-musl-latest:
needs: set-up-gitconfig-for-cotntainer
if: github.repository_owner == 'aws'
name: Build and test Node wrapper on Linux musl
runs-on: [self-hosted, Linux, ARM64]
container:
image: node:alpine
options: --user root

strategy:
fail-fast: false
timeout-minutes: 15
steps:

- name: Install dependencies
run: |
apk update
apk add bash git envsubst
# Currently it is not possible to use the checkout action with self-hosted runners on alpine so we need to do it manually
- name: Checkout repository
shell: bash
run: |
git config --global safe.directory "$HOME/musl-test-workspace"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Downgrade npm major version to 8
run: |
npm i -g npm@8
- name: Build Node wrapper
uses: ./.github/workflows/build-node-wrapper
with:
os: ubuntu
named_os: linux
arch: arm64
target: aarch64-unknown-linux-musl
github-token: ${{ secrets.GITHUB_TOKEN }}
publish: true

- name: Test compatibility
run: npm test -- -t "set and get flow works"
working-directory: ./node

Loading

0 comments on commit 7af9112

Please sign in to comment.