Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ tool_category:
Small Angle Neutron Scattering: small-angle-neutron-scattering
Triple-Axis Spectroscopy: spectroscopy

git_remote:
type: str
help: Provide your git remote URL (if not the default, then you will need to email ndip@ornl.gov for help setting up secrets)
default: "https://code.ornl.gov/ndip/tool-sources/{{ tool_category }}/{{ project_name.lower().replace(' ', '-').replace('_', '-') }}"

# --- Nova Application Specific ---
# Implicitly GUI if Nova Application is chosen.
framework:
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/.cli-copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Please do not edit or delete this file. It is needed to be able to update project from template.
application_type: Command-line tool
git_remote: https://code.ornl.gov/ndip/tool-sources/generic/cli-tool
project_name: CLI Tool
python_package: cli-tool
tool_category: generic
1 change: 1 addition & 0 deletions dockerfiles/.library-copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Please do not edit or delete this file. It is needed to be able to update project from template.
application_type: Library
git_remote: https://code.ornl.gov/ndip/tool-sources/generic/library
project_name: Library
publish_docs: true
publish_to_pypi: true
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/.minimal-copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Please do not edit or delete this file. It is needed to be able to update project from template.
application_type: Minimal
git_remote: https://code.ornl.gov/ndip/tool-sources/generic/minimal
project_name: minimal
tool_category: generic
1 change: 1 addition & 0 deletions dockerfiles/.ndip-tool-copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Please do not edit or delete this file. It is needed to be able to update project from template.
application_type: NDIP Tool
git_remote: https://code.ornl.gov/ndip/tool-sources/generic/ndip_tool
project_name: ndip_tool
python_package: ndip_tool
tool_category: generic
1 change: 1 addition & 0 deletions dockerfiles/.nova-application-copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Please do not edit or delete this file. It is needed to be able to update project from template.
application_type: Nova Application
framework: Trame
git_remote: https://code.ornl.gov/ndip/tool-sources/generic/nova_application
multitabs: true
project_name: nova_application
python_package: nova_application
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/.tutorial-copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Please do not edit or delete this file. It is needed to be able to update project from template.
application_type: Tutorial
framework: Trame
git_remote: https://code.ornl.gov/ndip/tool-sources/generic/tutorial
multitabs: true
project_name: Tutorial
python_package: tutorial
Expand Down
71 changes: 71 additions & 0 deletions template_sources/.github/workflows/build-test.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Test

on: push

concurrency:
group: "{% raw %}${{ github.ref }}{% endraw %}"
cancel-in-progress: true

env:
NDIP_DOCKER_REPOSITORY: "{% raw %}${{ secrets.NDIP_DOCKER_REPOSITORY }}{% endraw %}"

jobs:
build-and-test:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
GIT_STRATEGY: clone
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 20
lfs: true
- name: Build
uses: docker/build-push-action@v6
id: build
with:
file: dockerfiles/Dockerfile
load: true
target: source
- name: Run ruff check
run: docker run --rm {% raw %}${{ steps.build.outputs.imageid }}{% endraw %} ruff check
- name: Run format check
run: docker run --rm {% raw %}${{ steps.build.outputs.imageid }}{% endraw %} ruff format --check
- name: Run mypy
run: docker run --rm {% raw %}${{ steps.build.outputs.imageid }}{% endraw %} mypy .
- name: Unit tests
run: docker run --rm {% raw %}${{ steps.build.outputs.imageid }}{% endraw %} pytest
- name: Run coverage
run: docker run --rm {% raw %}${{ steps.build.outputs.imageid }}{% endraw %} sh -c "coverage run && coverage report"
- name: Docs test
run: docker run --rm {% raw %}${{ steps.build.outputs.imageid }}{% endraw %} bash build_docs.sh

publish-prototype:
runs-on: ubuntu-latest
env:
IMAGE_NAME: savannah.ornl.gov/ndip/tool-sources/{{ tool_category }}/{% include 'name_slug.j2' %}/prototypes
permissions: write-all
steps:
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: {% raw %}${{ secrets.NDIP_DOCKER_REGISTRY }}{% endraw %}
username: {% raw %}${{ secrets.NDIP_DOCKER_USER }}{% endraw %}
password: {% raw %}${{ secrets.NDIP_DOCKER_PASSWORD }}{% endraw %}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout repo
uses: actions/checkout@v4
- name: Build and push
uses: docker/build-push-action@v6
with:
file: dockerfiles/Dockerfile
push: true
tags: {% raw %}${{ env.IMAGE_NAME }}:${{ github.sha }}{% endraw %}
56 changes: 56 additions & 0 deletions template_sources/.github/workflows/release-version.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release Image

