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

[WIP] Add support for GitHub actions #95

Merged
merged 30 commits into from
May 27, 2020
Merged

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Nov 27, 2019

This PR adds preconfigured support for GitHub Actions, following conversation in #90.

To do

  • Parameterize existing implementation in openkinome/kinoml
  • Add support for Windows
  • Add support for non-conda builds
  • Apparently Miniconda is preinstalled in all environments, the location being available at $CONDA. Test this is true and functional.
  • Variables in GH Actions use some sort of Jinja-syntax (${{ variable }}) that interferes with cookiecutter's Jinja processing. I think we just need to escape this on the unprocessed YAML to make the tests pass.

@jaimergp jaimergp changed the title Add support for GitHub actions [WIP] Add support for GitHub actions Nov 27, 2019
{{cookiecutter.repo_name}}/.github/workflows/CI.yaml Outdated Show resolved Hide resolved
{{cookiecutter.repo_name}}/.github/workflows/CI.yaml Outdated Show resolved Hide resolved
{{cookiecutter.repo_name}}/.github/workflows/CI.yaml Outdated Show resolved Hide resolved
README.md Outdated
@@ -16,7 +16,7 @@ remove deployment platforms, or test with a different suite.
## Features
* Python-centric skeletal structure with initial module files
* Pre-configured `setup.py` for installation and packaging
* Pre-configured Window, Linux, and OSX continuous integration on AppVeyor and Travis-CI
* Pre-configured Window, Linux, and OSX continuous integration on AppVeyor+Travis-CI and/or GitHub Actions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am up for removing AppVeyor and Travis entirely. @janash @Lnaden any comments?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am all for dropping Travis and VERY much for dropping AppVeyor. Go for it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall I remove them as part of this PR or should this be in a separate PR (also merged to dev) for extra clarity?

@jaimergp
Copy link
Contributor Author

I have added Windows support by simply forcing bash to be the default shell in all steps. This is technically supported by GHA, but I'd like to test it with a dummy package first. I think I can use openkinome/kinoml for that in the meantime.

@jaimergp
Copy link
Contributor Author

jaimergp commented Nov 27, 2019

That seems to work! Look here for a similar setup: https://github.com/openkinome/kinoml/pull/5/checks

@jaimergp
Copy link
Contributor Author

By the way, do we want to update the CI on this repo too so it uses GH Actions?

@dgasmith
Copy link
Collaborator

dgasmith commented Dec 1, 2019

This looks really great, let me try this out in a few of our packages and see how it goes.

I would vote to changing the repo's CI in another PR.

@dgasmith
Copy link
Collaborator

dgasmith commented Dec 1, 2019

This is my pass at the YAML: https://github.com/MolSSI/QCElemental/pull/172/files

{% if cookiecutter.dependency_source != 'Dependencies from pip only (no conda)' %}
eval "$(${CONDA_EXE} shell.bash hook)" && conda activate test
{% endif %}
codecov
Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW this doesn't work without a token. I recommend using their image

    - name: CodeCov  
       uses: codecov/codecov-action@v1
       with:
         token: ${{ secrets.CODECOV_TOKEN }}
         file: ./coverage.xml
         flags: unittests
         yml: ./.codecov.yml 

Add --cov-report=xml to the pytest line as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just noticed and was about to ask! Thanks!

