From daa74cbf602fe374bf00aa743415587bd3362d23 Mon Sep 17 00:00:00 2001 From: Mike Henry <11765982+mikemhenry@users.noreply.github.com> Date: Mon, 17 Apr 2023 14:47:52 -0700 Subject: [PATCH] Fix single file installer (#308) --- .github/workflows/installer.yaml | 130 ++++++++------------ devtools/conda-envs/installer.yaml | 11 -- devtools/installer/construct.yaml | 23 ++++ devtools/scripts/build_cookiecutter_json.py | 23 ---- 4 files changed, 76 insertions(+), 111 deletions(-) delete mode 100644 devtools/conda-envs/installer.yaml create mode 100644 devtools/installer/construct.yaml delete mode 100644 devtools/scripts/build_cookiecutter_json.py diff --git a/.github/workflows/installer.yaml b/.github/workflows/installer.yaml index 3d42a07e..bb4f766a 100644 --- a/.github/workflows/installer.yaml +++ b/.github/workflows/installer.yaml @@ -2,96 +2,72 @@ name: Make single-file installers on: workflow_dispatch: + push: + tags: + - '*' # Build on pushes with tags (unless they contain a / ) + +defaults: + run: + shell: bash -l {0} jobs: test: - name: Building single file installer on ${{ matrix.os }}, Python ${{ matrix.python-version }} - + name: Building single file installer on ${{ matrix.os }} runs-on: ${{ matrix.os }} - strategy: fail-fast: false matrix: os: [macOS-latest, ubuntu-latest] - python-version: 3.9 - - env: - CI_OS: ${{ matrix.os }} - PYVER: ${{ matrix.python-version }} steps: - - uses: actions/checkout@v3 - - - uses: conda-incubator/setup-miniconda@v2.1.1 + - name: Checkout Code + uses: actions/checkout@v3 with: - python-version: ${{ matrix.python-version }} - activate-environment: constructor - environment-file: devtools/conda-envs/installer.yaml - auto-activate-base: false + fetch-depth: 0 - - name: Additional info about the build - shell: bash + - name: Get Latest Version + id: latest-version 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 + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) + # slice off the v, ie v0.7.2 -> 0.7.2 + VERSION=${LATEST_TAG:1} + echo $VERSION + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + + - name: Print Latest Version + run: echo ${{ steps.latest-version.outputs.VERSION }} + + - name: Install constructor environment with Micromamba + uses: mamba-org/provision-with-micromamba@main with: - name: ${{ matrix.os }}_py${{ matrix.python-version }}.sh - path: toolkit-installer-constructor/build/openfe*/openfe*.sh + environment-file: false + channels: conda-forge + environment-name: constructor-env + extra-specs: | + python=3.10 + jinja2 + constructor - - name: Install from installer - shell: bash -l {0} + - name: Create installer + run: VERSION=${{ steps.latest-version.outputs.VERSION }} constructor devtools/installer/ + + - name: Get installer file name + id: file-name 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/ + # This should work as long as we don't have any *.sh files in our root dir + FILE_NAME=$(find * -maxdepth 0 -type f -name "*.sh") + echo $FILE_NAME + echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT + + - name: Test installer + run: | + chmod +x ${{ steps.file-name.outputs.FILE_NAME }} + ./${{ steps.file-name.outputs.FILE_NAME }} -b + export PATH="$HOME/openfeforge/bin:$PATH" + OFE_DOCKER_BUILD=TRUE OFE_SLOW_TESTS=FALSE pytest -v --pyargs openfe pytest -v --pyargs openfe + + - uses: actions/upload-artifact@v3 + with: + name: ${{ steps.file-name.outputs.FILE_NAME }} + path: OpenFEforge* + if-no-files-found: error diff --git a/devtools/conda-envs/installer.yaml b/devtools/conda-envs/installer.yaml deleted file mode 100644 index 93374e81..00000000 --- a/devtools/conda-envs/installer.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: constructor - -channels: - - defaults - - conda-forge - -dependencies: - - conda-build - - conda - - constructor=>3.1 - - cookiecutter diff --git a/devtools/installer/construct.yaml b/devtools/installer/construct.yaml new file mode 100644 index 00000000..7e33158b --- /dev/null +++ b/devtools/installer/construct.yaml @@ -0,0 +1,23 @@ +name: OpenFEforge +version: {{ environ["VERSION"] }} +company: OpenFE +license_file: ../../LICENSE + +channels: + - conda-forge + +write_condarc: True +keep_pkgs: True +transmute_file_type: .conda + +specs: + - conda + - gufe=={{ environ["VERSION"] }} + - mamba + - openfe=={{ environ["VERSION"] }} + - pip + - pytest + - python 3.9.* + +# Not building an .exe for windows or a .pkg for macOS +installer_type: sh diff --git a/devtools/scripts/build_cookiecutter_json.py b/devtools/scripts/build_cookiecutter_json.py deleted file mode 100644 index 79630544..00000000 --- a/devtools/scripts/build_cookiecutter_json.py +++ /dev/null @@ -1,23 +0,0 @@ -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)