Skip to content

Run unit tests in CircleCI - #27

Merged
dnadeau-lanl merged 7 commits into
spacepy:masterfrom
jtniehof:circleci_unittests
Sep 23, 2020
Merged

dnadeau-lanl merged 7 commits into
spacepy:masterfrom
jtniehof:circleci_unittests

Conversation

@jtniehof

@jtniehof jtniehof commented Sep 21, 2020 •

Copy link
Copy Markdown
Member

This PR sets up unit testing in CircleCI.

It documents the basic CircleCI/GitHub setup, for configuration which isn't in the .yaml (Closes #16).

It splits the build and the tests into separate jobs: the build which installs most dependencies and dbprocessing itself, the postgres test which installs the necessary postgres tools and creates the postgres db, and the unittest job which runs the unit tests (Closes #15). It uses workspace persistence to carry .local across (which catches all the Python installs, basically.)

It also clears out a few things we aren't currently using:

  • It doesn't install vim, since it would need to do that for every job, slowing things down. vim can be installed from the command line after ssh in if something needs to be debugged.
  • It removes the environment variable setting for pip virtualenv handling, since we aren't using virtualenv. Might be a nice thing to look into, particularly once caching can be set up.

This doesn't do any caching at this point...I wanted to get the basic setup running. But in the future some level of caching the pip installs might be useful.

Draft for now until I can be sure the tests actually work....

PR Checklist

  • Pull request has descriptive title
  • Pull request gives overview of changes
  • (N/A) New code has inline comments where necessary
  • (N/A) Any new modules, functions or classes have docstrings consistent with dbprocessing style
  • (N/A) Major new functionality has appropriate Sphinx documentation
  • (N/A) Added an entry to CHANGELOG if fixing a major bug or providing a major new feature
  • (N/A) New features and bug fixes should have unit tests
  • Relevant issues are linked in the description (e.g. See issue # or Closes #)

 * Rather than chown of /usr/local, less messing with environment.
 * Can be installed when ssh in to fix, and otherwise have to install it
   for every job in the workflow.
 * Not using virtual environments.
 * This also made CI fail, since not installing SpacePy in test.
 * This can sometimes provide more clues about how a test failed, or what
   test raised a warning.
@jtniehof
jtniehof marked this pull request as ready for review September 21, 2020 20:37
@jtniehof

Copy link
Copy Markdown
Member Author

Once this is merged I'll update the checks to explicitly require the unittest and postgres jobs to succeed in order to merge, but until this is merged that would block any other merges :)

@jtniehof

Copy link
Copy Markdown
Member Author

CircleCI reports out both the succes of the entire workflow, and the success of each individual job. Right now I have both workflow and the "build" job required in order to merge ("build" because that was the only job in the initial setup.) Reasonable options would be:

  1. Just the workflow success is required. This is the same as requiring all the jobs, since the workflow only succeeds if all jobs succeed. I'm leaning in this direction, since it requires the fewest number of things to work in the communication from CircleCI to GitHub.
  2. Each individual job is required, but not the workflow.
  3. The workflow and each job are required.

Regardless of what is required all get reported out in the PR, so you can see which job failed if the workflow failed. You can see above that "4 successful checks" are listed, and only the workflow (main) and the build job have the "required" tag.

@dnadeau-lanl dnadeau-lanl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this! I am very happy to see your tests running successfully in circleci!

@dnadeau-lanl
dnadeau-lanl merged commit 1fe1ef4 into spacepy:master Sep 23, 2020
@jtniehof
jtniehof deleted the circleci_unittests branch September 23, 2020 16:30
@jtniehof

Copy link
Copy Markdown
Member Author

Thanks. I set up the master branch protection rule to require the workflow to pass and not care about individual jobs. (I also set up a default branch protection rule to make it really hard to push to other branches, since PRs should normally be submitted from forks...we can revisit that later.)

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.

Document CircleCI setup and github integration Execute unit tests in CircleCI

2 participants