Skip to content

Commit 66078fb

Browse files
authored
Continuous integration (#3)
* Continuous integration * Use Python version matrix * Fix typing * Add CI badge * Add more badges * Add codecov * Update PyPI version badge
1 parent 6f775e9 commit 66078fb

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed

.github/workflows/CI.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: 'Build and test fjsplib using ${{ matrix.python-version }}'
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
python-version: ['3.9', '3.12']
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Update pip and poetry
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install poetry
26+
- name: Cache Python dependencies
27+
uses: actions/cache@v4
28+
id: cache-python
29+
with:
30+
path: ~/.cache/pypoetry
31+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
32+
- name: Install Python dependencies
33+
if: steps.cache-python.outputs.cache-hit != 'true'
34+
run: poetry install
35+
- name: Cache pre-commit
36+
uses: actions/cache@v4
37+
id: cache-pre-commit
38+
with:
39+
path: ~/.cache/pre-commit/
40+
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
41+
- name: Install pre-commit
42+
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
43+
run: poetry run pre-commit install --install-hooks
44+
- name: Run pre-commit
45+
run: poetry run pre-commit run --all-files
46+
- name: Run tests
47+
run: poetry run pytest
48+
- if: matrix.python-version == '3.9'
49+
name: Upload coverage reports to Codecov
50+
uses: codecov/codecov-action@v4.0.1
51+
env:
52+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
53+
slug: leonlan/FJSPLIB

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# FJSPLIB
2+
![PyPI](https://img.shields.io/pypi/v/FJSPLIB?style=flat-square)
3+
![License](https://img.shields.io/pypi/l/FJSPLIB?style=flat-square)
4+
![CI](https://img.shields.io/github/actions/workflow/status/leonlan/FJSPLIB/.github%2Fworkflows%2FCI.yml?style=flat-square)
5+
![Codecov](https://img.shields.io/codecov/c/github/leonlan/FJSPLIB?style=flat-square)
26

37
FJSPLIB is a Python package for reading and writing flexible job shop problem (FJSP) instances.

fjsplib/read.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from dataclasses import dataclass
22
from pathlib import Path
3+
from typing import Union
34

45
ProcessingData = list[tuple[int, int]]
56
Arc = tuple[int, int]
@@ -115,7 +116,7 @@ def read(loc: Path) -> Instance:
115116
)
116117

117118

118-
def file2lines(loc: Path | str) -> list[list[int]]:
119+
def file2lines(loc: Union[Path, str]) -> list[list[int]]:
119120
with open(loc, "r") as fh:
120121
lines = [line for line in fh.readlines() if line.strip()]
121122

pyproject.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ repository = "https://github.com/leonlan/FJSPLIB"
1111
python = "^3.9"
1212
numpy = "^1.26.4"
1313

14-
1514
[tool.poetry.group.dev.dependencies]
16-
pytest = "^7.1.2"
1715
pre-commit = "^2.19.0"
16+
pytest = "^7.1.2"
17+
pytest-cov = ">=2.6.1"
1818

1919

2020
[tool.black]
2121
line-length = 79
2222

2323

24+
[tool.mypy]
25+
ignore_missing_imports = true
26+
27+
2428
[tool.ruff]
2529
line-length = 79
2630

27-
2831
[tool.ruff.lint]
2932
ignore-init-module-imports = true
3033
select = [
@@ -36,8 +39,9 @@ case-sensitive = true
3639
known-first-party = ["fjsplib", "tests"]
3740

3841

39-
[tool.mypy]
40-
ignore_missing_imports = true
42+
[tool.pytest.ini_options]
43+
addopts = "--cov=. --cov-report=xml --cov-report=term"
44+
testpaths = "tests"
4145

4246

4347
[build-system]

0 commit comments

Comments
 (0)