Giter Site home page Giter Site logo

fabric8-recommender's Introduction

fabric8-ui

Build Status codecov

Development environment

Run fabric8-ui with remote backends

You need to setup your shell to point to the right cluster so that it can talk to the required back end services like KeyCloak, WIT, Forge, OpenShift etc.

We provide various sample environments out of the box which make it easier to get started. They are all located as bash scripts in environments.

The default one you should use when you want to develop on the console is to reuse openshift.io production cluster:

source environments/openshift-prod-cluster.sh

There are others too. For example if you want to try run fabric8 locally on minishift and connect fabric8-ui to it then try:

source environments/local-cluster.sh

NOTE: If you want to target a local WIT backend, check our wiki How To pages.

Build and Run

Requires node version 8.3.0 and npm 5.3.0. Consider using Node Version Manager.

Run npm install. This will download all the required dependencies to be able to start the UI.

Run npm start. This will start the UI with live reload enabled. Then navigate to http://localhost:3000.

Run test

We use jest test loader because it's faster than karma execution.

All tests

npm run test

Note: the first execution of the test take longer, subsequent calls are cached and much faster.

Watch mode

If you want to run all test in a feature-flag folder in watch mode:

npm run test -- feature-flag -- --watch=true

Note: You don't need to specify full path for the name of the test.

Debug

npm run test:debug

or to debug a specific test:

npm run test:debug -- feature-flag.service
  • Go to chrome: chrome://inspect
  • Let go the debugger and put debugger in your test.

To debug in your prefer IDE consolt Jest debugging documentation.

VS Code

Run ext install EditorConfig to read the .editorconfig file

Feature flag

To learn how to toggle your work in progress development, read our wiki page on fabric8-toggles.

HTML, CSS and Less

| Code Guidelines

fabric8-ui uses HTML5 elements where appropriate, and practices practicality over purity. Use the least amount of markup with the fewest intricacies as possible.

Attribution order, syntax definitions and declaration order are an important aspect of the fabric8-ui code and should be followed according the the guidelines.

fabric8-ui uses Less for it's stylesheets. If you find yourself wanting to create a shared style that multiple components will use, then we recommend adding it to an existing .less file in the src/assets/stylesheets/shared/ directory. Only update these styles if you are making a truly global style, and are going to synchronize your changes across all of the various UI projects.

If you only want to make a change to a specific component, do so in that component's .less file, according to Angular best practices.

The file osio.less is imported into every component Less file using @import (reference), so all files inside of the /shared directory will be used by each component.

Code Quality

fabric8-ui utilizes stylelint and htmlhint to check the less and html code. As part of each linter, we include three files: .stylelintrc, .stylelintignore and .htmlhintrc.

The .stylelintrc configuration file controls our configuration for the stylelinter, which only checks folders and files that are not included in the .stylelintignore file. This allows us to exclude certain areas of the application, as needed.

The .htmlhintrc configuration file controls our HTML verification configuration. In the creation of this configuration, we have taken into account the various Angular elements that will exist in the HTML pages.

Running the code quality checks

Each linter is built into the build process, so running npm run build or npm start will display any errors, their location (file name and line number), and any error message(s). Whenever a file that is watched by the code quality checks is changed, the build (if started with npm start) will re-run, checking only the altered files.

If you would like to run either of these checks individually, without kicking off a full build, you can do so by installing stylelint and htmlhint globally:

npm install stylelint -g
npm install htmlhint -g

After installing stylelint and htmlhint globally, you can run the following commands:

  • stylelint "**/*.less"

This will run stylelint against all .less files in fabric8-ui/src, using the .stylelintrc configuration file.

  • htmlhint

This will run htmlhint against all html files in fabric8-ui/src, using the .htmlhintrc configuration file. This command will not ignore the files and folders dictated in the webpack.common.js file, leading to the possibility of errors being displayed that will not appear at build time.

Alternatively, if you would like to check a subset of folders, or a specific file, you can do so by altering your htmlhint command:

  cat src/app/layout/header/header.component.html | htmlhint stdin

Integrations

