Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/#996-MD-Style-additional-predefin…
Browse files Browse the repository at this point in the history
…ed–custom-containers
  • Loading branch information
Gargamil authored Nov 21, 2018
2 parents f1d52ad + b71fa67 commit 5a1b1d0
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 192 deletions.
131 changes: 72 additions & 59 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,67 +34,80 @@ branches:

cache:
directories:
- "$HOME/.npm"
- "$HOME/.npm"

before_install:
# check for change in changelog
- .travis/changelog.sh
stages:
- test
- name: deploy
if: type = push AND (branch IN (develop, master) OR tag IS present)

before_script:
# required for chrome to start properly
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
# required for MongoDB to have time to start up
- sleep 15

install:
# install api and return back to root for following steps
- cd api
- npm ci
- cd ..
# install frontend and return back to root for following steps
- cd app/webFrontend
- npm ci
- cd ../..
# install travis dependencies
- cd .travis
- npm ci
- cd ..

script:
# check for versions
- .travis/check-version.sh
# run license checker and write license.json / dependencies.ts
- .travis/license-crawler.sh
# run backend-tests and return back to root for following steps
- cd api
- sed -i 's/$TRAVIS_COMMIT/'$TRAVIS_COMMIT'/' src/server.ts
- npm run test # run backend test
- cd ..
- .travis/apidoc-check.sh
# run frontend-tests and return back to root for following steps
- cd api
- npm run load:fixtures
- npm start &
- cd ../app/webFrontend
- npm run lint # run linter
# - npm run test-ci || true # run test - many tests are broken
- npm run e2e # run end-to-end-tests
- sed -i 's/$TRAVIS_COMMIT/'$TRAVIS_COMMIT'/' src/app/shared/services/raven-error-handler.service.ts
- cd ../..
# - travis_wait 30 .travis/build-fe.sh # build in prod mode
- .travis/build-fe.sh # build in prod mode

after_script:
# send required files to coveralls.io
- .travis/coveralls.sh

after_success:
- .travis/package-checker.sh
- .travis/apidoc.sh
- .travis/docker.sh
- .travis/deploy.sh
- .travis/sentry.sh
jobs:
include:
- stage: test
name: "Tests Api"
install:
- ${TRAVIS_BUILD_DIR}/.travis/changelog.sh
- cd ${TRAVIS_BUILD_DIR}/.travis
- npm ci
- cd ${TRAVIS_BUILD_DIR}/api
- npm ci
- ${TRAVIS_BUILD_DIR}/.travis/license-crawler.sh
script:
- npm run lint
- npm run test
- npm run apidoc
after_script:
- cd ${TRAVIS_BUILD_DIR}
- .travis/coveralls.sh
- stage: test
name: "Tests Frontend"
before_install:
- export NODE_OPTIONS=--max_old_space_size=4096
install:
- ${TRAVIS_BUILD_DIR}/.travis/changelog.sh
- cd ${TRAVIS_BUILD_DIR}/.travis
- npm ci
- cd ${TRAVIS_BUILD_DIR}/api
- npm ci
- cd ${TRAVIS_BUILD_DIR}/app/webFrontend
- npm ci
- ${TRAVIS_BUILD_DIR}/.travis/license-crawler.sh
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- cd ${TRAVIS_BUILD_DIR}/api
- npm run load:fixtures
- npm start &
- cd ${TRAVIS_BUILD_DIR}/app/webFrontend
- npm run lint
- npm run e2e
- npm run build
- stage: deploy
before_install:
- export NODE_OPTIONS=--max_old_space_size=4096
install:
- cd ${TRAVIS_BUILD_DIR}/.travis
- npm ci
- cd ${TRAVIS_BUILD_DIR}/api
- npm ci
- sed -i 's/$TRAVIS_COMMIT/'$TRAVIS_COMMIT'/' src/server.ts
- cd ${TRAVIS_BUILD_DIR}/app/webFrontend
- npm ci
- sed -i 's/$TRAVIS_COMMIT/'$TRAVIS_COMMIT'/' src/app/shared/services/raven-error-handler.service.ts
- ${TRAVIS_BUILD_DIR}/.travis/license-crawler.sh
script:
- cd ${TRAVIS_BUILD_DIR}/api
- npm run build
- cd ${TRAVIS_BUILD_DIR}/app/webFrontend
- npm run build
after_success:
- cd ${TRAVIS_BUILD_DIR}
- .travis/package-checker.sh
- .travis/docker.sh
- .travis/apidoc.sh
- .travis/deploy.sh
- .travis/sentry.sh

