Skip to content

Commit

Permalink
feat: add feature page for github integration
Browse files Browse the repository at this point in the history
  • Loading branch information
sgfost committed Oct 4, 2024
1 parent 0bbd762 commit 5a356fb
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 11 deletions.
1 change: 1 addition & 0 deletions django/library/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def _create_org_repo(self):
org = github.get_organization(settings.GITHUB_MODEL_LIBRARY_ORG_NAME)
repo = org.create_repo(
name=self.repo_name,
description=f"Mirror of {self.codebase.get_absolute_url()}",
private=self.debug,
)
return repo
Expand Down
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 %}
9 changes: 2 additions & 7 deletions django/library/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,8 @@ def updated_after(self, start_date, end_date=None, **kwargs):

class CodebaseGitMirror(models.Model):
"""
# FIXME: should this manage both mirroring and syncing?
alt name ideas:
- CodebaseGithubIntegration
- CodebaseGitRepository
mirror makes sense if this is only responsible for the mirroring (1-way workflow)
model to keep track of the state of a git repository for a codebase
Keeps track of a git repository and its GitHub remote that were created
from a Codebase using the mirror (read-only archiving) workflow
"""

# is_active = models.BooleanField(default=True)
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
2 changes: 1 addition & 1 deletion django/library/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ class ContributorList(generics.ListAPIView):


class CCLicenseChangeView(LoginRequiredMixin, FormView):
template_name = "library/cc_license_change.jinja"
template_name = "library/cc-license-change.jinja"
form_class = Form # just a confirmation form, we don't need any fields
success_message = "Licenses updated successfully."

Expand Down
22 changes: 19 additions & 3 deletions frontend/src/components/GithubMirrorModal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div>
<button class="btn btn-sm btn-primary my-1 w-100" rel="nofollow" @click="modal?.show()">
<button class="btn btn-sm btn-secondary my-1 w-100" rel="nofollow" @click="modal?.show()">
<i class="fab fa-github"></i>
Mirror on Github
</button>
<BootstrapModal
Expand All @@ -10,6 +11,13 @@
centered
>
<template #body>
<p>
This will transform your model into a git repository and archive it on GitHub under a
central CoMSES Model Library organization.
<a href="/github" target="_blank"
>Learn more <i class="small fas fa-chevron-right"></i
></a>
</p>
<form @submit="handleSubmit" id="github-mirror-form">
<TextField class="mb-3" name="repoName" label="Repository Name" required />
<FormAlert :validation-errors="Object.values(errors)" :server-errors="serverErrors" />
Expand All @@ -21,7 +29,15 @@
</template>
<template #footer>
<button type="button" data-bs-dismiss="modal" class="btn btn-outline-gray">Cancel</button>
<button type="submit" form="github-mirror-form" class="btn btn-primary">Mirror</button>
<button
type="submit"
form="github-mirror-form"
class="btn btn-primary"
:disabled="isLoading"
>
<span v-if="isLoading"> <i class="fas fa-spinner fa-spin me-1"></i> Loading...</span>
<span v-else>Create Mirror</span>
</button>
</template>
</BootstrapModal>
</div>
Expand Down Expand Up @@ -51,7 +67,7 @@ const schema = yup.object().shape({
});
type GithubMirrorModalFields = yup.InferType<typeof schema>;
const { serverErrors, githubMirror, data: successMessage } = useCodebaseAPI();
const { serverErrors, githubMirror, data: successMessage, isLoading } = useCodebaseAPI();
const { errors, handleSubmit, values } = useForm<GithubMirrorModalFields>({
schema,
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/scss/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,22 @@ nav {
}
}

.card-bridge::before {
content: "";
position: absolute;
top: 0;
bottom: -100px;
left: 50%;
width: 1px;
background-color: #ccc;
z-index: -1;
}

.card-bridge .card {
position: relative;
z-index: 1;
}

.card-metadata {
@extend .card;
margin-top: 0.5em;
Expand Down

0 comments on commit 5a356fb

Please sign in to comment.