An open API service indexing awesome lists of open source software.

https://github.com/bahmanm/prolog-etudes

A collection of etudes for folks new to Prolog (and sometimes experienced ones) to learn the language in a practical fashion.
https://github.com/bahmanm/prolog-etudes

ci-cd circleci codecov learning-exercise prolog swi-prolog

Last synced: 4 months ago
JSON representation

A collection of etudes for folks new to Prolog (and sometimes experienced ones) to learn the language in a practical fashion.

Awesome Lists containing this project

README

        

# prolog-etudes

[![CircleCI](https://dl.circleci.com/status-badge/img/circleci/UMKeFZ8ns9T9vi5aquTfVT/GmMZi7fYoEtn4APsVdADde/tree/main.svg?style=svg&circle-token=357dc9c7b5626a1481100a8b3128a552a29def93)](https://dl.circleci.com/status-badge/redirect/circleci/UMKeFZ8ns9T9vi5aquTfVT/GmMZi7fYoEtn4APsVdADde/tree/main)
[![codecov](https://codecov.io/gh/bahmanm/prolog-etudes/graph/badge.svg?token=R5KPMGJAOY)](https://codecov.io/gh/bahmanm/prolog-etudes)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/bahmanm/prolog-etudes?style=flat&logo=github&label=commits)
[![Matrix](https://img.shields.io/matrix/github-bahmanm-prolog-etudes%3Amatrix.org?server_fqdn=matrix.org&logo=matrix&label=chat&color=%230e80c0)](https://matrix.to/#/#github-bahmanm-prolog-etudes:matrix.org)

A collection of etudes for folks new to Prolog (and sometimes experienced ones) to learn the
language in a practical fashion.
prolog-etudes logo

# How To Run/Test

Assuming you've got all the necessary tools installed (see below), all you'd need to is

```
$ make test

...
% All 22 tests passed in 0.055 seconds (0.053 cpu)
```

### Prerequisites

To run the tests all you need to do is a recent SWI-Prolog and the latest
[bmakelib](https://github.com/bahmanm/bmakelib).

For example, on an openSUSE Tumbleweed machine:

```
# zypper refresh && zypper install swipl make
# rpm --install --nosignature https://github.com/bahmanm/bmakelib/releases/download/v0.7.0/bmakelib-0.7.0-1.1.noarch.rpm
```

# CI Pipeline Setup

_I have used [CircleCI](https://circleci.com/) as the CI service for this project._

You can view the configuration at [.circleci/config.yml](https://github.com/bahmanm/prolog-etudes/blob/c7218f9c64ca430559629ce544aa25dfca53bfb6/.circleci/config.yml).

The highlights are:

* Line 8: [uses the bmakelib Docker image](https://github.com/bahmanm/prolog-etudes/blob/c7218f9c64ca430559629ce544aa25dfca53bfb6/.circleci/config.yml#L8)
from the [bdockerimg project](https://github.com/bahmanm/bdockerimg).
* Line 25: Install SWI-Prolog
* Line 31: Run the tests with the `test.produce-coverage-report=yes` option. This causes the Prolog report coverage files to be generated - more on this below.

### Test Code Coverage Setup

I have opted to use [Codecov](https://about.codecov.io/) as the code coverage service. The integration with Github is quite easy and takes only a few steps.

If you look at [.circleci/config.yml](https://github.com/bahmanm/prolog-etudes/blob/c7218f9c64ca430559629ce544aa25dfca53bfb6/.circleci/config.yml) file again:

* Line 48 and 56: install the Codecov CLI tool
* Line 66: uses codecov-cli to upload the coverage reports to Codecov.

However the problem is that none of the existing code coverage services, including Codecov, support the reports generated by Prolog.

To work around this, I wrote a small Perl program called [coverage-report-converter](bin/coverage-report-converter.pl) to parse the Prolog report and convert it to the format which is used by Go.

![Diagram depicting the CI and code coverage flow](https://imgur.com/a9DfaqI.png)