fabric8-ui uses rxjs to provide loose coupling between modules (both those in the code base and those integrated via NPM). To do this, fabric8-ui makes extensive use of the Broadcaster.

Context

Space changed

When the current space the user is viewing changes, fabric8-ui broadcasts with the key spaceChanged and the
new Space as the payload.

UI integrations

Notifications

To send a notification to the user, the module should import ngx-fabric8-wit and inject the Notifications service, and call the message() method, passing in a Notification. You can subscribe to the result of message() to observe any NotificationActions that result from the notification.

Working with multi-level depenendencies

Let's consider a scenario wher you have an NPM module 'C' which sits inside another NPM module 'B' which is included in the parent module 'A'. During development, it is very common to use npm link to create a symlink and test the changes automatically. In this case, there is a high possbility for the parent module 'A' to be totally unaware of the existence of npm module 'C' as the symlinks don't get propagated all the way up. As a result, you might end up seeing the following error in the parent module 'A':

Module not found: Error: Can't resolve 'C' in ...

To address this, we can make the parent module 'A' be aware of the existence of 'C', by making changes in

tsconfig.json

of the parent module 'A'.

Inside "compilerOptions", Add an object key, "baseUrl" which basically identifies the base of the project and all the other urls are relative to this. Add an object key, "paths" as below

{
  "compilerOptions": {
    .
    .
    .
    "baseUrl": ".",
    "paths": {
      .
      .
      .
      "C": ["node_modules/B/node_modules/C"] //relative to the base url
    }
  }
}

By doing this, parent module A now is aware of the existence of the grand child 'C'. This can be modified for n-level dependencies. If your project builds using AOT or in other words if your project uses tsconfig-aot.json or similar, same things can be handled over there as well.

Continuous Delivery & Semantic Releases

In ngx-fabric8-wit we use the semantic-release plugin. That means that all you have to do is use the AngularJS Commit Message Conventions (documented below). Once the PR is merged, a new release will be automatically published to npmjs.com and a release tag created on GitHub. The version will be updated following semantic versioning rules.

Commit Message Format

A commit message consists of a header, body and footer. The header has a type, scope and subject:

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

The header is mandatory and the scope of the header is optional.

Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.

Revert

If the commit reverts a previous commit, it should begin with revert:, followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>., where the hash is the SHA of the commit being reverted.

Type

If the prefix is fix, feat, or perf, it will always appear in the changelog.

Other prefixes are up to your discretion. Suggested prefixes are docs, chore, style, refactor, and test for non-changelog related tasks.

Scope

The scope could be anything specifying place of the commit change. For example $location, $browser, $compile, $rootScope, ngHref, ngClick, ngView, etc...

Subject

The subject contains succinct description of the change:

  • use the imperative, present tense: "change" not "changed" nor "changes"
  • don't capitalize first letter
  • no dot (.) at the end

Body

Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.

Footer

The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit Closes.

Breaking Changes should start with the word BREAKING CHANGE: with a space or two newlines. The rest of the commit message is then used for this.

A detailed explanation can be found in this document.

Based on https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit

Examples

Appears under "Features" header, pencil sub-header:

feat(pencil): add 'graphiteWidth' option

Appears under "Bug Fixes" header, graphite sub-header, with a link to issue #28:

fix(graphite): stop graphite breaking when width < 0.1

Closes #28

Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:

perf(pencil): remove graphiteWidth option

BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reason.

The following commit and commit 667ecc1 do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.

revert: feat(pencil): add 'graphiteWidth' option

This reverts commit 667ecc1654a317a13331b17617d973392f415f02.

Commitizen - craft valid commit messages

Commitizen helps you craft correct commit messages. Install it using npm install commitizen -g. Then run git cz rather than git commit.

Running End-to-End (E2E) Tests

A set of E2E tests have been written to verify the operation of major features such as the creation of a build pipeline.

These E2E tests are configured to be run locally in a shell, locally in a docker container, and in a docker container in Centos CI. The tests can be run against a local or remote server by specifying the server's URL as a parameter to the tests.

