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

Boilerplate GHA script #13

Open
mattwthompson opened this issue Jul 31, 2020 · 7 comments
Open

Boilerplate GHA script #13

mattwthompson opened this issue Jul 31, 2020 · 7 comments

Comments

@mattwthompson
Copy link
Member

mattwthompson commented Jul 31, 2020

Here is a starting point for a GitHub Actions script that runs CI. This assumes some structural similarity to the MolSSI cookiecutter (python -m pip install . should install the package, there should be a conda environment specified in devtools/conda-envs/test_env.yaml) but with some small modifications. The only necessary modification to get this running off the shelf should be updating PACKAGE_NAME_HERE

name: ci

on:
  push:
    branches:
      - "master"
      - "maintenance/.+"
  pull_request:
    branches:
      - "master"
      - "maintenance/.+"
  schedule:
    # Run a cron job once daily
    - cron: "0 3 * * *"

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macOS-latest, ubuntu-latest]
        python-version: [3.6, 3.7]
    env:
      PYVER: "${{ matrix.python-version }}"
      PACKAGE: PACKAGE_NAME_HERE  # Replace with the name of your package

    steps:
    - uses: actions/checkout@v2

    - uses: conda-incubator/setup-miniconda@v2
      with:
        python-version: ${{ matrix.python-version }}
        activate-environment: test
        channel-priority: true
        environment-file: devtools/conda-envs/test_env.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 --all
        conda list

    - name: Install package
      shell: bash -l {0}
      run: |
        python -m pip install --no-deps .

    - name: Run tests
      shell: bash -l {0}
      run: |
        PYTEST_ARGS=" -v --cov=$PACKAGE --cov-report=xml --cov-config=setup.cfg"
        pytest $PYTEST_ARGS $PACKAGE

    - name: Codecov
      uses: codecov/codecov-action@v1
      with:
        file: ./coverage.xml
        fail_ci_if_error: true
@jaimergp
Copy link
Contributor

jaimergp commented Aug 4, 2020

This is awesome! Thanks for putting it together.

Only a few comments:

  • I think mamba-version is not ready for production usage yet (some inconsistencies between solved envs with conda env).
  • conda info could be conda info --all.
  • PACKAGE_NAME_HERE can be exported as an environment variable in jobs.tests.env.
  • CI_OS: ${{ matrix.os }} is not needed now that we use Goanpeca's action.
  • What about including some scheduled crons?

@mattwthompson
Copy link
Member Author

Thanks for the feedback!

I think mamba-version is not ready for production usage yet (some inconsistencies between solved envs with conda env).

Done - I like that this can be configured with only 1-2 lines changed, not needing an extra file or several lines changed

conda info could be conda info --all.
PACKAGE_NAME_HERE can be exported as an environment variable in jobs.tests.env.
CI_OS: ${{ matrix.os }} is not needed now that we use Goanpeca's action.
What about including some scheduled crons?

Agre on each, and done too!

@jaimergp
Copy link
Contributor

jaimergp commented Aug 4, 2020

Awesome, thanks!

mattwthompson added a commit to openforcefield/openff-cli that referenced this issue Aug 4, 2020
mattwthompson added a commit to openforcefield/openff-cli that referenced this issue Aug 4, 2020
* Remove un-used import

* Add boilerplate GitHub Actions CI script taken from openforcefield/status#13

* Add channels to conda env YAML

* Fix some references to `openff_cli`
@mattwthompson
Copy link
Member Author

mattwthompson commented Sep 14, 2020

What was once goanpeca/setup-miniconda needs to now be conda-incubator/setup-miniconda. The author forked it from the org, so something will be downloaded by an script, but that is not guaranteed to be updated and should not be used in general. See for details/updates: conda-incubator/setup-miniconda#70

@mattwthompson
Copy link
Member Author

I've updated the above script to reflect the conda-incubator/setup-miniconda bump to v2

@mattwthompson
Copy link
Member Author

Based on discussion in conda-incubator/setup-miniconda#129, it is probably better to run cron jobs a few hours before or after midnight UTC, since that's when everybody else runs their cron jobs and Anaconda's servers are less reliable then (for non-cached channels; conda-forge and the defaults channel should be fine, but the omnia channel is very flaky). I've updated the script at the top to run at 3am UTC

@mattwthompson
Copy link
Member Author

Note a small syntax fix that @mikemhenry found, which will be necessary to have YAML resolve 3.10 as 3.10 and not 3.1: https://github.com/openforcefield/openff-interchange/pull/359/files

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

No branches or pull requests

2 participants