|
| 1 | +# Contributing |
| 2 | +Thank you for taking an interest in contributing to CWL Viewer. |
| 3 | + |
| 4 | +The following is a set of guidelines for contribution and helpful |
| 5 | +tips and resources for working with the code base. |
| 6 | + |
| 7 | +## Code of Conduct |
| 8 | +This project and everyone participating in it is governed by |
| 9 | +the [CWL Project Code of Conduct](https://github.com/common-workflow-language/common-workflow-language/blob/master/CODE_OF_CONDUCT.md). |
| 10 | +By participating, you are expected to uphold this code. |
| 11 | +Please report unacceptable behavior to |
| 12 | + |
| 13 | + |
| 14 | +## Issue Contribution |
| 15 | +Issues for both bug reports and feature requests are welcome. In |
| 16 | +the case of bug reports, please try to provide a verifiable example |
| 17 | +on the production instance if this is possible. |
| 18 | + |
| 19 | +Before you submit an issue, please search the issue tracker, maybe |
| 20 | +an issue for your problem already exists and the discussion might |
| 21 | +inform you of workarounds readily available. |
| 22 | + |
| 23 | +## Code Contribution |
| 24 | + |
| 25 | +### Workflow |
| 26 | +The preferred workflow for contributing to CWL Viewer is to fork the |
| 27 | +[main repository](https://github.com/common-workflow-language/cwlviewer) on |
| 28 | +GitHub, clone, and develop on a branch. Steps: |
| 29 | + |
| 30 | +1. Fork the [project repository](https://github.com/common-workflow-language/cwlviewer) |
| 31 | + by clicking on the 'Fork' button near the top right of the page. This creates |
| 32 | + a copy of the code under your GitHub user account. For more details on |
| 33 | + how to fork a repository see [this guide](https://help.github.com/articles/fork-a-repo/). |
| 34 | + |
| 35 | +2. Clone your fork of the cwlviewer repo from your GitHub account to your local disk: |
| 36 | + |
| 37 | + ```bash |
| 38 | + $ git clone [email protected]:YourLogin/cwlviewer.git |
| 39 | + $ cd cwlviewer |
| 40 | + ``` |
| 41 | + |
| 42 | +3. Create a ``feature`` branch to hold your development changes: |
| 43 | + |
| 44 | + ```bash |
| 45 | + $ git checkout -b my-feature |
| 46 | + ``` |
| 47 | + |
| 48 | + Always use a ``feature`` branch. It's good practice to never work on the ``master`` branch! |
| 49 | + |
| 50 | +4. Develop the feature on your feature branch. Add changed files using ``git add`` and then ``git commit`` files: |
| 51 | + |
| 52 | + ```bash |
| 53 | + $ git add modified_files |
| 54 | + $ git commit |
| 55 | + ``` |
| 56 | + |
| 57 | + to record your changes in Git, then push the changes to your GitHub account with: |
| 58 | + |
| 59 | + ```bash |
| 60 | + $ git push -u origin my-feature |
| 61 | + ``` |
| 62 | + |
| 63 | +5. Follow [these instructions](https://help.github.com/articles/creating-a-pull-request-from-a-fork) |
| 64 | +to create a pull request from your fork. |
| 65 | + |
| 66 | +### Running the Application and Tests |
| 67 | +See [README.md](README.md) for details on running the application with dependencies. |
| 68 | +The tests can be run using the standard `mvn test` command. |
| 69 | + |
| 70 | +### Code Structure and Dependencies |
| 71 | +This project uses the [Maven standard directory layout](https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) |
| 72 | +and is a [Model-view-controller](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) |
| 73 | +application built with [Spring Boot](https://projects.spring.io/spring-boot/). |
| 74 | + |
| 75 | +Packaging is done by feature and all Spring configuration is |
| 76 | +Java annotation based. |
| 77 | + |
| 78 | +Templates for the view use [Thymeleaf](http://www.thymeleaf.org/), |
| 79 | +which allows them to be displayed in browsers as static prototypes. |
| 80 | + |
| 81 | +MongoDB is used to store information about `Workflow` and `QueuedWorkflow` |
| 82 | +objects using [Spring Data JPA](https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/). |
| 83 | + |
| 84 | +The application also uses a triple store to keep the RDF representing |
| 85 | +workflows (gathered from [cwltool](https://github.com/common-workflow-language/cwltool)'s |
| 86 | +`--print-rdf` functionality). |
| 87 | + |
| 88 | +In general, the controller classes call services which have the main logic for |
| 89 | +the application. These controllers are: |
| 90 | +* `PageController` - handles basic static pages such as the index and documentation |
| 91 | +* `workflow.WorkflowController` - the main controller class for the application |
| 92 | +* `workflow.WorkflowJSONController` - handles API functionality |
| 93 | +* `workflow.PermalinkController` - handles permalinks with content negotiation for |
| 94 | +retrieving different formats |
| 95 | + |
| 96 | +Notable services include |
| 97 | +* `workflow.WorkflowService` - Handles workflow related functionality |
| 98 | +* `researchobject.ROBundleService` - Creates research object bundles |
| 99 | +* `graphviz.GraphVizService` - A wrapper for `com.github.jabbalaci.graphviz.GraphViz` |
| 100 | +to generate images from DOT source code |
| 101 | +* `git.GitService` - Builds on JGit to provide Git functionality |
| 102 | +* `cwl.CWLService` - Implements parsing of cwl files |
| 103 | + |
| 104 | +Note: For the async operations, Spring does not support the calling of a method within |
| 105 | +the same class (as a proxy needs to kick in to spawn a new thread). For this reason |
| 106 | +some extra classes such as `researchobject.ROBundleFactory` and `cwl.CWLToolRunner` |
| 107 | +are used when they would otherwise not be required. |
| 108 | + |
| 109 | +### Basic Application Flow |
| 110 | + |
| 111 | +1. User fills in the form on the front page. This is represented by |
| 112 | +`workflow.WorkflowForm` and consists of just a URL to Github/Gitlab, |
| 113 | +or a URL to a git repository as well as the branch and path of a |
| 114 | +workflow within the repository. |
| 115 | + |
| 116 | +2. This is submitted and picked up by a method in `workflow.WorkflowController`. |
| 117 | +The form is validated and parsed by `workflow.WorkflowFormValidator` to |
| 118 | +produce a `git.GitDetails` object with a repository URL, branch and path. |
| 119 | +The MongoDB database is checked for already pending `workflow.QueuedWorkflow` or |
| 120 | +created `workflow.Workflow` objects based on this (but this flow assumes they do |
| 121 | +not already exist). |
| 122 | + |
| 123 | +3. A new `workflow.QueuedWorkflow` object is created by cloning the repository |
| 124 | +locally (if it does not already exist), checking out the new branch and parsing |
| 125 | +the file using built-in YAML parsing code. Intermediate visualisations and |
| 126 | +models are produced which may not yet be complete. |
| 127 | + |
| 128 | +4. [cwltool](https://github.com/common-workflow-language/cwltool) is run on the |
| 129 | +workflow using the `--print-rdf` option to produce the RDF representation. The RDF |
| 130 | +will be stored in the SPARQL store and queries will extract the information |
| 131 | +required. Afterwards this is used to construct a Research Object Bundle for the workflow. |
| 132 | +This is an asynchronous operation so meanwhile... |
| 133 | + |
| 134 | +5. The user is redirected to the main workflow page, which will use the `loading` |
| 135 | +template for now until cwltool has finished running. The background is the intermediate |
| 136 | +visualisation. An AJAX call repeatedly checks the status of cwltool saved in the |
| 137 | +`workflow.QueuedWorkflow` object in MongoDB. |
| 138 | + |
| 139 | +6. The page either displays an error on the loading page or reloads to view the |
| 140 | + parsed workflow on the `workflow` template. An AJAX call checks if the Research Object |
| 141 | + Bundle has been created and adds it to the page when it has. |
0 commit comments