The E2E tests are available in this repo: https://github.com/fabric8io/fabric8-test

The full set of instructions on installing and executing the E2E tests are avalable here: https://github.com/fabric8io/fabric8-test/blob/master/ee_tests/README.md

Easy E2E Test Setup

Run the following script and follow the on screen prompts to configure the test environment. The process will checkout the fabric8-test project as a sibling to fabric8-ui.

npm run e2e

To clean up the fabric8-test project:

npm run e2e:clean

To delete the e2e configuration file and re-prompt for all data:

npm run e2e:reconfig

To run the e2e tests using the last configuration without prompting:

npm run e2e:last

Mac Users

You may encounter the error readlink: illegal option -- f. To fix this, run the following commands:

brew install coreutils
ln -s "$(which greadlink)" "$(dirname "$(which greadlink)")/readlink"

Monorepo

This monorepo is managed with Lerna.

To get started, install the project dependencies and bootstrap all packages. The bootstrap process will update all packages with all their dependencies and link any cross-dependencies.

npm install
npm run bootstrap

VSCode Extensions

  • Prettier - Code formatter
    • Integrates prettier for auto formatting.
  • ESLint
    • Integrates ESLint reporting in editors.
  • Coverage Gutters
    • Display test coverage generated by lcov.
  • Jest
    • Snapshot syntax highlighting.
    • Augment unit tests with inline error reports.
  • Angular Language Service (angular.ng-template)
    • Provides a rich editing experience for Angular templates.

fabric8-recommender's People

Contributors

arunkumars08 avatar aslakknutsen avatar christianvogt avatar corinnekrych avatar dgutride avatar fabric8cd avatar hectorj2f avatar humaton avatar invinciblejai avatar jarifibrahim avatar joshuawilson avatar jyasveer avatar naina-verma avatar nainav avatar pmuir avatar rawlingsj avatar sanketpathak avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fabric8-recommender's Issues

Bug: Build report doesn't show the declared licenses

From @luebken on June 7, 2017 14:5

In the stack report the dependencies should report the licenses declared by the project.

Associated test-cases:

  • Test-1704E469-02

    • io.vertx/vertx-core/3.4.1 should report Apache 2.0, EPL 1.0
  • Test-1704E469-03

    • io.vertx/vertx-web/3.4.1 should report Apache 2.0, EPL 1.0
  • Test-1704E469-04

    • org.springframework/spring-core/4.3.3.RELEASE should report Apache 2.0

Associated experience:

  • Experience 1704E469 [P0] โ€“ License information

Copied from original issue: openshiftio/openshift.io#205

Wrong number in analyzed_dependencies_count?

An example how the stack analyses v2 output look like - there's and array with one analyzed dependency, but the attribute analyzed_dependencies_count says it is zero:

                "analyzed_dependencies": [
                    {
                        "version": "6.7",
                        "package": "click"
                    }
                ],
                "analyzed_dependencies_count": 0,

Update Tests to Run on MacOS

Issue:
When trying to run npm run test on MacOS, they console hangs and never gets passed the 'Starting Webdriver and Selenium' step. In order to fix this, the user needs to manually change the run_functional_tests.sh file to use "nc" instead of "ncat".

Request:
Update run_functional_tests.sh to use "nc" rather than "ncat". This will allow the tests to run on both Linux and MacOS.

Semantic Release

Set up and configure Semantic Release so that each commit with the correct syntax releases a new version on npmjs.

fabric8-stack-analysis-ui cannot locate c3

While converting fabric8-ui to use Less, @mindreeper2420 and I encountered a new issue with the webpack build. That is, the build fails to compile while complaining that fabric8-stack-analysis-ui cannot locate c3.

ERROR in ./~/fabric8-stack-analysis-ui/src/app/stack/overview/chart-component.js
Module not found: Error: Can't resolve 'c3' in '/Users/dlabrecq/Work/alm/repos/fabric8-ui/node_modules/fabric8-stack-analysis-ui/src/app/stack/overview'

I don't see c3 as a dependency in package.json, but chart-component.js appears to require it.

