Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous integration #3

Merged
merged 7 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
name: 'Build and test fjsplib using ${{ matrix.python-version }}'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ['3.9', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Update pip and poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Cache Python dependencies
uses: actions/cache@v4
id: cache-python
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: Install Python dependencies
if: steps.cache-python.outputs.cache-hit != 'true'
run: poetry install
- name: Cache pre-commit
uses: actions/cache@v4
id: cache-pre-commit
with:
path: ~/.cache/pre-commit/
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
run: poetry run pre-commit install --install-hooks
- name: Run pre-commit
run: poetry run pre-commit run --all-files
- name: Run tests
run: poetry run pytest
- if: matrix.python-version == '3.9'
name: Upload coverage reports to Codecov
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
slug: leonlan/FJSPLIB
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# FJSPLIB
![PyPI](https://img.shields.io/pypi/v/FJSPLIB?style=flat-square)
![License](https://img.shields.io/pypi/l/FJSPLIB?style=flat-square)
![CI](https://img.shields.io/github/actions/workflow/status/leonlan/FJSPLIB/.github%2Fworkflows%2FCI.yml?style=flat-square)
![Codecov](https://img.shields.io/codecov/c/github/leonlan/FJSPLIB?style=flat-square)

FJSPLIB is a Python package for reading and writing flexible job shop problem (FJSP) instances.
3 changes: 2 additions & 1 deletion fjsplib/read.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dataclasses import dataclass
from pathlib import Path
from typing import Union

ProcessingData = list[tuple[int, int]]
Arc = tuple[int, int]
Expand Down Expand Up @@ -115,7 +116,7 @@ def read(loc: Path) -> Instance:
)


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

Expand Down
14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ repository = "https://github.com/leonlan/FJSPLIB"
python = "^3.9"
numpy = "^1.26.4"


[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"
pre-commit = "^2.19.0"
pytest = "^7.1.2"
pytest-cov = ">=2.6.1"


[tool.black]
line-length = 79


[tool.mypy]
ignore_missing_imports = true


[tool.ruff]
line-length = 79


[tool.ruff.lint]
ignore-init-module-imports = true
select = [
Expand All @@ -36,8 +39,9 @@ case-sensitive = true
known-first-party = ["fjsplib", "tests"]


[tool.mypy]
ignore_missing_imports = true
[tool.pytest.ini_options]
addopts = "--cov=. --cov-report=xml --cov-report=term"
testpaths = "tests"


[build-system]
Expand Down