Commit dcf97f1d authored by Duggan, John's avatar Duggan, John
Browse files

Initial commit from NOVA Application Template

parents
Loading
Loading
Loading
Loading
Loading

.copier-answers.yml

0 → 100644
+10 −0
Original line number Diff line number Diff line
# Please do not edit or delete this file. It is needed to be able to update project from template.
_commit: '0.39'
_src_path: https://code.ornl.gov/ndip/project-templates/nova-application-template.git
application_type: Nova Application
framework: Trame
multitabs: true
project_name: IPS Fastran GUI
python_package: ips-fastran-gui
tool_category: fusion
use_mantid: false

.dockerignore

0 → 100644
+7 −0
Original line number Diff line number Diff line
dockerfiles/Dockerfile
.pixi
.mypy_cache
.pytest_cache
.ruff_cache
.vscode
.env

.gitignore

0 → 100644
+169 −0
Original line number Diff line number Diff line
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
#   For a library or package, you might want to ignore these files since the code is
#   intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# poetry
#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
#   This is especially recommended for binary packages to ensure reproducibility, and is more
#   commonly ignored for libraries.
#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# Pixi
.pixi

# pdm
#   Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
#   pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
#   in version control.
#   https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
#  We ingore the whole .idea folder
#  For more fine tuning, JetBrains specific template is maintained in a separate JetBrains.gitignore that can
#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
#  and can be added to the global gitignore or merged into this file.
.idea


.envrc


junit.xml

.gitlab-ci.yml

0 → 100644
+158 −0
Original line number Diff line number Diff line
workflow:
  rules:
    - if: $CI_COMMIT_TAG
      when: never
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: never
    - when: always

stages:
  - lint
  - test
  - tag
  - build-prototype
  - publish

variables:
  GIT_STRATEGY: clone
  IMAGE_NAME: ${NDIP_DOCKER_REPOSITORY}/${CI_PROJECT_PATH}
  PROTOTYPE_IMAGE_DESTINATION: ${NDIP_DOCKER_REPOSITORY}/${CI_PROJECT_PATH}/prototypes

before_script:
  - curl https://code.ornl.gov/rse-deployment/rse-sharables/raw/master/rse-bash-modules.sh -O
  - source rse-bash-modules.sh
  - func_rse_docker_cleanup
  - docker login -u $NDIP_DOCKER_USER -p $NDIP_DOCKER_PASSWORD $NDIP_DOCKER_REPOSITORY
  - export VERSION=$(cat pyproject.toml | grep "version =" | head -n 1 | awk '{ print $3 }' | tr -d '"')
  

after_script:
  - curl https://code.ornl.gov/rse-deployment/rse-sharables/raw/master/rse-bash-modules.sh -O
  - source rse-bash-modules.sh
  - func_rse_docker_cleanup

lint-check:
  stage: lint
  script:
    - docker build -f dockerfiles/Dockerfile --target source -t image .
    - docker run -u `id -u`:`id -g` image poetry run ruff check
    - docker run -u `id -u`:`id -g` image poetry run ruff format --check
    - docker run -u `id -u`:`id -g` image poetry run mypy .
    - docker tag image ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
    - docker push ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
  tags:
    - rse-multi-builder


unit-tests:
  stage: test
  script:
    - mkdir reports
    - docker run -u `id -u`:`id -g` -v `pwd`/reports:/src/reports ${IMAGE_NAME}:src-${CI_COMMIT_SHA} poetry run coverage run
    - docker run -u `id -u`:`id -g` -v `pwd`/reports:/src/reports ${IMAGE_NAME}:src-${CI_COMMIT_SHA} poetry run coverage report
    - docker run -u `id -u`:`id -g` -v `pwd`/reports:/src/reports ${IMAGE_NAME}:src-${CI_COMMIT_SHA} poetry run coverage xml -o reports/coverage.xml
    - sed -i "s:<source>/src:<source>${CI_BUILDS_DIR}/${CI_PROJECT_PATH}:" reports/coverage.xml

  coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
  artifacts:
    when: always
    reports:
      junit: reports/junit.xml
      coverage_report:
        coverage_format: cobertura
        path: reports/coverage.xml
  tags:
    - rse-multi-builder


docs-test:
  stage: test
  script:
    - docker run -u `id -u`:`id -g` ${IMAGE_NAME}:src-${CI_COMMIT_SHA} bash build_docs.sh
  tags:
    - rse-multi-builder


