travisci: add alpine test/publish to ci

This commit is contained in:
Mark Wolff 2019-12-02 14:43:31 -08:00
Родитель 4f55f11952
Коммит abc999cb08
5 изменённых файлов: 42 добавлений и 3 удалений

2
.dockerignore Normal file
Просмотреть файл

@ -0,0 +1,2 @@
node_modules
npm-debug.log

Просмотреть файл

@ -1,11 +1,12 @@
language: node_js
env:
- LINUX_CXX=g++-4.8
dist: trusty
os:
- linux
- osx
node_js:
- "node"
- "13"
- "12"
- "10"
- "8"
@ -20,5 +21,12 @@ script:
- npm run build:ts
- npm run build
- npm test
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker build --build-arg VERSION=$TRAVIS_NODE_VERSION -t tmp/alpine-native-metrics .; fi;
after_success:
- echo "Publishing"; npm install node-pre-gyp-github@1.4.3; ./node_modules/.bin/node-pre-gyp configure; ./node_modules/.bin/node-pre-gyp build; ./node_modules/.bin/node-pre-gyp package; ./node_modules/.bin/node-pre-gyp-github publish;
if ([ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]) &&
[ "$TRAVIS_PULL_REQUEST" == "false" ]; then
docker run -e NODE_PRE_GYP_GITHUB_TOKEN tmp/alpine-native-metrics; fi;
echo "Publishing"; npm install node-pre-gyp-github@1.4.3; ./node_modules/.bin/node-pre-gyp configure; ./node_modules/.bin/node-pre-gyp build; ./node_modules/.bin/node-pre-gyp package; ./node_modules/.bin/node-pre-gyp-github publish;
else
echo "Not publishing"
fi

26
Dockerfile Normal file
Просмотреть файл

@ -0,0 +1,26 @@
ARG VERSION=latest
FROM mhart/alpine-node:${VERSION}
WORKDIR .
COPY . .
RUN node --version
# Install Python dependencies
RUN apk add --update \
python \
python-dev \
py-pip \
build-base \
&& pip install virtualenv \
&& rm -rf /var/cache/apk/*
# Build & Test
RUN npm install
RUN npm run build:ts
RUN npm run build
RUN npm test
# # Publish binary to github
CMD npm run publish:github

Просмотреть файл

@ -27,7 +27,8 @@
"test:renamebinding": "rename-files ./ binding.gyp temp",
"test:renametestbinding": "cp test.gyp binding.gyp",
"test:renameoriginalbinding": "rename-files ./ temp binding.gyp",
"clean": "rimraf build/"
"clean": "rimraf build/",
"publish:github": "echo 'Publishing'; npm install node-pre-gyp-github@1.4.3; ./node_modules/.bin/node-pre-gyp configure; ./node_modules/.bin/node-pre-gyp build; ./node_modules/.bin/node-pre-gyp package; ./node_modules/.bin/node-pre-gyp-github publish;"
},
"gypfile": true,
"license": "MIT",

Просмотреть файл

@ -7,6 +7,8 @@ const emitter = new NativeMetricEmitter();
describe("#EndToEnd", () => {
it("should collect manual global.gc events", () => {
if (emitter._gcProfiler) {
emitter.getGCData(); // clear any transient GCs
// Verify precondition
assert.deepEqual({}, emitter.getGCData());