Sciware Testing Examples and Exercises

codecov

This is an example repository for writing tests, for the Sciware Testing session. It demonstrates how to setup a repository to use GitHub actions to automatically run tests on the code.

Quick-start

Prerequisites

  • python3 with pip3 (with optional virtualenv or conda)

Install

git clone https://github.com/flatironinstitute/sciware-testing-python.git
cd sciware-testing-python
pip3 install -e .

This will work with a virtualenv, conda, or on a personal machine. With a system python, you may need pip3 install --user -e .. This will also install dependencies (like pytest) specified in requirements.txt.

The -e indicates that we want to continue developing (editing) the installed package.

Run tests

pytest

Forking This Project

If you fork this project you should do the following things to make sure that your fork is correctly linked to your GitHub account:

  1. If you haven't linked your GitHub account to codecov, do so now.
  2. Change the badge URL at the top of README.md to point to your GitHub workflow build. To do this, replace flatironinstitute with your GitHub handle in the URLs of the badge.
  3. Change the badge URL at the top of README.md to point to your codecov report. Go to codecov, navigate to the sciware-testing-python project, then go to Settings > Badge.
  4. Change your codecov token in your GitHub actions file (in .github/workflows). To get your token go to codecov, navigate to the sciware-testing-python project, then go to Settings > General > Repository Upload Token. Copy this token and use it to set the CODECOV_TOKEN variable in .github/workflows.

Contents

  • README.md - File generating this page.
  • setup.py - File describing the metadata for the package and rules to build/install/test it.
  • requirements.txt - File listing the packages required to run the code. It is included by setup.py.
  • LICENSE - File containing the text of the license the code is released under. Having a license file allows other people to use the code.
  • sciware_testing_python/ - Directory for all the code.
  • sciware_testing_python/__init.py__ - File that python imports to define the `sciware_testing_python package.
  • sciware_testing_python/main.py - File with all of the code.
  • [tests/ - Directory for the code which tests the code in sciware_testing_python](tests/** - Directory for the code which tests the code in sciware_testing_python).
  • tests/test_1.py - File to fill in with some tests
  • tests/test_examples.py - File containing some tests
  • .gitignore - File which tells github what files to not track (optional)
  • .github/workflows/ - Directory containing the configuration file for GitHub actions.
  • .github/workflows/test.yml - File detailing the system configurations to use for the tests.