Skip to content

Commit

Permalink
Make 'make check' more consistent across projects
Browse files Browse the repository at this point in the history
We have decided to remove the prepare-check and prepare-build
targets entirely, relying instead on strongly-worded recommendations
in CONTRIBUTING.md and README.md.

Fixes ogr issue packit#579.

Signed-off-by: Ben Crocker <[email protected]>
  • Loading branch information
bcrocker15 committed Jun 1, 2021
1 parent 900a803 commit ea2640e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
37 changes: 17 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,26 @@ Tests are stored in the [tests](/tests) directory.

Running tests locally:

```
make prepare-check && make check
```

The following packages are installed by 'make prepare-check'
if they are not installed already:
The following packages should be installed beforehand:

python3-flexmock
python3-requre

Or you can run tests in a container:

make prepare-build
make build
make check-in-container
```
make check
```

The following packages are installed by 'make prepare-build'
if they are not installed already:
Or you can run tests in a container; the following packages should be
installed beforehand:

podman
ansible-bender

Then:

make build
make check-in-container

The 'make build' command builds a local image with all the dependencies using
[ansible-bender](https://github.com/ansible-community/ansible-bender);
the 'make check-in-container' command runs the tests in a container created
Expand Down Expand Up @@ -93,16 +91,9 @@ Here are some important and useful targets of [Makefile](/Makefile):
Use [ansible-bender](https://pypi.org/project/ansible-bender) to build container image from [recipe.yaml](recipe.yaml):

```
make prepare-build
make build
```

Install packages needed to run tests:

```
make prepare-check
```

Run tests locally:

```
Expand All @@ -115,6 +106,12 @@ Start shell in a container from the image previously built with `make build`:
make shell
```

Run tests in a container:

```
make check-in-container
```

In a container, do basic checks to verify that ogr can be distributed, installed and imported:

```
Expand Down
16 changes: 0 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@ BASE_IMAGE := fedora:latest
TEST_TARGET ?= ./tests/
PY_PACKAGE := ogr
OGR_IMAGE := ogr
IS_FEDORA := $(shell uname -r | grep -c "\.fc[1-9]")
ifeq ($(IS_FEDORA), 1)
PACKAGE_CHECKER := rpm -q --quiet
PACKAGE_INSTALLER := dnf install
else
PACKAGE_CHECKER := :
PACKAGE_INSTALLER := :
endif

prepare-build:
if ! $(PACKAGE_CHECKER) ansible-bender ; then sudo $(PACKAGE_INSTALLER) ansible-bender ; fi
if ! $(PACKAGE_CHECKER) podman ; then sudo $(PACKAGE_INSTALLER) podman ; fi

build: recipe.yaml
ansible-bender build --build-volumes $(CURDIR):/src:Z -- ./recipe.yaml $(BASE_IMAGE) $(OGR_IMAGE)

prepare-check:
if ! $(PACKAGE_CHECKER) python3-requre ; then sudo $(PACKAGE_INSTALLER) python3-requre ; fi
if ! $(PACKAGE_CHECKER) python3-flexmock ; then sudo $(PACKAGE_INSTALLER) python3-flexmock ; fi

check:
@#`python3 -m pytest` doesn't work here b/c the way requre overrides import system:
@#`AttributeError: module 'importlib_metadata' has no attribute 'distributions'
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ $ pip3 install --user git+https://github.com/packit/ogr.git

### Tests

Run `make prepare-check` before first `make check`.
Make sure to install prerequisite packages before first `make check`,
`make build`, or `make check-in-container`. See CONTRIBUTING.md for
details.

# Contribution notes

Expand Down

0 comments on commit ea2640e

Please sign in to comment.