tag-release:
  stage: tag
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: always
    - when: never
  script:
    - echo "Attempting to tag release $VERSION"
    - git config user.email "$GITLAB_USER_EMAIL"
    - git config user.name "$GITLAB_USER_NAME"
    - >
      if [ -z $(git ls-remote --tags origin "$VERSION") ]; then
        echo "Tag $VERSION does not exist remotely. Creating and pushing..."
        git remote add gitlab https://oauth2:${NDIP_GROUP_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git || echo "Remote gitlab already exists or failed to add."
        git tag ${VERSION}
        git push gitlab --tags
      else
        echo "Tag $VERSION already exists remotely. Skipping tag creation."
      fi
  tags:
  - rse-multi-builder

build-prototype-image:
  stage: build-prototype
  script:
    - echo "Building prototype image for commit ${CI_COMMIT_SHA}"
    # Build using source image for non-minimal types, which is at ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
    - echo "Building prototype run image for ${PROTOTYPE_IMAGE_DESTINATION}:${CI_COMMIT_SHA} using source image ${IMAGE_NAME}:src-${CI_COMMIT_SHA}"
    - docker build -f dockerfiles/Dockerfile -t prototype-image-built --target run --build-arg SOURCE_IMAGE=${IMAGE_NAME}:src-${CI_COMMIT_SHA} .
    # Tagging and pushing logic for prototype
    - docker tag prototype-image-built ${PROTOTYPE_IMAGE_DESTINATION}:${CI_COMMIT_SHA}
    - docker push ${PROTOTYPE_IMAGE_DESTINATION}:${CI_COMMIT_SHA}
    - docker tag prototype-image-built ${PROTOTYPE_IMAGE_DESTINATION}:latest-prototype
    - docker push ${PROTOTYPE_IMAGE_DESTINATION}:latest-prototype
  tags:
    - rse-multi-builder

build-prod-image:
  stage: publish
  variables:
    OVERWRITE_IMAGE: "false"
  when: manual
  script:
    - IMAGE_TAG=${VERSION}
    # Build using source image for non-minimal types
    - echo "Building run image for $IMAGE_NAME:$IMAGE_TAG using source image ${IMAGE_NAME}:src-${CI_COMMIT_SHA}"
    - docker build -f dockerfiles/Dockerfile -t image --target run --build-arg SOURCE_IMAGE=${IMAGE_NAME}:src-${CI_COMMIT_SHA} .
    - docker tag image ${IMAGE_NAME}:bin-${CI_COMMIT_SHA}
    - docker push ${IMAGE_NAME}:bin-${CI_COMMIT_SHA}
    # Tagging and pushing logic (common)
    - docker tag image ${IMAGE_NAME}:latest
    - docker push ${IMAGE_NAME}:latest
    - >
      if ! docker pull ${IMAGE_NAME}:${IMAGE_TAG} || [ "$OVERWRITE_IMAGE" == "true" ]; then
        echo "Pushing tag ${IMAGE_NAME}:${IMAGE_TAG}"
        docker tag image ${IMAGE_NAME}:${IMAGE_TAG}
        docker push ${IMAGE_NAME}:${IMAGE_TAG}
      else
        echo "Tag ${IMAGE_TAG} already exists in ${NDIP_DOCKER_REPOSITORY}. Skipping push."
        echo "To overwrite, set OVERWRITE_IMAGE=true in CI variables or delete the tag manually."
        # Optionally exit 1 here if overwriting is strictly forbidden by default
        # exit 1
      fi
  tags:
    - rse-multi-builder

package-build:
  stage: publish
  script:
    - >
      docker run
      -u `id -u`:`id -g`
      ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
      bash -c "
      poetry config repositories.gitlab_repo ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi &&
      poetry publish -u gitlab-ci-token -p ${CI_JOB_TOKEN} -r gitlab_repo
      "
  when: manual
  tags:
    - rse-multi-builder


+27 −0
Original line number Diff line number Diff line
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.6.0
  hooks:
    - id: check-added-large-files
      args: [--maxkb=8192]
    - id: check-merge-conflict
    - id: check-yaml
      args: [--allow-multiple-documents]
    - id: end-of-file-fixer
    - id: check-toml
    - id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
  rev: v0.6.2
  hooks:
    - id: ruff
      args: [--fix, --exit-non-zero-on-fix]
    - id: ruff-format
- repo: local
  hooks:
    - id: mypy
      name: mypy
      entry: poetry run mypy .
      language: system
      types: [python]
      verbose: true
      pass_filenames: false