Skip to content

Commit

Permalink
Add post-install test to make sure installation works on all supporte…
Browse files Browse the repository at this point in the history
…d platforms (#229)

* WIP: tests for debian-based OSes

* Try with quoted OS names

* Add alpine builds

* Update alpine post-install

* Add rhel block

* Add macos block

* Add Windows block

* Remove unix specific line from pipeline

* Add tempFolderPath to env

* Enable install once

* Fix windows error

* Remove AlmaLinux/RockyLinux 9, split Debian block

* Add node 23 to debian older tests

* Address review comments
  • Loading branch information
milindl authored Jan 20, 2025
1 parent 540aa2b commit f5c907b
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 0 deletions.
201 changes: 201 additions & 0 deletions .semaphore/post_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
version: v1.0
name: post-install
agent:
machine:
type: s1-prod-ubuntu22-04-amd64-1

global_job_config:
prologue:
commands:
- checkout

auto_cancel:
running:
when: "branch != 'master'"

execution_time_limit:
hours: 3

queue:
- when: "branch != 'master'"
processing: parallel

blocks:
- name: "Debian-based OS (amd64)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-ubuntu22-04-amd64-1
prologue:
commands:
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
jobs:
- name: "Install"
matrix:
- env_var: DOCKER_IMAGE
values: ["debian:bullseye", "debian:bookworm", "ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04"]
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- docker run -v "$(pwd):/v" "$DOCKER_IMAGE" /v/ci/post-install/install-debian.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "Debian-based OS (arm64)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-ubuntu22-04-arm64-1
prologue:
commands:
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
jobs:
- name: "Install"
matrix:
- env_var: DOCKER_IMAGE
values: ["debian:bullseye", "debian:bookworm", "ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04"]
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- docker run -v "$(pwd):/v" "$DOCKER_IMAGE" /v/ci/post-install/install-debian.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "Alpine-based OS (amd64)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-ubuntu22-04-amd64-1
prologue:
commands:
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
jobs:
- name: "Install"
matrix:
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- docker run -v "$(pwd):/v" "node:${NODE_VERSION}-alpine" /v/ci/post-install/install-alpine.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "Alpine-based OS (arm64)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-ubuntu22-04-arm64-1
prologue:
commands:
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
jobs:
- name: "Install"
matrix:
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- docker run -v "$(pwd):/v" "node:${NODE_VERSION}-alpine" /v/ci/post-install/install-alpine.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "RHEL-based OS (amd64)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-ubuntu22-04-amd64-1
prologue:
commands:
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
jobs:
- name: "Install"
matrix:
- env_var: DOCKER_IMAGE
values: ["quay.io/centos/centos:stream9", "almalinux:9", "rockylinux:9"]
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- docker run -v "$(pwd):/v" "$DOCKER_IMAGE" /v/ci/post-install/install-rhel.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "RHEL-based OS (arm64)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-ubuntu22-04-arm64-1
prologue:
commands:
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
jobs:
- name: "Install"
matrix:
- env_var: DOCKER_IMAGE
values: ["quay.io/centos/centos:stream9", "almalinux:9", "rockylinux:9"]
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- docker run -v "$(pwd):/v" "$DOCKER_IMAGE" /v/ci/post-install/install-rhel.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "Mac (Intel)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-macos-13-5-amd64
jobs:
- name: "Install"
matrix:
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- sem-version node $NODE_VERSION
- bash ci/post-install/install-mac.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "Mac (M1)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-macos-13-5-arm64
jobs:
- name: "Install"
matrix:
- env_var: NODE_VERSION
values: ["18", "20", "21", "22", "23"]
commands:
- sem-version node $NODE_VERSION
- bash ci/post-install/install-mac.sh "$NODE_VERSION" "$LIBRARY_VERSION"

- name: "Windows (x64)"
dependencies: [ ]
task:
agent:
machine:
type: s1-prod-windows
prologue:
commands:
# The semaphore agent already comes with an installed version of node. We, however, need to use a different
# version of node for the release (as many as we need to cover all the different ABIs).
# The node installer does not allow us to downgrade, so we need to uninstall the current version.
# The method below isn't particularly robust (as it depends on the particular format of the URL), but it
# works and can be easily fixed if it breaks (the node --version in the below jobs can be checked if there are
# any issues in the build).
- $env:InstalledMajor = (Get-Command node).Version.Major
- $env:InstalledMinor = (Get-Command node).Version.Minor
- $env:InstalledBuild = (Get-Command node).Version.Build
- $env:InstalledVersion = "v${env:InstalledMajor}.${env:InstalledMinor}.${env:InstalledBuild}"
- echo "https://nodejs.org/dist/${env:InstalledVersion}/node-${env:InstalledVersion}-x64.msi"
- Invoke-WebRequest "https://nodejs.org/dist/${env:InstalledVersion}/node-${env:InstalledVersion}-x64.msi" -OutFile node_old.msi
- msiexec /qn /l* node-old-log.txt /uninstall node_old.msi
- cat .\node-old-log.txt
jobs:
- name: "Install"
matrix:
- env_var: NODE_VERSION
values: ["18.19.0", "20.11.0", "21.6.1", "22.2.0", "23.2.0"]
commands:
- Invoke-WebRequest "https://nodejs.org/download/release/v${env:NODE_VERSION}/node-v${env:NODE_VERSION}-x64.msi" -OutFile node.msi
- msiexec /qn /l* node-log.txt /i node.msi
- cat .\node-log.txt
- node --version
- $env:tempFolderPath = Join-Path $Env:Temp $(New-Guid)
- New-Item -Type Directory -Path ${env:tempFolderPath} | Out-Null
- cd ${env:tempFolderPath}
- npm init -y
- npm install --save @confluentinc/kafka-javascript@${env:LIBRARY_VERSION}
- node -e "console.log(require('@confluentinc/kafka-javascript').librdkafkaVersion);"
17 changes: 17 additions & 0 deletions ci/post-install/_install_ckjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Only for logging purposes
node -v
uname -m

installDir=$(mktemp -d)
cd $installDir
npm init -y

# uncomment for one final run.
library_version="$2"

if [ -z "${library_version}" ]; then
library_version="latest"
fi

npm install @confluentinc/kafka-javascript@${library_version} --save
node -e 'console.log(require("@confluentinc/kafka-javascript").librdkafkaVersion);'
8 changes: 8 additions & 0 deletions ci/post-install/_install_nvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_version="$1"

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

nvm install $node_version
4 changes: 4 additions & 0 deletions ci/post-install/install-alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e

. /v/ci/post-install/_install_ckjs.sh
11 changes: 11 additions & 0 deletions ci/post-install/install-debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

export DEBIAN_FRONTEND=noninteractive
export NEEDRESTART_MODE=a

apt update
apt install -y bash curl

. /v/ci/post-install/_install_nvm.sh
. /v/ci/post-install/_install_ckjs.sh
4 changes: 4 additions & 0 deletions ci/post-install/install-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e

. $(pwd)/ci/post-install/_install_ckjs.sh
9 changes: 9 additions & 0 deletions ci/post-install/install-rhel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e

pwd

dnf install --allowerasing -y bash curl

. /v/ci/post-install/_install_nvm.sh
. /v/ci/post-install/_install_ckjs.sh
10 changes: 10 additions & 0 deletions service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ codeowners:
enable: true
semaphore:
enable: true
tasks:
- name: post-install
scheduled: false
branch: "master"
pipeline_file: .semaphore/post_install.yml
parameters:
- name: LIBRARY_VERSION
required: true
description: "Which library version to install."
default_value: "latest"
sonarqube:
enable: true
coverage_reports:
Expand Down

0 comments on commit f5c907b

Please sign in to comment.