import * as c3 from 'c3'; <<< Line 7 of chart-component.js

That said, the work around is to modify webpack to use Patternfly's c3 dependency, like so. However, this is something we should resolve in the fabric8-stack-analysis-ui package instead.

resolve: {
...
      modules: [helpers.root('src'), helpers.root('node_modules'),

        // Todo: fabric8-stack-analysis-ui/src/app/stack/overview/chart-component.js cannot locate c3
        helpers.root("node_modules/patternfly/node_modules/c3"),
        helpers.root("node_modules/patternfly/node_modules/d3")
      ]

Note the error is reproducible with the Less conversion branch.

https://github.com/mindreeper2420/fabric8-ui/tree/less-conversion

Stack Report Dropdown: Display only the meaningful portion of the manifest file path

In stack report, a dropdown has been introduced that enables users to change reports for different manifest files in a multi-module application. Currently, that dropdown displays the full build path of manifest files that includes unnecessary reference of a temporary build location.

See https://www.screencast.com/t/DTyNN6zia

Please display only the meaningful portion from the application's context in the dropdown. Also, please make sure that this change is verified by the UX team.

CC: @jyasveer

Update Login

The login client needs to be configured to work when imported into fabric8-ui. Possibly in standalone mode too.

Typo in stack analysis v2 result JSON

outlier_prbability should be outlier_probability:

           "recommendations": {
                "companion": [],
                "usage_outliers": [
                    {
                        "package_name": "wheel",
                        "outlier_prbability": 0.71875
                    },
                    {
                        "package_name": "setuptools",
                        "outlier_prbability": 0.640625
                    }
                ],
                "alternate": []

Bug: No /stack-analysis results for known stack

From @luebken on June 29, 2017 11:33

I started a stack analysis for https://github.com/openshiftio-vertx-boosters/vertx-http-booster

The results seem broken:


curl -sH "Authorization: Bearer $OSIO_TOKEN" $API/stack-analyses/74703fe130004ce2aef674c4dd0dcb48
{
    "finished_at": "2017-06-29T10:59:10.516466",
    "recommendation": {
        "recommendations": {
            "component_level": null,
            "similar_stacks": []
        }
    },
    "request_id": "74703fe130004ce2aef674c4dd0dcb48",
    "result": [
        {
            "_audit": {
                "ended_at": "2017-06-29T10:59:10.516466",
                "started_at": "2017-06-29T10:59:10.494493",
                "version": "v1"
            },
            "_release": "None:None:None"
        }
    ],
    "schema": {
        "name": "stack_analyses",
        "url": "http://recommender.api.openshift.io/api/v1/schemas/api/stack_analyses/2-1-4/",
        "version": "2-1-4"
    },
    "started_at": "2017-06-29T10:59:10.494493"
}

Copied from original issue: openshiftio/openshift.io#302

Typo in work item screen after creating work items from recommender

Steps to reproduce:

  1. Login to openshift
  2. Create a new space
  3. Use the starter application and create a starter project (say Vert.x basic)
  4. Go to pipelines tab
  5. Trigger a pipeline build for the one that you have created.
  6. Stack analysis report link will show up (Else log an issue in this repo for the same)
  7. Click on stack analysis link (A modal will show up)
  8. Click on create work item if any
  9. Go to the view work item link
  10. Check the typo in the description (It has to be potential version upgrade instead of 'potentially')

screen shot 2017-06-09 at 11 36 52 am

"BVT" against every PR should be enabled

"BVT" against every PR should be enabled

Presently , recommender doesn't have Build verification tests running against PR's.

  • Unit tests
  • smoke tests
    should be enabled before merging the code into the master !

Implement recommender feature as per mock.

Change the current recommender feature's look to make it in sync with the mock.

  1. Handle Actions for the recommendations - Done
  2. Handle Single Work Item addition scenario - Done
  3. Handle Multiple work item addition scenario - Done
  4. Handle styling

Convert to LESS and add Stylelint

Convert all .scss files to .less and add Stylelint to check code quality. File structure, configurations and rulesets will be updated to match fabric8-ui.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.