# Configure notification
notifications:
Expand Down
21 changes: 0 additions & 21 deletions .travis/apidoc-check.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .travis/apidoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "${DIR}/_shared-vars.sh"

echo
echo "+++ Create and publish API-Doc +++"
echo "+++ Create and publish Api-Doc +++"
echo

if [[ ${TRAVIS_PULL_REQUEST} != false ]]; then
Expand Down
28 changes: 0 additions & 28 deletions .travis/build-fe.sh

This file was deleted.

49 changes: 23 additions & 26 deletions .travis/license-crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@
const fs = require('fs');
const nlf = require('nlf');

const LICENSE_FILE_NAME = 'nlf-licenses';
const PATH_API = '../api/';
const PATH_APP_WEB = '../app/webFrontend/';
const PATH_APP_WEB_FILE_NAME = 'src/app/about/licenses/dependencies.ts';
const PACKAGE_BLACKLIST = [
'geli-api',
'geli-web-frontend',
'rxjs-compat'
];
const API_PATH = '../api/';
const API_FILE_NAME = 'nlf-licenses';
const WEB_PATH = '../app/webFrontend/';
const WEB_FILE_NAME = 'src/app/about/licenses/dependencies.ts';

const PACKAGE_BLACKLIST = ['geli-api', 'geli-web-frontend', 'rxjs-compat'];
const SEARCH_FOR = '// DEPENDENCY_REPLACE';

console.log('\n+++ Starting license js +++\n');