shell: bash
if: startsWith(matrix.os, 'windows')
run: echo "::set-env name=CONDA_EXE::$CONDA/Scripts/conda.exe"
{% endif %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So conda is in PATH? Cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like this is not applicable to Windows! Shall I revert the changes?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add it to the path for Windows only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed this discussion and there seems to be some problems with path modification. I'll try to use condabin instead, and see if that works better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, looks like conda is only in PATH in Ubuntu. I keep thinking that the CONDA_EXE approach is the cleanest although it requires one more setup step.

We could use a single step too:

- name: Set-up conda
        run:   |
          if [ "${{ matrix.os }}" != "windows-latest" ]; then
            echo '::set-env name=CONDA_EXE::${CONDA}/bin/conda'
          else
            echo '::set-env name=CONDA_EXE::C:\Miniconda\condabin\conda.bat'
          fi
        shell: bash

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think we could add a conda function in this manner? If not I would recommend something simple so that further lines can do eval '$CONDA_INIT' or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Best thing would be modifying the bash_profile/bashrc to autostart conda for us (but we should still run conda activate test once the environment has been created, although we could check for test existence and activate that instead?), but I think that default bash interpreters in GitHub are configured to ignore profile files, so we would need to define a custom shell in each step. I am not aware of any option to override the default shell for all steps - if that's possible, it'd be the best way. Anyway, shall I try with the bashrc+custom bash shell approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've tried this route but it's not pretty at all because we would need to always specify shell: bash --noprofile --rcfile conda_init.sh -i -e -o pipefail {0}. I find that very confusing and hard to reason about.

Instead, I have opted to create this auxiliary script and call it at the beginning of each step:

    - name: Install package
      shell: bash
      run: |
        . devtools/scripts/initialize_conda.sh
        python -m pip install . --no-deps
        conda list

That way the intention is clear and the initialization code is easier to maintain. Would you prefer this approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and added the script in the last commit.

@dgasmith
Copy link
Collaborator

dgasmith commented Dec 1, 2019

On the codecov line add --color=yes. Unsure why color isn't shown without this.

@jaimergp
Copy link
Contributor Author

jaimergp commented Dec 1, 2019

Oh, due to a WSL bug, my commits are dated as 4 days old. Next ones should be ok, though. Sorry for the confusion!

@jaimergp jaimergp mentioned this pull request Mar 18, 2020
5 tasks
@dotsdl
Copy link

dotsdl commented May 14, 2020

Shall we try @dgasmith's suggestion that this gets merged into a dev branch so that we can see how it behaves properly? Is there anyone with merge ability that can make this happen?

@jchodera
Copy link

@Lnaden @janash @bennybp are still active maintainers, as far as I know.

@Lnaden
Copy link
Collaborator

Lnaden commented May 14, 2020

I've read through all of this, what are the things we are waiting for, @jaimergp? By my thinking, we just need to change the target branch this is being merged in to? Or is there something else I am missing?

@jaimergp
Copy link
Contributor Author

We have been using GHA for a while now in several repositories, and have accumulated some knowledge on how to use it. I have some fixes to add here as well (macOS permissions, for example).

I'd say I can add the fixes here, and then we merge to dev. Additional features could be targeted in separate PRs. What do you think?

@janash
Copy link
Member

janash commented May 15, 2020

Considering that we are using CookieCutter now for MolSSI Education, I would ask that the GHA change be put on a branch or that GHA is listed as an option in CookieCutter set up (travis-ci or GHA)

@jchodera
Copy link

I like the idea of being able to select either travis-ci or GHA until we can make sure that the GHA works robustly for a variety of people. At some point, we can just make GHA the default once folks are happy with it (and hopefully the MolSSI Education program can switch over at that point too).

@Lnaden
Copy link
Collaborator

Lnaden commented May 18, 2020

@jaimergp Is it possible for you to make your changes here that you mentioned, then once you're done, I'll come back in and make it an option to either use travis or GHA as part of the cookiecutter? That way we can get this in without having to worry about a separate branch, and we can mark the GHA experimental while we work out kinks.

@jaimergp
Copy link
Contributor Author

Added to my list. I'll add them some time this week!

@dgasmith
Copy link
Collaborator

Big fan of:

    - name: Setup Conda Environment
      uses: goanpeca/setup-miniconda@v1
      with:
         activate-environment: test
         environment-file: devtools/conda-envs/test_env.yaml
         auto-activate-base: false
    - name: Environment Information
      shell: bash -l {0}
      run: |
        conda info
        conda list

Seems to work very well these days.

@jaimergp
Copy link
Contributor Author

jaimergp commented May 25, 2020

@Lnaden, I have added the last changes I was talking about. Namely:

  • Rely on a GitHub Action to deal with the Miniconda stuff, as recommended by @dgasmith.
  • Added more informative job names
  • Add a "good enough" general case for the push/pr branch configuration. Only commits on master and PRs against master are tested. This removes the duplicated jobs we saw in early attempts.
  • Ability to choose the CI provider and update the tests accordingly
  • Bumped the version to 1.3. Should this be 2.0?

Todo:

  • I don't know how to deal with the tests for GH Actions. What should we try to cover?
  • Documentation must be updated to reflect these changes.

@Lnaden
Copy link
Collaborator

Lnaden commented May 26, 2020

Awesome. I think this has come together fantastically. There is just one small change I would like to request: I am thinking we should make the travis (or +appveyor) default first until we fully debug GHA. Does that work for you?

Things I intend to do after we merge:

  • Add a GHA CI test
  • Bump version to 3.7 and 3.8
  • Reword some of the CI options so they are more clear on their supported OS's
  • Update docs.

@jaimergp
Copy link
Contributor Author

That's an excellent point, yes! This shouldn't be the default just yet. I'll add the changes now.

@Lnaden
Copy link
Collaborator

Lnaden commented May 26, 2020

Great. Once those are in, I think we can merge this. I'll keep the 1.3 until we get GHA stable, then move to 2.0

@jaimergp
Copy link
Contributor Author

Hm, I am thinking that maybe we should label GH Actions as experimental in this early stage? Like this:

    "continuous_integration_provider": [
        "Travis",
        "Travis+AppVeyor",
        "GitHub Actions (experimental)"
    ],

What do you think?

@Lnaden
Copy link
Collaborator

Lnaden commented May 26, 2020

I think thats a great idea. Makes it very clear this is a work in progress.

@jaimergp
Copy link
Contributor Author

Ok, let me add that before you merge.

Copy link
Collaborator

@Lnaden Lnaden left a comment

Choose a reason for hiding this comment

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

I think this is ready to merge finally. Thanks for all the work in making this ready!

@Lnaden
Copy link
Collaborator

Lnaden commented May 26, 2020

I'm getting one more pair of eyes to look over this before I hit merge just in case I missed something obvious, but I'm investigating the nested/chained GHA in the meantime.

@Lnaden Lnaden merged commit 8bb9fdc into MolSSI:master May 27, 2020
@RMeli RMeli mentioned this pull request Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants