Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action and CI #1

Merged
merged 36 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b5b7005
add ci
lilyminium Aug 13, 2022
f7206cc
outdent
lilyminium Aug 13, 2022
35596d8
comment python ver?
lilyminium Aug 13, 2022
35a74f2
add ref?
lilyminium Aug 13, 2022
de2f0bf
made release
lilyminium Aug 13, 2022
460be65
use main
lilyminium Aug 13, 2022
756ccd3
fix if
lilyminium Aug 13, 2022
df8b188
add outputs
lilyminium Aug 13, 2022
e6a2965
update develop
lilyminium Aug 13, 2022
3507808
change 2.0 to 2.1
lilyminium Aug 13, 2022
3125323
fix upgrade
lilyminium Aug 13, 2022
1382840
fix check
lilyminium Aug 13, 2022
9445cc5
fix include
lilyminium Aug 13, 2022
9598c5b
add expected
lilyminium Aug 13, 2022
942885a
quote version
lilyminium Aug 13, 2022
5c624f0
fix version
lilyminium Aug 13, 2022
3621615
fix if?
lilyminium Aug 13, 2022
8946443
fix tests
lilyminium Aug 13, 2022
1c6d36c
dodge shell?
lilyminium Aug 13, 2022
6bf0b5b
stringify
lilyminium Aug 13, 2022
60dcbf9
flesh out matrix
lilyminium Aug 13, 2022
11c169d
add concurrency
lilyminium Aug 13, 2022
2adafdd
change mac settings
lilyminium Aug 13, 2022
4f8e6ab
rm superfluous action
lilyminium Aug 13, 2022
63fea93
comments from review
lilyminium Aug 13, 2022
d2dbdfe
rm env from matrix
lilyminium Aug 13, 2022
1d5c377
set outputs
lilyminium Aug 13, 2022
f2c5aef
get action name right
lilyminium Aug 13, 2022
8ae6f22
/do/then
lilyminium Aug 13, 2022
7ad6dc4
/done/fi/
lilyminium Aug 13, 2022
4b62d48
pls
lilyminium Aug 13, 2022
0d4f536
rm space
lilyminium Aug 13, 2022
7a282d2
what happened to mamba
lilyminium Aug 13, 2022
137f6bc
move env outside workflows to avoid ci
lilyminium Aug 13, 2022
868c461
oops
lilyminium Aug 13, 2022
55f7727
conda remove
lilyminium Aug 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/actions/check-mdanalysis-install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Install and check
description: Install MDAnalysis and check it's installed
inputs:
expected-version:
description: Expected version
required: true
install-version:
description: Input version to install
required: true
default: latest
include-tests:
description: Whether to install MDAnalysisTests
required: true
default: false
installer:
description: pip, conda, or mamba
required: true
default: pip
shell:
description: shell to use
required: true
default: bash
outputs:
installed-version:
description: Installed MDAnalysis version
value: "${{ steps.install.outputs.installed-version }}"


runs:
using: "composite"
steps:
- id: install
uses: ./
with:
version: ${{ inputs.install-version }}
install-tests: ${{ inputs.include-tests }}
installer: ${{ inputs.installer }}
shell: ${{ inputs.shell }}

- name: Check version
shell: python
run: |
import MDAnalysis
assert MDAnalysis.__version__ == ${{ inputs.expected-version }}

- name: Check MDAnalysisTests
if: ${{ matrix.include-tests }}
shell: python
run:
from MDAnalysis.tests.datafiles import PDB
IAlibay marked this conversation as resolved.
Show resolved Hide resolved
81 changes: 81 additions & 0 deletions .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

defaults:
lilyminium marked this conversation as resolved.
Show resolved Hide resolved
run:
shell: bash

jobs:
main-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
installer: ["pip", "mamba"]
include-tests: [true, false]
mdanalysis-version:
- install-version: develop
expected-version: "2.3.0-dev0"
lilyminium marked this conversation as resolved.
Show resolved Hide resolved
- install-version: latest
expected-version: "2.2.0"
- install-version: "2.1.0"
expected-version: "2.1.0"

include:
IAlibay marked this conversation as resolved.
Show resolved Hide resolved
- os: windows-latest
python-version: 3.9
installer: pip
include-tests: true
- os: macOS-latest
python-version: 3.10
installer: mamba
include-tests: false


steps:
- uses: actions/checkout@v3

- name: Set up environment
run: |
if [[ ${{ matrix.installer }} == 'pip' ]] ; then
USE_SHELL="bash"
else
USE_SHELL="bash -l {0}"
fi

echo "USE_SHELL=${USE_SHELL}" >> $GITHUB_ENV

- name: Install conda Python ${{ matrix.python-version }}
if: ${{ matrix.installer == 'conda' }} || ${{ matrix.installer == 'mamba' }}
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
add-pip-as-python-dependency: true
architecture: x64
mamba-version: "*"
channels: conda-forge, defaults
auto-update-conda: true
show-channel-urls: true

