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 all 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
12 changes: 12 additions & 0 deletions .github/test-environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test
channels:
- conda-forge
- defaults
dependencies:
# Base depends
- python
- pip

# MDAnalysis
- MDAnalysis
- MDAnalysisTests
206 changes: 206 additions & 0 deletions .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
name: CI
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
schedule:
# Weekly tests at midnight on Sundays run on main by default:
# Scheduled workflows run on the latest commit on the default or base branch.
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * 0"


concurrency:
# Specific group naming so CI is only cancelled
# within same PR or on merge to main
group: "${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}"
cancel-in-progress: true

defaults:
lilyminium marked this conversation as resolved.
Show resolved Hide resolved
run:
shell: bash -l {0}

env:
MDANALYSIS_DEVELOP_VERSION: "2.3.0-dev0"
MDANALYSIS_LATEST_RELEASE: "2.2.0"
MDANALYSIS_PREVIOUS_RELEASE: "2.1.0"

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: ["develop", "latest", "previous"]

include:
IAlibay marked this conversation as resolved.
Show resolved Hide resolved
- os: windows-latest
python-version: "3.10"
installer: conda
include-tests: true
mdanalysis-version: "latest"

- os: macOS-latest
python-version: "3.10"
installer: conda
include-tests: false
mdanalysis-version: "latest"

steps:
- uses: actions/checkout@v3

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

echo "::set-output name=action-shell::$(echo $USE_SHELL)"

if [[ ${{ matrix.mdanalysis-version }} == 'previous' ]] ; then
INSTALL_VERSION=${MDANALYSIS_PREVIOUS_RELEASE}
else
INSTALL_VERSION=${{ matrix.mdanalysis-version }}
fi

echo "::set-output name=action-install-version::$(echo $INSTALL_VERSION)"


- 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 }}

- id: Install
uses: ./
with:
version: ${{ steps.environment-setup.outputs.action-install-version }}
install-tests: ${{ matrix.include-tests }}
installer: ${{ matrix.installer }}
shell: ${{ steps.environment-setup.outputs.action-shell }}

- name: Check version
run: |
case "${{ matrix.mdanalysis-version }}" in
"develop") VERSION="'${MDANALYSIS_DEVELOP_VERSION}'" ;;
"latest") VERSION="'${MDANALYSIS_LATEST_RELEASE}'";;
"previous") VERSION="'${MDANALYSIS_PREVIOUS_RELEASE}'" ;;
*) VERSION="'${{ matrix.mdanalysis-version }}'" ;;
esac

echo "Expecting version $VERSION for installed version ${{ steps.environment-setup.outputs.action-install-version }} "

python -c "import MDAnalysis; assert MDAnalysis.__version__ == ${VERSION}, f'incorrect version {MDAnalysis.__version__}'"

if [[ "${{ matrix.include-tests }}" == "true" ]] ; then
python -c "import MDAnalysisTests; assert MDAnalysisTests.__version__ == ${VERSION}, f'incorrect test version {MDAnalysis.__version__}'"

else
if [[ $(python -m pip list | grep "^MDAnalysisTests ") ]] ; then
echo "MDAnalysisTests is installed even though it shouldn't be!"
exit 1
fi
fi

environment-config:
runs-on: ubuntu-latest
outputs:
stable-python-version: "${{ steps.get-python-version.outputs.python-version }}"
steps:
- uses: actions/checkout@v3

- id: get-python-version
uses: MDAnalysis/get-latest-python-version@main
with:
last-n-minor-release: 1

test-on-preinstalled-conda:
needs: environment-config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install conda ${{ needs.environment-config.outputs.stable-python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ needs.environment-config.outputs.stable-python-version }}
environment-file: ./.github/test-environment.yaml
activate-environment: test
add-pip-as-python-dependency: true
architecture: x64
mamba-version: "*"
channels: conda-forge, defaults
auto-update-conda: true
show-channel-urls: true


- name: Install
uses: ./
with:
version: ${{ env.MDANALYSIS_PREVIOUS_RELEASE }}
install-tests: false
installer: mamba
shell: bash -l {0}

- name: Check version
run: |
python -c "import MDAnalysis; assert MDAnalysis.__version__ == '${{ env.MDANALYSIS_PREVIOUS_RELEASE }}'"
if [[ $(python -m pip list | grep "^MDAnalysisTests ") ]] ; then
echo "MDAnalysisTests is installed even though it shouldn't be!"
exit 1
fi

test-on-preinstalled-pip:
needs: environment-config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Python ${{ needs.environment-config.outputs.stable-python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ needs.environment-config.outputs.stable-python-version }}

- name: Install MDAnalysis
shell: bash
run: |
# fun with versions
python -m pip install MDAnalysis==${{ env.MDANALYSIS_PREVIOUS_RELEASE }} MDAnalysisTests==${{ env.MDANALYSIS_PREVIOUS_RELEASE }}
python -m pip install MDAnalysis==${{ env.MDANALYSIS_LATEST_RELEASE }} MDAnalysisTests==${{ env.MDANALYSIS_LATEST_RELEASE }}
python -m pip install MDAnalysis==${{ env.MDANALYSIS_PREVIOUS_RELEASE }} MDAnalysisTests==${{ env.MDANALYSIS_PREVIOUS_RELEASE }}

- name: Install
uses: ./
with:
version: develop
install-tests: true
installer: pip
shell: bash

- name: Check version
run: |
python -c "import MDAnalysis; assert MDAnalysis.__version__ == '${{ env.MDANALYSIS_DEVELOP_VERSION }}'"
python -c "import MDAnalysisTests; assert MDAnalysisTests.__version__ == '${{ env.MDANALYSIS_DEVELOP_VERSION }}'"
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,81 @@
# install-mdanalysis
Action to install MDAnalysis

## Basic usage

See the action.yaml for all inputs.


Examples:

The below workflow installs the develop version of MDAnalysis and MDAnalysisTests, using pip.
```yaml
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.9

- uses: MDAnalysis/install-mdanalysis@main
id: install-mdanalysis
with:
version: develop
install-tests: true
installer: pip
shell: bash

- name: Check MDAnalysis version
shell: bash
run: |
echo "MDAnalysis version: ${{ steps.install-mdanalysis.outputs.installed-version }}

```

Alternatively, you could use conda to install version 2.1.0:

```yaml
steps:
- uses: actions/checkout@v3

- name: Install conda Python 3.9
uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.9
add-pip-as-python-dependency: true
architecture: x64
mamba-version: "*"
channels: conda-forge, defaults
auto-update-conda: true
show-channel-urls: true

- uses: MDAnalysis/install-mdanalysis@main
id: install-mdanalysis
with:
version: "2.1.0"
install-tests: true
installer: conda # or mamba
shell: bash -l {0}

- name: Check MDAnalysis version
shell: bash
run: |
echo "MDAnalysis version: ${{ steps.install-mdanalysis.outputs.installed-version }}

```


### Options

* version: this can be
* "develop": this will pull the develop branch from GitHub
* "latest": this will install the most recent release
* "2.0.0" or a similar release number
* install-tests: `true` or `false`. Whether or not to install MDAnalysisTests
* installer: this can be "conda", "mamba", or "pip". The conda environments and Python should already be set up prior to installing.
* shell: We highly recommend using the login shell `"bash -l {0}"` if you are using a conda environment, and `"bash"` otherwise.


### Notes:

* Cycling this action while using `pip` and `conda` to repeatedly uninstall or reinstall MDAnalysis may lead to undefined behaviour. It is highly encouraged to keep Python environments separate between jobs to avoid this kind of issue.
Loading