Skip to content

Commit

Permalink
Single File Installer (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemhenry authored Mar 31, 2022
1 parent e1a503b commit 721abe4
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/installer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Make single-file installers

on:
workflow_dispatch:

jobs:
test:
name: Building single file installer on ${{ matrix.os }}, Python ${{ matrix.python-version }}

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
python-version: [3.8, 3.9]

env:
CI_OS: ${{ matrix.os }}
PYVER: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@v2.1.1
with:
python-version: ${{ matrix.python-version }}
activate-environment: constructor
environment-file: devtools/conda-envs/installer.yaml
auto-activate-base: false

- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
- name: Environment Information
shell: bash -l {0}
run: |
conda info
conda list
- name: Prepare and run the constructor
shell: bash -l {0}
run: |
#cd ..
# Find the tag of the last release (excluding RCs)
# TODO: Make this a variable that can be passed through from trigger and/or allow RC
# TODO: not sure why grep is failing to match v0.0.1 here
#export LATEST_TAG=$(git ls-remote --tags https://github.com/openfreeEnergy/openfe.git | cut -f2 | grep -E "([0-9]+)\.([0-9]+)\.([0-9]+)$" | sort --version-sort | tail -1 | sed 's/refs\/tags\///')
export LATEST_TAG=$(git ls-remote --tags https://github.com/openfreeEnergy/openfe.git | cut -f2 | sort --version-sort | tail -1 | sed 's/refs\/tags\///')
echo $LATEST_TAG
git clone https://github.com/openfreeEnergy/toolkit-installer-constructor
ls -l devtools
ls -l devtools/scripts
cd toolkit-installer-constructor
echo latest tag $LATEST_TAG pyver $PYVER ci os $CI_OS
python ../devtools/scripts/build_cookiecutter_json.py $LATEST_TAG $PYVER $CI_OS
cp new_cookiecutter.json cookiecutter/cookiecutter.json
cat new_cookiecutter.json
python run.py
pwd
ls
ls build
- name: Upload installer as artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}_py${{ matrix.python-version }}.sh
path: toolkit-installer-constructor/build/openfe*/openfe*.sh

- name: Install from installer
shell: bash -l {0}
run: |
#cd ..
pwd
ls
ls toolkit-installer-constructor
ls toolkit-installer-constructor/build
ls toolkit-installer-constructor/build/openfe-*/
mkdir scratch
cd scratch
echo $HOME/constructor_install/ | bash ../toolkit-installer-constructor/build/openfe-*/openfe-*.sh
conda activate $HOME/constructor_install/
conda info
conda list
export FOUND_VER=$(python -c "import openfe; print(openfe.__version__)")
export LATEST_TAG=$(git ls-remote --tags https://github.com/openfreeEnergy/openfe.git | cut -f2 | grep -v "rc" | tail -1 | sed 's/refs\/tags\///')
echo $LATEST_TAG
echo $FOUND_VER
#TODO fix version on conda-forge release
#if [[ $LATEST_TAG != $FOUND_VER ]];
# then echo "Version mismatch"
# exit 1
#fi
# This should work if run directly at release time, but a safer approach would be
# to `git checkout` the corresponding tag of the release, see PR #577
pytest -v ../openfe/tests/
11 changes: 11 additions & 0 deletions devtools/conda-envs/installer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: constructor

channels:
- defaults
- conda-forge

dependencies:
- conda-build
- conda
- constructor=>3.1
- cookiecutter
23 changes: 23 additions & 0 deletions devtools/scripts/build_cookiecutter_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import sys
import json


release_tag = sys.argv[1]
python_version = sys.argv[2]
ci_os = sys.argv[3]

platform_mapping = {
"ubuntu-latest": "linux-64",
"macOS-latest": "osx-64",
}

data = {
"name": "openfe",
"channel": "conda-forge",
"python": [python_version],
"platform": [platform_mapping[ci_os]],
"release": release_tag,
}

with open("new_cookiecutter.json", "w") as fp:
json.dump(data, fp)

0 comments on commit 721abe4

Please sign in to comment.