Some cleanup on files. Remove skip tests

master
Jonatan Nilsson 2022-02-18 08:16:36 +00:00
parent 0f504eaf53
commit 57be8a144a
6 changed files with 95 additions and 248 deletions

View File

@ -1,58 +0,0 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:latest
resource_class: medium
working_directory: ~/app
steps:
- checkout
- run:
name: Install npm deployment app
command: sudo npm install -g github-release-cli @babel/runtime
- run:
name: Check if this is a new release
command: |
set +e
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g')
github-release list --owner $CIRCLE_PROJECT_USERNAME --repo $CIRCLE_PROJECT_REPONAME | grep "tag_name=\"v${PACKAGE_VERSION}\""
retVal=$?
if [ $retVal -eq 0 ]; then
echo "Release already exists. Quitting early"
circleci step halt
fi
- run:
name: Get current git commit message
command: |
echo "export COMMIT_MESSAGE=\"$(git log --format=oneline -n 1 $CIRCLE_SHA1)\"" >> $BASH_ENV
source $BASH_ENV
- run:
name: Get 7zz
command: |
wget https://www.7-zip.org/a/7z2106-linux-x64.tar.xz
tar -xvf 7z2106-linux-x64.tar.xz
- deploy:
name: Create a release
command: |
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g')
echo "Creating release v${PACKAGE_VERSION}"
./7zz a "${CIRCLE_PROJECT_REPONAME}_build-sc-core.7z" runner.mjs package.json "service/*" "core/**/*" "core/*" -mx9 -mfb273 -mmt2 -md16M -mqs -myx9
./7zz a "${CIRCLE_PROJECT_REPONAME}_app.zip" runner.mjs package.json "service/*" "core/**/*" "core/*" config.json install.bat npminstall.bat README.md uninstall.bat
echo "Creating release '${PACKAGE_VERSION}'"
github-release upload \
--commitish $CIRCLE_SHA1 \
--token $GITHUB_TOKEN \
--owner $CIRCLE_PROJECT_USERNAME \
--repo $CIRCLE_PROJECT_REPONAME \
--tag "v${PACKAGE_VERSION}" \
--release-name "v${PACKAGE_VERSION}" \
--body "Automatic CircleCI Build of v${PACKAGE_VERSION} from ${CIRCLE_SHA1}: ${COMMIT_MESSAGE}" \
"${CIRCLE_PROJECT_REPONAME}_build-sc-core.zip" "${CIRCLE_PROJECT_REPONAME}_app.zip"
workflows:
version: 2
build_deploy:
jobs:
- build:
context: github-thething

98
.gitignore vendored
View File

@ -1,111 +1,13 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Custom ignore
db.json
package-lock.json
daemon
dev/public/main.js

View File

@ -50,7 +50,7 @@ on_success:
-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}\"}")
-d "{\"tag_name\":\"v${CURR_VER}\",\"name\":\"v${CURR_VER}\",\"body\":\"Automatic release from Appveyor from ${APPVEYOR_REPO_COMMIT} :\n\n${APPVEYOR_REPO_COMMIT_MESSAGE}\"}")
RELEASE_ID=$(echo $RELEASE_RESULT | jq -r .id)
echo "Adding ${CURR_VER}_sc-core.7z to release ${RELEASE_ID}"
curl \

View File