- name: Setup Python ${{ matrix.python-version }}
if: ${{ matrix.installer == 'pip' }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Check
uses: ./.github/actions/check-mdanalysis-install
with:
install-version: ${{ matrix.mdanalysis-version['install-version'] }}
include-tests: ${{ matrix.include-tests }}
installer: ${{ matrix.installer }}
shell: ${{ env.USE_SHELL }}
117 changes: 117 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Install MDAnalysis
description: Install MDAnalysis
inputs:
version:
description: >
Version of MDAnalysis to install.
Can be a specified version (e.g. 2.0.0),
"develop", or "latest".
required: true
default: latest
install-tests:
description: Whether to install MDAnalysisTests
required: true
default: false
installer:
description: >
Installer to use.
Must be one of pip, conda, or mamba.
required: true
default: pip
shell:
description: >
Which shell to use.
If you have a conda environment, you should
lilyminium marked this conversation as resolved.
Show resolved Hide resolved
use `bash -l {0}`.
If you are using pip, you should use `bash`,
as `bash -l {0}` can fail on Mac runners.
required: true
default: bash
outputs:
installed-version:
description: Installed MDAnalysis version
value: "${{ steps.print-version.outputs.installed-version }}"


runs:
using: "composite"
steps:
- name: Uninstall pre-existing versions
shell: ${{ inputs.shell }}
run: |
# uninstall tests even if not reinstalling,
IAlibay marked this conversation as resolved.
Show resolved Hide resolved
# as versions can clash
python -m pip uninstall -y MDAnalysis MDAnalysisTests

- name: Set installer
id: setup-installer
shell: ${{ inputs.shell }}
run: |
case ${{ inputs.installer }} in
pip|conda|mamba) true ;;
*)
printf "${{ inputs.installer }} is not a valid installer; must be one of pip, conda, mamba"
exit 1
;;
esac

INSTALLER="${{ inputs.installer }}"
if [[ ${{ inputs.version }} == "develop" ]] ; then
INSTALLER="pip"
fi

echo "::set-output name=installer::$(echo $INSTALLER)"


- name: Setup install lines
id: setup-install-line
shell: ${{ inputs.shell }}
run: |
if [[ "${{ inputs.version }}" == "latest" ]] ; then
_PACKAGE_SUFFIX=""
else
_PACKAGE_SUFFIX="==${{ inputs.version }}"
fi

_INSTALL_LINE="MDAnalysis${_PACKAGE_SUFFIX}"
if [[ "${{ inputs.install-tests }}" == "true" ]] ; then
_INSTALL_LINE="${_INSTALL_LINE} MDAnalysisTests${_PACKAGE_SUFFIX}"
fi

# special case develop
if [[ "${{ inputs.version }}" == "develop" ]] ; then
_INSTALL_LINE="'git+https://github.com/MDAnalysis/mdanalysis@develop#egg=MDAnalysis&subdirectory=package'"
if [[ "${{ inputs.install-tests }}" == "true" ]] ; then
_INSTALL_LINE="${_INSTALL_LINE} 'git+https://github.com/MDAnalysis/mdanalysis@develop#egg=MDAnalysisTests&subdirectory=testsuite'"
fi
fi

echo "Install line: ${_INSTALL_LINE}"
echo "::set-output name=install-line::$(echo $_INSTALL_LINE)"

- name: Install with conda
if: steps.setup-installer.outputs.installer != 'pip'
shell: ${{ inputs.shell }}
run: |
${{ inputs.installer }} install -y -c conda-forge ${{ steps.setup-install-line.outputs.install-line }}

if [[ ${{ inputs.version }} == "latest" ]] ; then
${{ inputs.installer }} update -y -c conda-forge ${{ steps.setup-install-line.outputs.install-line }}
fi

- name: Install with pip
if: steps.setup-installer.outputs.installer == 'pip'
shell: ${{ inputs.shell }}
run: |
python -m pip install ${{ steps.setup-install-line.outputs.install-line }}

if [[ ${{ inputs.version }} == "latest" ]] ; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this special case exists, I thought you could just straight up pip install from git develop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"develop" pulls from git develop -- "latest" pulls the latest release available on pypi/conda. Is that what you're asking?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh, calling upgrade again? I think because I have murky memories in the past about having to manually --upgrade to get the latest version, although I never nailed down exactly why.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We pip install from main in a few places in OpenFE and I've never had this problem. Would it be worth seeing if it's not worth it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused what you're asking here -- are you asking why pip --upgrade, or are you asking to install from github? I was answering the former question. We could install from github for latest but I guess I don't quite see why -- especially since I assume we're renaming master at some point?

Copy link
Member

@IAlibay IAlibay Aug 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my sole question here is about upgrade step overall and whether or not it's necessary to run it.

edit: I've never had to do this before, especially with pip

python -m pip install --upgrade ${{ steps.setup-install-line.outputs.install-line }}
fi

- name: Get final version
id: print-version
shell: ${{ inputs.shell }}
run: |
pyver=$(python -c 'import MDAnalysis; print(MDAnalysis.__version__)')
echo "::set-output name=installed-version::$(echo $pyver)"