Skip to content

Commit

Permalink
feat: github integration ui and mirroring feature
Browse files Browse the repository at this point in the history
* /github page to describe the integration features
* sidebar element on release detail page will show information about
  integration status for that codebase, and allow users with edit
  permissions to create a new mirror
  • Loading branch information
sgfost committed Jan 9, 2025
1 parent 10f0f27 commit b25ba7b
Show file tree
Hide file tree
Showing 10 changed files with 489 additions and 3 deletions.
56 changes: 56 additions & 0 deletions django/library/jinja2/library/codebases/releases/retrieve.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,61 @@
{% endif %}
{% endwith %}

{% if codebase.git_mirror or has_change_perm %}
<div class="card-metadata">
<div class="card-body">
<div class="section mb-0">
<div>
<b class="card-title">
<i class="fab fa-github"></i>
Github Integration
</b>
<sup class="badge bg-gray"><small>beta</small></sup>
</div>

{% if codebase.git_mirror %}
{% if codebase.git_mirror.remote_url %}
<div class="d-flex align-items-center pt-1">
<a href="{{ codebase.git_mirror.remote_url }}" class="d-block text-truncate" target="_blank">
<span class='badge bg-info'>
{{ codebase.git_mirror.repository_name }}
<i class="fas fa-external-link-alt"></i>
</span>
</a>
</div>
{% else %}
<div class="alert alert-info mb-0">
<small>
<p>
Mirroring in progress. This may take a few seconds.
</p>
<a href=".">Refresh this page.</a>
</small>
</div>
{% endif %}
{% elif has_change_perm %}
{% if codebase.live %}
<div
id="github-mirror"
data-identifier="{{ codebase.identifier }}"
data-default-repo-name="{{ slugify(codebase.title) }}"
></div>
{% else %}
<div class="card-text">
Only available for published models
</div>
{% endif %}
{% endif %}
<div class="card-text">
<a class="small" href="/github/" target="_blank">
<i class="fas fa-question-circle"></i> What is this?
</a>
</div>
</div>
</div>
</div>
{% endif %}

<div class="card-metadata">
<div class="card-body">
<div class="section">
Expand Down Expand Up @@ -572,5 +627,6 @@
{{ vite_asset("apps/release_download.ts") }}
{% if has_change_perm %}
{{ vite_asset("apps/release_regenerate_share_uuid.ts") }}
{{ vite_asset("apps/github_mirror.ts") }}
{% endif %}
{% endblock %}
234 changes: 234 additions & 0 deletions django/library/jinja2/library/github-integration-overview.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{% extends "base.jinja" %}

{% block introduction %}
<h1>Computational Model Library Github Integration</h1>
{% endblock %}

{% block content %}
<div class="container">
<div class="row justify-content-center">
<div class="col-6 position-relative card-bridge">
<div class="card mb-5">
<div class="card-body">
<div class="d-flex justify-content-between">
<h2 class="card-title">Mirroring</h2>
<h2 class="card-title">
<i class="fas fa-arrow-up"></i>
</h2>
</div>
<p class="card-text">
Mirroring transforms your model into a git repository and archives it on GitHub under the
<a href="https://github.com/orgs/{{ github_model_library_org_name }}/repositories"
target="_blank">
{{ github_model_library_org_name }}</a> organization.
</p>
<p class="card-text">
Get started by clicking the <span class="badge bg-secondary"><i class="fab fa-github"></i>
Mirror on GitHub</span> button on
one of your models.
</p>
</div>
</div>
</div>
<div class="col-6 position-relative card-bridge">
<div class="card mb-5 bg-light">
<div class="card-body">
<div class="d-flex justify-content-between">
<h2 class="card-title">Syncing (coming soon!)</h2>
<h2 class="card-title">
<i class="fas fa-sync-alt small"></i>
</h2>
</div>
<p class="card-text opacity-50">
Syncing will allow you to develop your model on GitHub and have any new releases
pulled back into the CoMSES Model Library.

</p>
<p class="card-text opacity-50">
Start from either a model on CoMSES or an existing GitHub repository.
</p>
</div>
</div>
</div>
</div>