@ -25,6 +25,9 @@
"inherit": true
}
},
"bin": {
"sccli": "./cli.mjs"
},
"repository": {
"type": "git",
"url": "git+https://git.nfp.is/TheThing/service-core.git"

View File

@ -32,7 +32,7 @@ t.after(function() {
})
})
t.skip().timeout(10000).test('should run update and install correctly', async function(){
t.timeout(10000).test('should run update and install correctly', async function(){
try {
await app.update()
} catch (err) {

View File

@ -3,96 +3,96 @@ import Util from '../../core/util.mjs'
import fs from 'fs/promises'
import GitProvider from '../../core/providers/git.mjs'
t.skip().describe('test', function() {
t.after(function() {
return fs.rm('./test/providers/file.7z')
.catch(function() { })
})
t.after(function() {
return fs.rm('./test/providers/file.7z')
.catch(function() { })
})
t.timeout(5000).describe('#getLatestVersion()', function() {
t.test('should return latest version in a valid repository', async function() {
let provider = new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/sc-helloworld/releases' })
let version = await provider.getLatestVersion()
assert.ok(version)
assert.ok(version.version)
assert.ok(version.description)
assert.ok(version.link)
assert.match(version.link, /\/attachments\//)
})
})
t.timeout(5000).describe('#checkConfig()', function() {
t.test('should fail if link does not return json repository object', async function() {
let err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/repos/thething/ProgramQueuer' }).checkConfig())
assert.match(err.message, /valid/i)
assert.match(err.message, /repository/i)
err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/orgs/nfp/repos' }).checkConfig())
assert.match(err.message, /service-core/i)
assert.match(err.message, /release/i)
})
t.test('should fail if no active release repository with assets', async function() {
let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/eltro/releases' }).checkConfig())
assert.match(err.message, /service-core/i)
assert.match(err.message, /release/i)
})
t.test('should fail on private repositories', async function() {
let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases' }).checkConfig())
assert.match(err.message, /fail/i)
assert.match(err.message, /404/i)
assert.match(err.message, /release/i)
})
t.test('should otherwise succeed', function() {
return new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/sc-manager/releases' })
.checkConfig()
})
let test = t
if (!process.env.gittesttoken) {
test = test.skip()
}
test.test('should succeed on private repo with token', function() {
return new GitProvider({
token: process.env.gittesttoken.trim(),
url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases',
}).checkConfig()
})
})
t.timeout(5000).describe('#downloadVersion()', function() {
const util = new Util(import.meta.url)
let test = t
if (!process.env.gittesttoken) {
test = test.skip()
}
test.test('should successfully download release', async function() {
let provider = new GitProvider({
token: process.env.gittesttoken.trim(),
url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases',
})
await provider.checkConfig()
let version = await provider.getLatestVersion()
assert.ok(version.version)
assert.ok(version.filename)
assert.ok(version.link)
let path = util.getPathFromRoot('./file.7z')
await provider.downloadVersion(version, path)
let stat = await fs.stat(path)
assert.ok(stat.size > 0)
stat = await fs.stat('./test/providers/file.7z')
assert.ok(stat.size > 0)
let output = ''
await util.runCommand(util.get7zipExecutable(), ['l', 'file.7z'], util.getPathFromRoot('./'), function(chunk) {
output += chunk + '\n'
})
assert.ok(output.indexOf('file1.txt'))
assert.ok(output.indexOf('file2.txt'))
})
t.timeout(5000).describe('#getLatestVersion()', function() {
t.test('should return latest version in a valid repository', async function() {
let provider = new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/sc-helloworld/releases' })
let version = await provider.getLatestVersion()
assert.ok(version)
assert.ok(version.version)
assert.ok(version.description)
assert.ok(version.link)
assert.match(version.link, /\/attachments\//)
})
})
t.timeout(5000).describe('#checkConfig()', function() {
t.test('should fail if link does not return json repository object', async function() {
let err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/repos/thething/ProgramQueuer' }).checkConfig())
assert.match(err.message, /valid/i)
assert.match(err.message, /repository/i)
err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/orgs/nfp/repos' }).checkConfig())
assert.match(err.message, /service-core/i)
assert.match(err.message, /release/i)
})
t.test('should fail if no active release repository with assets', async function() {
let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/eltro/releases' }).checkConfig())
assert.match(err.message, /service-core/i)
assert.match(err.message, /release/i)
})
t.test('should fail on private repositories', async function() {
let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases' }).checkConfig())
assert.match(err.message, /fail/i)
assert.match(err.message, /404/i)
assert.match(err.message, /release/i)
})
t.test('should otherwise succeed', function() {
return new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/sc-manager/releases' })
.checkConfig()
})
let test = t
if (!process.env.gittesttoken) {
console.log('Skipping "git.test.integration: #checkConfig() should succeed on private repo with token"')
test = test.skip()
}
test.test('should succeed on private repo with token', function() {
return new GitProvider({
token: process.env.gittesttoken.trim(),
url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases',
}).checkConfig()
})
})
t.timeout(5000).describe('#downloadVersion()', function() {
const util = new Util(import.meta.url)
let test = t
if (!process.env.gittesttoken) {
console.log('Skipping "git.test.integration: #downloadVersion() should successfully download release"')
test = test.skip()
}
test.test('should successfully download release', async function() {
let provider = new GitProvider({
token: process.env.gittesttoken.trim(),
url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases',
})
await provider.checkConfig()
let version = await provider.getLatestVersion()
assert.ok(version.version)
assert.ok(version.filename)
assert.ok(version.link)
let path = util.getPathFromRoot('./file.7z')
await provider.downloadVersion(version, path)
let stat = await fs.stat(path)
assert.ok(stat.size > 0)
stat = await fs.stat('./test/providers/file.7z')
assert.ok(stat.size > 0)
let output = ''
await util.runCommand(util.get7zipExecutable(), ['l', 'file.7z'], util.getPathFromRoot('./'), function(chunk) {
output += chunk + '\n'
})
assert.ok(output.indexOf('file1.txt'))
assert.ok(output.indexOf('file2.txt'))
})
})