<commit_before>name: Make single-file installers

on:
  release:
    types: 
      - released
      - prereleased
  workflow_dispatch:
  pull_request:  # Remove this when merging this PR
  schedule:
    - cron: "0 0 * * 0"  # This cron job should maybe just live in openforcefield/status/?

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

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

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

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

    steps:
    - uses: actions/checkout@v2
      
    - name: Wait for 2 hours if triggered by a release
      if: (github.event_name == 'release') || (github.event_name == 'prerelease')
      run:
        sleep 7200

    - uses: conda-incubator/setup-miniconda@v1
      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
        export LATEST_TAG=$(git ls-remote --tags https://github.com/openforcefield/openforcefield.git | cut -f2 | grep -v "rc" | tail -1 | sed 's/refs\/tags\///')

        echo $LATEST_TAG

        git clone https://github.com/openforcefield/toolkit-installer-constructor
        cd toolkit-installer-constructor

        python ../openforcefield/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 tarball as artifact
      uses: actions/upload-artifact@v2
      with:
        path: toolkit-installer-constructor/build/openforcefield-*.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/openforcefield-*/

        mkdir scratch
        cd scratch
        echo $HOME/constructor_install/ | bash ../toolkit-installer-constructor/build/openforcefield-*/openforcefield-*.sh

        conda activate $HOME/constructor_install/
        conda info
        conda list

        export FOUND_VER=$(python -c "import openforcefield; print(openforcefield.__version__)")
        export LATEST_TAG=$(git ls-remote --tags https://github.com/openforcefield/openforcefield.git | cut -f2 | grep -v "rc" | tail -1 | sed 's/refs\/tags\///')

        echo $LATEST_TAG
        echo $FOUND_VER

        if [[ $LATEST_TAG != $FOUND_VER ]];
          then echo "Version mismatch"
          exit 1
        fi

        PYTEST_ARGS=" -r fE --tb=short"
        PYTEST_ARGS+=" --ignore=openforcefield/tests/test_links.py"
        # Can be dropped in the release after 0.7.1, in which readme links were tested in test_examples.py
        PYTEST_ARGS+=" --ignore=openforcefield/tests/test_examples.py"
        PYTEST_ARGS+=" --ignore=utilities --ignore=examples/deprecated "

        # 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 $PYTEST_ARGS ../openforcefield/openforcefield/tests/

<commit_msg>Fix path to file for upload<commit_after>name: Make single-file installers

on:
  release:
    types: 
      - released
      - prereleased
  workflow_dispatch:
  pull_request:  # Remove this when merging this PR
  schedule:
    - cron: "0 0 * * 0"  # This cron job should maybe just live in openforcefield/status/?

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

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

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

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

    steps:
    - uses: actions/checkout@v2
      
    - name: Wait for 2 hours if triggered by a release
      if: (github.event_name == 'release') || (github.event_name == 'prerelease')
      run:
        sleep 7200

    - uses: conda-incubator/setup-miniconda@v1
      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
        export LATEST_TAG=$(git ls-remote --tags https://github.com/openforcefield/openforcefield.git | cut -f2 | grep -v "rc" | tail -1 | sed 's/refs\/tags\///')

        echo $LATEST_TAG

        git clone https://github.com/openforcefield/toolkit-installer-constructor
        cd toolkit-installer-constructor

        python ../openforcefield/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 tarball as artifact
      uses: actions/upload-artifact@v2
      with:
        path: toolkit-installer-constructor/build/openforcefield-*-64/openforcefield-*-64.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/openforcefield-*/

        mkdir scratch
        cd scratch
        echo $HOME/constructor_install/ | bash ../toolkit-installer-constructor/build/openforcefield-*/openforcefield-*.sh

        conda activate $HOME/constructor_install/
        conda info
        conda list

        export FOUND_VER=$(python -c "import openforcefield; print(openforcefield.__version__)")
        export LATEST_TAG=$(git ls-remote --tags https://github.com/openforcefield/openforcefield.git | cut -f2 | grep -v "rc" | tail -1 | sed 's/refs\/tags\///')

        echo $LATEST_TAG
        echo $FOUND_VER

        if [[ $LATEST_TAG != $FOUND_VER ]];
          then echo "Version mismatch"
          exit 1
        fi

        PYTEST_ARGS=" -r fE --tb=short"
        PYTEST_ARGS+=" --ignore=openforcefield/tests/test_links.py"
        # Can be dropped in the release after 0.7.1, in which readme links were tested in test_examples.py
        PYTEST_ARGS+=" --ignore=openforcefield/tests/test_examples.py"
        PYTEST_ARGS+=" --ignore=utilities --ignore=examples/deprecated "

        # 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 $PYTEST_ARGS ../openforcefield/openforcefield/tests/


{'fraction_non_alphanumeric': 0.10151960158345039, 'fraction_numerical': 0.007917251947388584, 'mean_word_length': 2.188925081433225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4016155', 'n_tokens_mistral': 2487, 'n_tokens_neox': 2315, 'n_words': 655}