Skip to content

Commit

Permalink
CI: add prebuilds (#385)
Browse files Browse the repository at this point in the history
* native runtime info collection

* metrics sending

* add tests

* lint

* fix: cumulative counters

* add deps for node-gyp

* actually call apk add

* apk sudo

* apk add as the correct user

* apk add python3

* add binding.gyp to docker image

* test: spin with hrtime

* test: debug output

* test: format eventloop test message

* test: copy native module to the correct path

* fix: native builds for packaging

* test: fix getSignalFxClient

* fix: lint

* test: separate e2e Dockerfiles

* test: run compilation on windows

* fix: set metrics disabled by default

* doc: add docs

* Change files

* test: remove event loop collection flakiness

* test: add a small timeout to native counters test to ensure a poll step
happens between and counters are updated

* docs: improve advanced-config wording

* docs: mention future changes

* refactor: add missing newlines, remove the need for a loop

* add prebuild os script

* linux prebuild jobs

* add build stage

* linux: specific prebuild versions

* disable scripts in before_script

* disable caching

* prebuild node >= 14 on the proper image

* debug prebuilds dir

* tgz as artifact

* macos runner

* windows build

* linux prebuilds in gh actions

* fix yaml typo

* debug

* create-package job

* upload the final npm package as an artifact

* fix set-output

* fix tgz upload path

* windows, macos prebuilds

* fix prebuild-os without any target args

* use node14 on win, macos

* fix needs

* use c++14 on macos

* run unit tests on macos

* fix typo

* rename linux prebuilds

* use node 8.17 for unit tests

* don't run on node 8

* remove codecov from tests setup

* artifact fetch attempt 1

* fetch-release-artifact script

* fix fetch-release-artifact invocation

* install deps before ghfetch

* debug artifact

* wait for artifacts

* increase timeout for waiting

* use public artifacts token

* prepare release dir

* add artifact prepare debug message

* add run conclusion debug message on failure

* remove unnecessary Dockerfile

* add node 17 to prebuild matrix

* attempt node 17

* attempt 17 on node 16

* node 17

* upgrade prebuildify, attempt node 17 builds

* only build 17 on node 14

* run unit tests for node 17

* remove test-release stage from gitlab

* strip release binaries

* refactor

* remove release-test
  • Loading branch information
seemk authored Nov 11, 2021
1 parent 668ffd8 commit a2d5b94
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 81 deletions.
94 changes: 90 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,102 @@ on:
permissions: read-all

jobs:
prebuilds-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- container: node:10.13.0
versions: '8.5.0 9.0.0 10.0.0 11.0.0 12.0.0 13.0.0'
label: node10
- container: node:14.0.0
versions: '14.0.0 15.0.0 16.0.0 17.0.1'
label: node14
container: ${{ matrix.container }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Install npm dependencies
run: npm ci
- name: Prebuild
run: npm run prebuild:os ${{ matrix.versions }}
- name: Run tests
run: npm run test
- name: upload prebuilds
uses: actions/upload-artifact@v2
with:
name: prebuilds-linux-${{ matrix.label }}
path: prebuilds

prebuilds:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
label: windows
- os: macos-10.15
label: macos
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install npm dependencies
run: npm ci
- name: Prebuild
run: npm run prebuild:os
- name: Run tests
run: npm run test
- name: upload prebuilds
uses: actions/upload-artifact@v2
with:
name: prebuilds-${{ matrix.label }}
path: prebuilds

create-package:
needs: [prebuilds-linux, prebuilds]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: download prebuilds
uses: actions/download-artifact@v2
- name: copy prebuilds
run: |
mkdir -p prebuilds
cp -r prebuilds-linux-node10/* prebuilds
cp -r prebuilds-linux-node14/* prebuilds
cp -r prebuilds-windows/* prebuilds
cp -r prebuilds-macos/* prebuilds
- name: Install npm dependencies
run: npm ci
- name: Build
run: npm run compile
- name: Pack
id: pack
run: |
echo "::set-output name=package_file::$(npm pack)"
- name: Upload package
uses: actions/upload-artifact@v2
with:
name: ${{ steps.pack.outputs.package_file }}
path: ${{ steps.pack.outputs.package_file }}

unit-tests:
needs: [prebuilds-linux, prebuilds]
runs-on: ${{ matrix.os }}
permissions: read-all
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
nodejs: ['10', '12', '14', '16']
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
nodejs: ['10', '12', '14', '16', '17']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -25,8 +113,6 @@ jobs:
run: npm ci
- name: Test
run: npm run test
- name: Report coverage
run: npm run codecov

lint:
if: ${{ github.event_name == 'pull_request' }}
Expand Down
41 changes: 1 addition & 40 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
default:
image: 'cimg/node:lts'

cache:
key:
files:
- package-lock.json
paths:
- .npm/
- node_modules/

# tell npm to store cache in .npm so it can be cached by Gitlab
before_script:
- npm ci --cache .npm --prefer-offline

stages:
- setup
- test
- release

install:
stage: setup
script:
- npm install

test:
script:
- npm test

lint:
script:
- npm run lint
- npm run version:check

build:
artifacts:
paths:
- dist/
script:
- npm run compile
- npm pack

release:
stage: release
artifacts:
Expand All @@ -51,10 +15,7 @@ release:
- branches
script:
- npm install
- npm run compile
- npm pack
- mkdir -p dist
- mv splunk-otel-${CI_COMMIT_REF_NAME:1}.tgz dist/
- npm run prepare-release-artifact
- shasum -a 256 dist/* > dist/checksums.txt

# release in Github
Expand Down
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"xcode_settings": {
"MACOSX_DEPLOYMENT_TARGET": "10.10",
"OTHER_CFLAGS": [
"-std=c++11",
"-std=c++14",
"-stdlib=libc++",
"-Wall",
"-Werror"
Expand Down
54 changes: 20 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"clean": "tsc --build --clean",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p .",
"compile": "tsc --build",
"prepare-release-artifact": "node scripts/prepare-release-artifact.js",
"install": "node-gyp-build",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint . --ext .ts",
"lint:commits": "commitlint",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"prebuild:current": "node scripts/prebuild-current.js",
"prebuild:os": "node scripts/prebuild-os.js",
"release:github": "node scripts/release-github.js",
"version:check": "node scripts/version-check.js",
"version:generate": "node scripts/version-generate.js",
Expand All @@ -37,7 +39,7 @@
"stats"
],
"engines": {
"node": ">=8.5.0 <17"
"node": ">=8.5.0 <18"
},
"files": [
"binding.gyp",
Expand Down Expand Up @@ -94,7 +96,7 @@
"ts-node": "10.4.0",
"typescript": "4.4.4",
"winston": "3.3.3",
"prebuildify": "4.2.1"
"prebuildify": "5.0.0"
},
"dependencies": {
"@opentelemetry/api": "^1.0.3",
Expand Down
17 changes: 17 additions & 0 deletions scripts/prebuild-os.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const prebuildify = require('prebuildify');

let targets = process.argv.slice(2);

if (targets.length == 0) {
targets = ['8.5.0', '9.0.0', '10.0.0', '11.0.0', '12.0.0', '13.0.0', '14.0.0', '15.0.0', '16.0.0', '17.0.1'];
}

prebuildify({
strip: true,
targets: targets,
}, err => {
if (err) {
console.error(err.message || err);
process.exit(1);
}
});
Loading

0 comments on commit a2d5b94

Please sign in to comment.