Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bazel rules for C# packaging, distribution and documentation #406

Merged
merged 20 commits into from
Apr 4, 2024

Conversation

farost
Copy link
Member

@farost farost commented Apr 3, 2024

What is the goal of this PR?

We prepare tools for the C# driver release, namely: documentation, packaging, and distribution.

What are the changes implemented in this PR?

Added:
Rules for the C# nuget packages generation and distribution. These rules are based on the rules from the open source Selenium repo, so thanks to them for boosting the development by making it available! They are used and tested in the typedb-driver project:

  • nuget_pack: gets a list of C# libraries, native libs files (if needed), a template nuget project description, a list of files to include into the package (for example, README or logos), and produces two files: nupkg (nuget package) and snupkg (symbol package for debugging).
  • nuget_push: receives the result of the previous command and pushes the packages (with their symbols) to the target (snapshot/release) repo.

Updated:

  • doxygen configuration, previously used solely for C++. Now it's also convenient for C#, so some refactoring and additions happened.

@typedb-bot
Copy link
Member

typedb-bot commented Apr 3, 2024

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

  • This change is trivial and does not require a code or architecture review.

Code

  • Packages, classes, and methods have a single domain of responsibility.
  • Packages, classes, and methods are grouped into cohesive and consistent domain model.
  • The code is canonical and the minimum required to achieve the goal.
  • Modules, libraries, and APIs are easy to use, robust (foolproof and not errorprone), and tested.
  • Logic and naming has clear narrative that communicates the accurate intent and responsibility of each module (e.g. method, class, etc.).
  • The code is algorithmically efficient and scalable for the whole application.

Architecture

  • Any required refactoring is completed, and the architecture does not introduce technical debt incidentally.
  • Any required build and release automations are updated and/or implemented.
  • Any new components follows a consistent style with respect to the pre-existing codebase.
  • The architecture intuitively reflects the application domain, and is easy to understand.
  • The architecture has a well-defined hierarchy of encapsulated components.
  • The architecture is extensible and scalable.

#---------------------------------------------------------------------------
# Configuration options related to optional content included to the output
#---------------------------------------------------------------------------
EXTRACT_STATIC = YES
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't affect the C++ documentation (as it doesn't have docs for static classes -> doesn't need it) but is needed for the C# docs.

@@ -26,7 +26,7 @@ def _doxygen_docs_impl(ctx):
files.extend(target.files.to_list())

replacements = {
"PROJECT_NAME": ctx.attr.project_name,
"PROJECT_NAME": '"' + ctx.attr.project_name + '"',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to scale from just cpp to cpp + csharp.

# specific language governing permissions and limitations
# under the License.

# This file is based on the original implementation of https://github.com/SeleniumHQ/selenium/.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things are just stolen (like dotnet_preamble and many main ideas), and some things that I'll highlight further are modified. https://github.com/SeleniumHQ/selenium/. They have an Apache-2.0 license.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put accredetation in the PR description :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what accreditation means in this context, but I've mentioned Selenium in the PR =) Hope it's what you was looking for

return version


def _nuget_pack_impl(ctx):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially taken from here, but this version has many small modifications.


def _nuget_pack_impl(ctx):
version = _parse_version(ctx)
nuspec = ctx.actions.declare_file("{}-generated.nuspec".format(ctx.label.name))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We create a .nuspec-file (declaration of a nuget project) based on the given template.


package_name = "{}{}".format(ctx.attr.id, platform_suffix)

if ctx.files.native_libs:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we add native dynamic libs references to the template (needed for the runtime lib).

@farost
Copy link
Member Author

farost commented Apr 3, 2024

Copy link
Member

@flyingsilverfin flyingsilverfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic!

# specific language governing permissions and limitations
# under the License.

# This file is based on the original implementation of https://github.com/SeleniumHQ/selenium/.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put accredetation in the PR description :)

@farost farost merged commit 5e8c09d into typedb:development Apr 4, 2024
1 check passed
@farost farost changed the title Add Bazel rules for C# packaging, distribution and documentation. Add Bazel rules for C# packaging, distribution and documentation Apr 4, 2024
@farost farost mentioned this pull request Apr 4, 2024
flyingsilverfin pushed a commit that referenced this pull request Apr 4, 2024
We fixed the build issues with the doc target, that appeared because of
the `cpp` dir renaming in[ the previous
PR](#406), and some
code style in the meantime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants