-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
404 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const $ = require('shelljs') | ||
const path = require('path') | ||
const fs = require('fs') | ||
require('./logging') | ||
|
||
$.config.fatal = true | ||
const root = path.join(__dirname, '..') | ||
|
||
const dotnet_image = "microsoft/dotnet:2.0.0-sdk-stretch" | ||
|
||
function unit_test(configuration) { | ||
console.info(`Unit testing on .NET Core`) | ||
console.debug(`Configuration: ${configuration}`) | ||
|
||
const commands = [ | ||
`cd /app/test/UnitTests/`, | ||
`dotnet restore`, | ||
`dotnet build --configuration ${configuration}`, | ||
`dotnet xunit -configuration ${configuration} -nobuild -verbose` | ||
] | ||
.reduce((prev, curr) => `${prev} && ${curr}`, 'echo') | ||
|
||
$.exec( | ||
`docker run --rm --tty --volume "${root}:/app/" "${dotnet_image}" ` + | ||
`sh -c "${commands}"` | ||
) | ||
} | ||
|
||
function generate_app_settings_file() { | ||
console.info(`Generate appsettings.Development.json from environment variables`) | ||
|
||
const appSettings = { | ||
'ApiToken': process.env['TelegramBot_ApiToken'], | ||
'AllowedUserNames': process.env['TelegramBot_AllowedUserNames'], | ||
'SuperGroupChatId': process.env['TelegramBot_SuperGroupChatId'] | ||
} | ||
|
||
for (const field in appSettings) | ||
if (!appSettings[field]) | ||
console.warn(`There is no value set for field ${field}.`) | ||
|
||
fs.writeFileSync(`${root}/test/IntegrationTests/appsettings.Development.json`, JSON.stringify(appSettings)) | ||
} | ||
|
||
function systems_integration_test(configuration) { | ||
console.info(`Systems Integration testing on .NET Core`) | ||
console.debug(`Configuration: ${configuration}`) | ||
|
||
const commands = [ | ||
`cd /app/test/IntegrationTests/`, | ||
`dotnet restore`, | ||
`dotnet build --configuration ${configuration}`, | ||
`dotnet xunit -configuration ${configuration} -stoponfail -nobuild -verbose` | ||
] | ||
.reduce((prev, curr) => `${prev} && ${curr}`, 'echo') | ||
|
||
$.exec( | ||
`docker run --rm --tty --volume "${root}:/app/" "${dotnet_image}" ` + | ||
`sh -c "${commands}"` | ||
) | ||
} | ||
|
||
console.info(`Docker Image: ${dotnet_image}`) | ||
|
||
unit_test('Debug') | ||
unit_test('Release') | ||
|
||
const branch = process.env['TRAVIS_BRANCH'] | ||
if (branch === 'develop') { | ||
generate_app_settings_file() | ||
systems_integration_test('Release') | ||
} else { | ||
console.warn(`Branch is "${branch}". Skipping systems integration tests...`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const chalk = require('chalk'); | ||
const $ = require('shelljs') | ||
|
||
if (process.env['TRAVIS']) { | ||
console.info = m => $.echo("\n\033[1;34m#", m, "\033[0m") | ||
console.debug = m => $.echo("\n\033[0;32m##", m, "\033[0m") | ||
console.warn = m => $.echo("\n\033[1;33m##", m, "\033[0m") | ||
console.error = m => $.echo("\n\033[1;31m##", m, "\033[0m") | ||
} else { | ||
console.info = m => console.log(chalk.blue.bold(`\n# ${m}\n`)) | ||
console.debug = m => console.log(chalk.green.bold(`\n## ${m}\n`)) | ||
console.warn = m => console.log(chalk.yellow.bold(`\n## ${m}\n`)) | ||
console.error = m => console.log(chalk.red.bold(`\n## ${m}\n`)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "build", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"travis-ci": "node build_travis-ci.js" | ||
}, | ||
"private": true, | ||
"devDependencies": { | ||
"@types/chalk": "^2.2.0", | ||
"@types/shelljs": "^0.8.0", | ||
"chalk": "^2.4.1", | ||
"shelljs": "^0.8.2" | ||
} | ||
} |
Oops, something went wrong.