Skip to content

Commit

Permalink
[Improvement][DevInfra] Reorg the code directory to easily to extend …
Browse files Browse the repository at this point in the history
…libraries (#116)
  • Loading branch information
acezen authored Mar 9, 2023
1 parent 9702e12 commit b124402
Show file tree
Hide file tree
Showing 80 changed files with 434 additions and 223 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GraphAr CI
name: GraphAr C++ CI

on:
# Trigger the workflow on push or pull request,
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
run: |
mkdir build
pushd build
cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON
cmake ../cpp -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON
popd
- name: Cpp Format and lint
Expand All @@ -67,7 +67,7 @@ jobs:
# validate format
function prepend() { while read line; do echo "${1}${line}"; done; }
make clformat
make gar-clformat
GIT_DIFF=$(git diff --ignore-submodules)
if [[ -n $GIT_DIFF ]]; then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
Expand All @@ -91,7 +91,7 @@ jobs:
function ec() { [[ "$1" == "-h" ]] && { shift && eval $* > /dev/null 2>&1; ec=$?; echo $ec; } || eval $*; ec=$?; }
ec make cpplint
ec make gar-cpplint
if [[ "$ec" != "0" ]]; then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "| cpplint failures found! Run: "
Expand All @@ -114,5 +114,7 @@ jobs:
- name: Test
run: |
cd build && make test
cd build
export GAR_TEST_DATA=$PWD/../testing/
make test
8 changes: 3 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ jobs:
run: |
sudo apt-get update -y
sudo apt-get install -y ca-certificates cmake doxygen python3-pip
sudo pip3 install -r requirements-dev.txt
sudo pip3 install -r docs/requirements.txt
- name: Generate Doc
run: |
mkdir build
pushd build
cmake ..
make doc
pushd docs
make html
popd
- name: Preview using surge
Expand Down
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
/build/
spark/target/
.vscode
.idea
.DS_store
.DS_Store
.cache

# docs
/docs/_build/

# examples
/examples/*/build


12 changes: 6 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "test/gar-test"]
path = test/gar-test
[submodule "testing"]
path = testing
url = https://github.com/GraphScope/gar-test.git
[submodule "thirdparty/yaml-cpp"]
path = thirdparty/yaml-cpp
[submodule "cpp/thirdparty/yaml-cpp"]
path = cpp/thirdparty/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git
[submodule "thirdparty/Catch2"]
path = thirdparty/Catch2
[submodule "cpp/thirdparty/Catch2"]
path = cpp/thirdparty/Catch2
url = https://github.com/catchorg/Catch2.git
70 changes: 43 additions & 27 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ into the Git repository, you could first install `pre-commit`_ by

.. code:: bash
pip3 install pre-commit
$ pip3 install pre-commit
The configure the necessary pre-commit hooks with

.. code:: bash
pre-commit install --install-hooks
$ pre-commit install --install-hooks
Minor Fixes
^^^^^^^^^^^^
Expand All @@ -86,7 +86,7 @@ A good branch name would be (where issue #42 is the ticket you're working on):

.. code:: shell
git checkout -b 42-add-chinese-translations
$ git checkout -b 42-add-chinese-translations
Get the test suite running
^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -97,22 +97,33 @@ Now initialize the submodules of GraphAr:

.. code:: shell
git submodule update --init
$ git submodule update --init
For the C++ Library, Check that the system has the `GraphAr C++ Dependencies`_.

Then you can do an out-of-source build using CMake and build the test suite:

.. code:: shell
mkdir build
cd build
cmake .. -DBUILD_TESTS=ON
make -j$(nproc)
$ mkdir build
$ cd build
$ cmake ../cpp -DBUILD_TESTS=ON
$ make -j$(nproc)
Now you should be able to run the test suite:

.. code:: shell
make test
$ make test
For the Spark Library, Check that the system has the `GraphAr Spark Dependencies`_.

Then you build and run test suite using Maven:

.. code:: shell
$ cd spark
$ mvn test
How to generate the document
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -123,9 +134,10 @@ The documentation is generated using Doxygen and sphinx. You can build GraphAr's

.. code:: shell
make doc
$ cd docs
$ make html
The HTML documentation will be available under `docs/_build/html`.
The HTML documentation will be available under ``docs/_build/html``.

Implement your fix or feature
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -143,13 +155,15 @@ You can format your code by the command:

.. code:: shell
make clformat
$ cd build
$ make gar-clformat
You can check & fix style issues by running the *cpplint* linter with the command:

.. code:: shell
make cpplint
$ cd build
$ make gar-cpplint
Submitting your changes
^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -173,17 +187,17 @@ up to date with GraphAr's main branch:

.. code:: shell
git remote add upstream https://github.com/alibaba/GraphAr.git
git checkout main
git pull upstream main
$ git remote add upstream https://github.com/alibaba/GraphAr.git
$ git checkout main
$ git pull upstream main
Then update your feature branch from your local copy of main, and push it!

.. code:: shell
git checkout 42-add-chinese-translations
git rebase main
git push --set-upstream origin 42-add-chinese-translations
$ git checkout 42-add-chinese-translations
$ git rebase main
$ git push --set-upstream origin 42-add-chinese-translations
Finally, go to GitHub and `make a Pull Request`_ :D

Expand All @@ -206,9 +220,9 @@ To learn more about rebasing in Git, there are a lot of `good <http://git-scm.co

.. code:: shell
git checkout 42-add-chinese-translations
git pull --rebase upstream main
git push --force-with-lease 42-add-chinese-translations
$ git checkout 42-add-chinese-translations
$ git pull --rebase upstream main
$ git push --force-with-lease 42-add-chinese-translations
Feel free to post a comment in the pull request to ping reviewers if you are awaiting an answer
on something. If you encounter words or acronyms that seem unfamiliar, refer to this `glossary`_.
Expand Down Expand Up @@ -236,15 +250,15 @@ Maintainers need to do the following to push out a release:

.. code:: shell
git checkout main
git pull upstream main
$ git checkout main
$ git pull upstream main
2. Tag the release with a version number and push it to GitHub. Note that the version number should follow `semantic versioning <https://semver.org/#summary>`_. e.g.: v0.1.0.

.. code:: shell
git tag -a v0.1.0 -m "GraphAr v0.1.0"
git push upstream v0.1.0
$ git tag -a v0.1.0 -m "GraphAr v0.1.0"
$ git push upstream v0.1.0
3. The release draft will be automatically built to GitHub by GitHub Actions. You can edit the release notes draft on `GitHub <https://github.com/alibaba/GraphAr/releases>`_ to add more details.
4. Publish the release.
Expand Down Expand Up @@ -419,7 +433,9 @@ to determine whether the failure was caused by the changes in the pull request.

.. _interactive rebase: https://help.github.com/en/github/using-git/about-git-rebase

.. _GraphAr Dependencies: https://github.com/alibaba/GraphAr#dependencies
.. _GraphAr C++ Dependencies: https://github.com/alibaba/GraphAr/tree/main/cpp#system-setup

.. _GraphAr Spark Dependencies: https://github.com/alibaba/GraphAr/tree/main/spark#system-setup

.. _Contributor License Agreement: https://cla-assistant.io/alibaba/GraphAr

Expand Down
80 changes: 12 additions & 68 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,77 +111,19 @@ Take the "person knows person" edges to illustrate. Suppose the vertex chunk siz
|Edge Physical Table2|


Building the Libraries
----------------------
Libraries
----------

Libraries are available for C++ and Spark.

Prerequisites
^^^^^^^^^^^^^^

Basic dependencies:

- A modern C++ compiler compliant with C++17 standard (g++ >= 7.1 or clang++ >= 5).
- `CMake <https://cmake.org/>`_ (>=2.8)

Dependencies for optional features:

- `Doxygen <https://www.doxygen.nl/index.html>`_ (>= 1.8) for generating documentation;
- `sphinx <https://www.sphinx-doc.org/en/master/index.html>`_ for generating documentation.

Extra dependencies are required by examples:

- `BGL <https://www.boost.org/doc/libs/1_80_0/libs/graph/doc/index.html>`_ (>= 1.58).


Building
^^^^^^^^^

Once the required dependencies have been installed, go to the root directory of GraphAr and do an out-of-source build using CMake.

.. code-block:: shell
git submodule update --init
mkdir build && cd build
cmake ..
make -j$(nproc)
**Optional**: Using a Custom Namespace

The :code:`namespace` is configurable. By default,
it is defined in :code:`namespace GraphArchive`; however this can be toggled by
setting :code:`NAMESPACE` option with cmake:

.. code:: shell
mkdir build
cd build
cmake .. -DNAMESPACE=MyNamespace
make -j$(nproc)
Run the test with command:

.. code-block:: shell
make test
Install the GraphAr library:

.. code-block:: shell
sudo make install
Optionally, you can build the documentation for GraphAr library:

.. code-block:: shell
# assume doxygen and sphinx has been installed.
pip3 install -r ../requirements-dev.txt --user
make doc
Libraries are provided for reading, writing and transforming files in GraphAr,
now the C++ library and the Spark library are available. And we are going to
provide libraries for more programming languages.

The C++ Library
^^^^^^^^^^^^^^^
See `GraphAr C++ Library`_ for details about the building of the C++ library.

The Spark Library
-----------------
^^^^^^^^^^^^^^^^^

See `GraphAr Spark Library`_ for details about the Spark library.

Expand Down Expand Up @@ -239,7 +181,9 @@ third-party libraries may not have the same license as GraphAr.

.. _GraphAr File Format: https://alibaba.github.io/GraphAr/user-guide/file-format.html

.. _GraphAr Spark Library: https://alibaba.github.io/GraphAr/user-guide/spark-lib.html
.. _GraphAr Spark Library: https://github.com/alibaba/GraphAr/tree/main/spark

.. _GraphAr C++ Library: https://github.com/alibaba/GraphAr/tree/main/cpp

.. _example files: https://github.com/GraphScope/gar-test/blob/main/ldbc_sample/

Expand Down
5 changes: 5 additions & 0 deletions cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/build/
/examples/*/build/

apidoc/html
apidoc/xml
Loading

0 comments on commit b124402

Please sign in to comment.