on:
workflow_dispatch:

jobs:
tag-release:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions: write-all
env:
GIT_STRATEGY: clone
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 20
lfs: true
- name: Parse version
run: {% raw %}echo "VERSION=$(cat pyproject.toml | grep "version =" | head -n 1 | awk '{ print $3 }' | tr -d '"')" >> $GITHUB_ENV{% endraw %}
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
with:
tag_name: {% raw %}${{ env.VERSION }}{% endraw %}
release_name: {% raw %}${{ env.VERSION }}{% endraw %}

publish-release:
runs-on: ubuntu-latest
env:
IMAGE_NAME: savannah.ornl.gov/ndip/tool-sources/{{ tool_category }}/{% include 'name_slug.j2' %}
permissions: write-all
steps:
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: {% raw %}${{ secrets.NDIP_DOCKER_REGISTRY }}{% endraw %}
username: {% raw %}${{ secrets.NDIP_DOCKER_USER }}{% endraw %}
password: {% raw %}${{ secrets.NDIP_DOCKER_PASSWORD }}{% endraw %}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout repo
uses: actions/checkout@v4
- name: Parse version
run: echo "VERSION=$(cat pyproject.toml | grep "version =" | head -n 1 | awk '{ print $3 }' | tr -d '"')" >> $GITHUB_ENV
- name: Check image already exists
run: if [ -n "$(docker manifest inspect {% raw %}${{ env.IMAGE_NAME }}:${{ env.VERSION }}{% endraw %})" ]; then echo "Image already exists, update the version and try again." && exit 1; fi
- name: Build and push
uses: docker/build-push-action@v6
with:
file: dockerfiles/Dockerfile
push: true
tags: {% raw %}${{ env.IMAGE_NAME }}:latest,${{ env.IMAGE_NAME }}:${{ env.VERSION }}{% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TOOL_CATEGORY="{{ tool_category }}"
PROJECT_NAME_RAW="{{ project_name }}"
# Slugify project name for URL (lowercase, replace space/underscore with dash)
PROJECT_SLUG=$(echo "$PROJECT_NAME_RAW" | tr '[:upper:]' '[:lower:]' | sed 's/[ _]/-/g')
REMOTE_URL="https://code.ornl.gov/ndip/tool-sources/${TOOL_CATEGORY}/${PROJECT_SLUG}"
REMOTE_URL="{{ git_remote }}"
INITIAL_COMMIT_MSG="Initial commit from NOVA Application Template (Minimal)"

# --- Functions ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def init_repository() -> None:
This function will:
- Initialize a git repository if one doesn't exist.
- Set the default branch to 'main'.
- Add or update the 'origin' remote to point to the GitLab repository:
https://code.ornl.gov/ndip/tool-sources/{{ tool_category }}/{{ project_name.lower().replace(' ', '-').replace('_', '-') }}
- Add or update the 'origin' remote to point to the GitLab repository: {{ git_remote }}
- Stage all files.
- Create an initial commit if no commits exist.

Expand All @@ -22,8 +21,7 @@ def init_repository() -> None:
try:
# Determine repository path
# We need to organize the groups under tool sources and provide them an option of location
remote_url = "https://code.ornl.gov/ndip/tool-sources/{{ tool_category }}/"
remote_url += "{{ project_name.lower().replace(' ', '-').replace('_', '-') }}"
remote_url = "{{ git_remote }}"

# --- Confirmation Step ---
print("\n--- Git Repository Setup Plan ---")
Expand Down
2 changes: 1 addition & 1 deletion template_sources/xml/tool.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

This is a Galaxy tool for {{ project_name }}.

For more information, see the repository: https://code.ornl.gov/ndip/tool-sources/{{ tool_category }}/{{ project_name.lower().replace(' ', '-').replace('_', '-') }}
For more information, see the repository: {{ git_remote }}
]]></help>
</tool>
Loading