Clean up some of the test, finish implementing auto publish on both npm and git
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

This commit is contained in:
Jonatan Nilsson 2022-02-18 07:40:39 +00:00
parent ed73607e7b
commit 0f504eaf53
4 changed files with 33 additions and 3 deletions

View file

@ -38,12 +38,28 @@ artifacts:
# on successful build
on_success:
- sh: |
CURR_VER=$(npm view package.json version)
if curl -s -X GET -H "token: $deploytoken" https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases | grep -o "\"name\"\:\"v${CURR_VER}\"" > /dev/null; then
apk add curl jq
CURR_VER=$(cat package.json | jq -r .version)
if curl -s -X GET -H "Authorization: token $deploytoken" https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases | grep -o "\"name\"\:\"v${CURR_VER}\"" > /dev/null; then
echo "Release already exists, nothing to do.";
else
./test/7zas a -mx9 "${CURR_VER}_sc-core.7z" package.json index.mjs cli.mjs core bin
echo "Creating release on gitea"
RELEASE_RESULT=$(curl \
-X POST \
-H "Authorization: token $deploytoken" \
-H "Content-Type: application/json" \
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases \
-d "{\"tag_name\":\"v${CURR_VER}\",\"name\":\"v${CURR_VER}\",\"body\":\"Automatic release from Appveyor from ${APPVEYOR_REPO_COMMIT}: ${APPVEYOR_REPO_COMMIT_MESSAGE}\"}")
RELEASE_ID=$(echo $RELEASE_RESULT | jq -r .id)
echo "Adding ${CURR_VER}_sc-core.7z to release ${RELEASE_ID}"
curl \
-X POST \
-H "Authorization: token $deploytoken" \
-F "attachment=@${CURR_VER}_sc-core.7z" \
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases/$RELEASE_ID/assets
echo '//registry.npmjs.org/:_authToken=${npmtoken}' > ~/.npmrc
echo "Publishing new version to npm"
npm publish
fi
- sh: |

View file

@ -1,6 +1,6 @@
{
"name": "service-core",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.2",
"description": "Core boiler plate code to install node server as windows service",
"main": "index.mjs",
"scripts": {

View file

@ -255,6 +255,12 @@ t.describe('#init()', function() {
Core.providers.set(assertProviderName, FakeProvider)
})
t.after(function() {
return Promise.all([
fs.rm('./log_test_1.log', { recursive: true, force: true }),
])
})
t.test('it should call util.verifyConfig correctly', async function() {
const assertError = new Error('Red faction IO drive mix')
const assertConfig = { a: 1 }

View file

@ -1,4 +1,5 @@
import { Eltro as t, assert, stub } from 'eltro'
import fs from 'fs/promises'
import getLog from '../core/log.mjs'
t.describe('#constructor', function() {
@ -6,6 +7,13 @@ t.describe('#constructor', function() {
process.env.NODE_ENV = null
})
t.after(function() {
return Promise.all([
fs.rm('./log.log', { recursive: true, force: true }),
])
})
t.test('should add name', function() {
const assertName = 'Stray Cat'
let logger = getLog(assertName)