// API
console.log('+ starting api crawl');
nlf.find({
directory: PATH_API,
directory: API_PATH,
production: true,
depth: 1
}, (err, data) => {
if (err) throw err;
if (err) {
throw err;
}
console.log('+ api: polish json');
let json = JSON.stringify(
{data: polishJson(data)}
);

fs.writeFile(
PATH_API + LICENSE_FILE_NAME + '.json',
API_PATH + API_FILE_NAME + '.json',
json,
'utf8',
() => console.log('+ api: wrote json')
Expand All @@ -39,7 +38,7 @@ nlf.find({
// WEB_APP
console.log('+ starting appWeb crawl');
nlf.find({
directory: PATH_APP_WEB,
directory: WEB_PATH,
production: true,
depth: 1
}, (err, data) => {
Expand All @@ -49,7 +48,7 @@ nlf.find({
let out = '';
json.forEach((value, i) => {
if (i > 0) {
out += '\n , ';
out += ',\n ';
}

let sep = '\', \'';
Expand All @@ -62,19 +61,17 @@ nlf.find({
+ ')';
});

fs.readFile(PATH_APP_WEB + PATH_APP_WEB_FILE_NAME, (err, data) => {
if (err) throw err;
data = data.toString();
data = data.replace(SEARCH_FOR, out);

if (process.env.TRAVIS) {
fs.writeFile(PATH_APP_WEB + PATH_APP_WEB_FILE_NAME, data, 'utf8',
() => console.log(('+ appWeb: wrote file'))
);
} else {
console.warn('+ appWeb: We are not on travis, will only print content:');
console.log(data);
fs.readFile(WEB_PATH + WEB_FILE_NAME, 'utf8', (err, data) => {
if (err) {
throw err;
}

fs.writeFile(
WEB_PATH + WEB_FILE_NAME,
data.replace(SEARCH_FOR, out),
'utf8',
() => console.log(('+ appWeb: wrote file'))
);
})
});

Expand Down
67 changes: 15 additions & 52 deletions .travis/license-crawler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,30 @@

# Path to this file
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Path the script was called from
IPWD="$(pwd)"
# Import shared vars
. ${DIR}/_shared-vars.sh

# Functions
function npm_package_is_installed {
local return_=1
ls node_modules | grep $1 > /dev/null 2>&1 || { local return_=0; }
echo "$return_"
}
# shellcheck source=_shared-vars.sh
. "${DIR}/_shared-vars.sh"

# Begin of code
echo
echo "+++ Run NLF +++"
echo "+++ Run node license finder +++"
echo

[ ! "$TRAVIS_PULL_REQUEST" == "false" ] ; IS_PR=$?
( [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "develop" ] ) ; IS_BRANCH=$?
[ -n "$TRAVIS_TAG" ] ; IS_TAG=$?
if [[ ${TRAVIS_PULL_REQUEST} != false ]]; then
echo -e "${YELLOW}+ Pull Request. Write dummy data.${NC}"

IS_PR=$(if [ "$IS_PR" == "0" ]; then echo -n true; else echo -n false; fi)
IS_BRANCH=$(if [ "$IS_BRANCH" == "0" ]; then echo -n true; else echo -n false; fi)
IS_TAG=$(if [ "$IS_TAG" == "0" ]; then echo -n true; else echo -n false; fi)
echo '{"data":[{"name":"NO-DEP","version":"0.0.1","repository":"https://exmaple.com","license":"MIT","devDependency":false},{"name":"NO-DEP","version":"0.0.1","repository":"https://exmaple.com","license":"MIT","devDependency":true}]}' > "${DIR}/../api/nlf-licenses.json"
sed -i "s#// DEPENDENCY_REPLACE#new Dependency('NO-DEP', '0.0.1', 'https://example.com', 'MIT', false), new Dependency('NO-DEP', '0.0.1', 'https://example.com', 'MIT', true)#" "${DIR}/../app/webFrontend/src/app/about/licenses/dependencies.ts"

echo -e "+ IS_PR => $IS_PR\t($TRAVIS_PULL_REQUEST)"
echo -e "+ IS_BRANCH => $IS_BRANCH\t($TRAVIS_BRANCH)"
echo -e "+ IS_TAG => $IS_TAG\t($TRAVIS_TAG)"
echo

if ( [ "$IS_BRANCH" == "true" ] && [ "$IS_PR" == "false" ] ) || [ "$IS_TAG" == "true" ]; then
echo "+ checking if nlf is installed"
cd ${DIR}
if [ $(npm_package_is_installed nlf) == 0 ]; then
echo -e "${RED}+ ERROR: nlf is not installed, please add nlf to the .travis/package.json${NC}"
exit 1
fi
cd ${IPWD}
exit 0;
fi

echo "+ run node"
echo
if [[ ${TRAVIS_BRANCH} == "master" ]] || [[ ${TRAVIS_BRANCH} == "develop" ]] || [[ -n ${TRAVIS_TAG} ]]; then
cd "${DIR}" || exit 0

cd ${DIR}
node license-crawler.js
cd ${IPWD}
else
echo -e "${YELLOW}+ WARNING: Branch not whitelisted OR PullRequest${NC}";
echo "+ will write dummy data"
echo "{
\"data\": [
{\"name\":\"NO-DEP\",\"version\":\"0.0.1\",\"repository\":\"https://exmaple.com\",\"license\":\"MIT\",\"devDependency\":false},
{\"name\":\"NO-DEP\",\"version\":\"0.0.1\",\"repository\":\"https://exmaple.com\",\"license\":\"MIT\",\"devDependency\":true}
]
}" > api/nlf-licenses.json
FE_DATA="
new Dependency('NO-DEP', '0.0.1', 'https://example.com', 'MIT', false),
new Dependency('NO-DEP', '0.0.1', 'https://example.com', 'MIT', true)
"
FE_DATA=`echo $FE_DATA | tr '\n' "\\n"`
sed -i "s!// DEPENDENCY_REPLACE!$FE_DATA!" app/webFrontend/src/app/about/licenses/dependencies.ts

exit 0
fi

echo
echo "+ finished"
echo -e "${YELLOW}+ Branch not master or develop and no tag. Nothing todo.${NC}"
exit 0
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Switched to cookie-based JWT authentication. [#840](https://github.com/geli-lms/geli/issues/840) [#968](https://github.com/geli-lms/geli/issues/968)
- Prepare `typescript` 3.1 upgrade. [#967](https://github.com/geli-lms/geli/pull/967)
- Use `npm ci` instead `npm install` and cache `$HOME/.npm` instead of `node_modules`. [#972](https://github.com/geli-lms/geli/pull/972)
- Use travis build stages. [#962](https://github.com/geli-lms/geli/issues/962)

### Removed
- `@types/winston`. [#945](https://github.com/geli-lms/geli/pull/945)
Expand Down
6 changes: 3 additions & 3 deletions api/package-lock.json

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

Loading

0 comments on commit 5a1b1d0

Please sign in to comment.