<div class="row justify-content-center">
<h2 class="text-center mb-4">How It Works</h2>
<div class="col-6 position-relative card-bridge">
<div class="card mb-5 ">
<ul class="list-group list-group-flush">
<li class="list-group-item d-flex">
<i class="fas fa-code-branch pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Published model releases are transformed into commits
and releases on GitHub, preserving your project's history and versioning.
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-user pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
The original submitter is set as the commit
author, maintaining attribution.
<p class="text-muted small mb-0">
{% if not user.is_authenticated %}
We will use a connected Github account or your profile information to sign commits.
You can
connect
your Github account by editing your profile if you want it to appear as the author
of the
commits.
{% elif user.member_profile.github_username %}
Since you have a connected Github account, we will use it to sign commits:
<code>{{ user.member_profile.github_username }} &lt;{{ user.member_profile.github_username }}@users.noreply.github.com&gt;</code>
{% else %}
Since you do not have a github account connected we will use your profile
information:
<code>{{ user.member_profile.name }} &lt;{{ user.email }}&gt;</code>
{% endif %}
</p>
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-tags pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Metadata is preserved by adding to the GitHub repo where possible and stored in
versioned
<a href="https://codemeta.github.io/"><code>codemeta.json</code></a>,
<a
href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository"><code>LICENSE</code></a>,
and <a href="https://citation-file-format.github.io/"><code>CITATION.cff</code></a> files.
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-sync-alt pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Each time a new release is published on the Model Library, the GitHub repository is
updated automatically.
</div>
</li>
</ul>
</div>
</div>
<div class="col-6 position-relative card-bridge">
<div class="card mb-5 bg-light">
<ul class="list-group list-group-flush opacity-25">
<li class="list-group-item d-flex">
<i class="fas fa-address-card pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
When enabled on a CoMSES model, the model is transformed into a git repository
with the <b>same process as mirroring</b> but the repository will be created under your
GitHub account.
</div>
</li>
<li class="list-group-item d-flex">
<i class="fab fa-github pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Alternatively, you can start from an existing GitHub repository and import it into
the Model Library.
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-rocket pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
When you are ready to publish a new release, update the software's metadata
and create a new release on GitHub. The Model Library will automatically pull in the
new release.
</div>
</li>
</ul>
</div>
</div>
</div>

<div class="row justify-content-center">
<h2 class="text-center mb-4">Benefits</h2>
<div class="col-6 position-relative card-bridge">
<div class="card mb-5">
<ul class="list-group list-group-flush">
<li class="list-group-item d-flex">
<i class="fas fa-check pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Automatically transition your model codebase to the most commonly used
version control system
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-check pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Provide better access to your model's source with GitHub's code browser
</div>
</li>
</ul>
</div>
</div>
<div class="col-6 position-relative card-bridge">
<div class="card mb-5 bg-light">
<ul class="list-group list-group-flush opacity-25">
<li class="list-group-item d-flex">
<i class="fas fa-check pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Collaborate with other researchers using GitHub's rich collaboration and project
management environment
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-check pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Take advantage of tools available as <a href="https://github.com/marketplace">GitHub apps
and actions</a>
</div>
</li>
</ul>
</div>
</div>
</div>

<div class="row justify-content-center">
<h2 class="text-center mb-4">Limitations</h2>
<div class="col-6 position-relative">
<div class="card mb-5">
<ul class="list-group list-group-flush">
<li class="list-group-item d-flex">
<i class="fas fa-exclamation-triangle pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Individual files cannot exceed 100MB
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-exclamation-triangle pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Mirrored repositories are <b>read-only</b>, though you are free to <a
href="https://docs.github.com/articles/fork-a-repo">fork</a> them
</div>
</li>
</ul>
</div>
</div>
<div class="col-6 position-relative">
<div class="card mb-5 bg-light">
<ul class="list-group list-group-flush opacity-25">
<li class="list-group-item d-flex">
<i class="fas fa-exclamation-triangle pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Individual files cannot exceed 100MB
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-exclamation-triangle pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Required metadata must be present in order to pull in new releases from GitHub
</div>
</li>
<li class="list-group-item d-flex">
<i class="fas fa-exclamation-triangle pt-1" style="width: 1rem"></i>
<div class="ps-3 flex-grow-1">
Changes cannot be made to the CoMSES Model Library record when there are conflicting
changes on GitHub
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
7 changes: 6 additions & 1 deletion django/library/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ def _convert_release(cls, release) -> CodeMeta:
name=codebase.title,
# FIXME: is this semantically correct?
# isPartOf=COMSES_MODEL_LIBRARY_CREATIVE_WORK,
codeRepository=codebase.repository_url or None,
codeRepository=(
codebase.git_mirror.remote_url
if codebase.git_mirror
else codebase.repository_url
)
or None,
programmingLanguage=[
# FIXME: this can include "version" when langs are refactored
{"@type": "ComputerLanguage", "name": pl.name}
Expand Down
10 changes: 10 additions & 0 deletions django/library/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
)

urlpatterns = [
path(
"github/",
TemplateView.as_view(
template_name="library/github-integration-overview.jinja",
extra_context={
"github_model_library_org_name": settings.GITHUB_MODEL_LIBRARY_ORG_NAME,
},
),
name="github-integration-overview",
),
path(
"reviews/",
TemplateView.as_view(template_name="library/review/peer-review-overview.jinja"),
Expand Down
Loading

0 comments on commit b25ba7b

Please sign in to comment.