Skip to content

Commit

Permalink
feat: base branch and pr target are different
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-sysbio committed Feb 27, 2021
1 parent a9c9672 commit 4d8804a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Run the pipeline
run: |
cd latest-ecModels
python3 run.py
python3 run.py ${GITHUB_REF#refs/heads/}
50 changes: 24 additions & 26 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import tools
import subprocess as sp
from sys import exit
import sys
import logging
import os


logging.basicConfig(level=logging.DEBUG)
l = logging.getLogger(__name__)
system = tools.GECKO_VM()


def matlab_command(gem):
cmd = """
cd {}geckomat
Expand Down Expand Up @@ -63,29 +61,29 @@ def setup_and_run_GECKO(gem):
system.git_add_and_pr(gem, matlab_output)
system.cleanup('GECKO')

if __name__ == "__main__":
system.PIPELINE_BASE_BRANCH = sys.argv[1]
l.info('Pipeline started on branch {}'.format(system.PIPELINE_BASE_BRANCH))
l.info('Checking all dependencies listed in config.ini of type not `gem`.')
system.check_dependencies()
# Run GECKO wherever needed
for gem in system.gems():
system.cleanup(gem)
new_version = system.download(gem)
old_version = system.version(gem)
if system.HAS_CHANGES or git_version != old_version:
if system.HAS_CHANGES:
l.warning('System config has changed, have to run GECKO on {} {}'.format(gem, new_version))
else:
l.warning('{} changed from {} to {}'.format(gem, old_version, new_version))

l.info('It has begun')
l.info('Checking all dependencies listed in config.ini of type not gem')
system.check_dependencies()

# Run GECKO wherever needed
for gem in system.gems():
system.cleanup(gem)
new_version = system.download(gem)
old_version = system.version(gem)
if system.HAS_CHANGES or git_version != old_version:
if system.HAS_CHANGES:
l.warning('System config has changed, have to run GECKO on {} {}'.format(gem, new_version))
else:
l.warning('{} changed from {} to {}'.format(gem, old_version, new_version))

l.info('Going to run GECKO on {}, saving config file before running'.format(gem))
system.version(gem, new_version)
system.save_config()
l.info('Going to run GECKO on {}, saving config file before running'.format(gem))
system.version(gem, new_version)
system.save_config()

setup_and_run_GECKO(gem)
setup_and_run_GECKO(gem)

l.info('Reverting changes on config file made for {}, proceeding to next gem'.format(gem))
system.version(gem, old_version)
system.save_config()
system.cleanup(gem)
l.info('Reverting changes on config file made for {}, proceeding to next gem'.format(gem))
system.version(gem, old_version)
system.save_config()
system.cleanup(gem)
5 changes: 3 additions & 2 deletions tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
DURL = 'download_url'
IDIR = 'install_dir'
SCRIPTSDIR = 'scripts'
PIPELINE_BASE_BRANCH = 'master'

logging.basicConfig(level=logging.DEBUG)
l = logging.getLogger(__name__)
Expand Down Expand Up @@ -111,8 +112,8 @@ def git_add_and_pr(self, gem, matlab_output):
except sp.CalledProcessError:
l.critical('While upgrading {} to {} no changes were detected'.format(gem, self.version(gem)))
finally:
l.info('Checking out {}'.format(self.pr_target()))
cmd = sp.check_output(['git', 'checkout', '-f', self.pr_target()])
l.info('Checking out {}'.format(self.PIPELINE_BASE_BRANCH))
cmd = sp.check_output(['git', 'checkout', '-f', self.PIPELINE_BASE_BRANCH])
l.info(cmd.decode('utf-8'))

def check_dependencies(self):
Expand Down

0 comments on commit 4d8804a

Please sign in to comment.