Skip to content

Commit

Permalink
Merge pull request #5 from MolSSI-MDI/files
Browse files Browse the repository at this point in the history
Create entry scripts
  • Loading branch information
taylor-a-barnes authored Dec 12, 2022
2 parents 56afed8 + 70df34d commit c40c6eb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/CI.yaml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request events
on:
push:
branches:
- "**"
- '**'
pull_request:
branches:
- "master"
schedule:
# Nightly tests run on master by default:
# Scheduled workflows run on the latest commit on the default or base branch.
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * *"
- '**'

jobs:
test:
Expand Down Expand Up @@ -54,10 +50,10 @@ jobs:
# ls /home/runner/.local/lib/python3.8/site-packages/mdimechanic/docker/ssh


- name: Check for files
if: matrix.os == 'ubuntu-latest'
run: |
ls /home/runner/.local/lib/python3.8/site-packages/mdimechanic/docker/ssh
# - name: Check for files
# if: matrix.os == 'ubuntu-latest'
# run: |
# ls /home/runner/.local/lib/python3.8/site-packages/mdimechanic/docker/ssh


- name: Build the ELECTRIC MDI driver
Expand Down
14 changes: 13 additions & 1 deletion mdimechanic/cmd_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,20 @@ def install_all( base_path ):
if ret != 0:
raise Exception("Unable to build the engine image")

# This script will be executed on entry to the image
build_entry_script = '''#!/bin/bash
set -e
cd /repo
bash .mdimechanic/.temp/build_engine.sh
'''

# Write the entry script into the mounted volume
build_entry_path = os.path.join( base_path, "docker", ".temp", "build_entry.sh" )
os.makedirs(os.path.dirname(build_entry_path), exist_ok=True)
ut.write_as_bytes( build_entry_script, build_entry_path )

# Build the engine, within its Docker image
docker_string = "docker run --rm -v " + str(base_path) + ":/repo -v " + str(package_path) + ":/MDI_Mechanic " + mdimechanic_yaml['docker']['image_name'] + " bash -c \"cd /repo && bash .mdimechanic/.temp/build_engine.sh \""
docker_string = "docker run --rm -v " + str(base_path) + ":/repo -v " + str(package_path) + ":/MDI_Mechanic " + mdimechanic_yaml['docker']['image_name'] + " bash /repo/docker/.temp/build_entry.sh"
ret = os.system(docker_string)
if ret != 0:
raise Exception("Unable to build the engine")
18 changes: 15 additions & 3 deletions mdimechanic/cmd_interactive.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import subprocess
import shutil
from .utils.utils import format_return, insert_list, docker_error, get_mdi_standard, get_compose_path, get_package_path, get_mdimechanic_yaml, write_as_bytes
from .utils import utils as ut


def start( base_path ):
mdimechanic_yaml = get_mdimechanic_yaml( base_path )
mdimechanic_yaml = ut.get_mdimechanic_yaml( base_path )

# Name of the image to run
image_name = mdimechanic_yaml['docker']['image_name']
Expand Down Expand Up @@ -40,10 +40,22 @@ def start( base_path ):
if not found_file:
print("WARNING: MDI Mechanic was unable to locate a .ssh directory. Git will not be fully functional within this interactive session.")

# This script will be executed on entry to the image
interactive_entry_script = '''#!/bin/bash
set -e
cd /repo
bash
'''

# Write the entry script into the mounted volume
interactive_entry_path = os.path.join( base_path, "docker", ".temp", "interactive_entry.sh" )
os.makedirs(os.path.dirname(interactive_entry_path), exist_ok=True)
ut.write_as_bytes( interactive_entry_script, interactive_entry_path )

# Construct the command line to launch docker interactively
run_line = "docker run --rm"
run_line += " -v " + str( base_path ) + ":/repo"
run_line += gitconfig_line
run_line += ssh_line
run_line += " -it " + str(image_name) + " bash -c \"cd /repo && bash\""
run_line += " -it " + str(image_name) + " bash /repo/docker/.temp/interactive_entry.sh"
os.system(run_line)

0 comments on commit c40c6eb

Please sign in to comment.