Skip to content

Commit

Permalink
Merge pull request Yikai-Liao#6 from Natooz/tests-ci
Browse files Browse the repository at this point in the history
Tests CI workflows
  • Loading branch information
Yikai-Liao authored Dec 20, 2023
2 parents 0ed98ad + 15cd9a9 commit 01678c7
Show file tree
Hide file tree
Showing 17 changed files with 1,032 additions and 1,328 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Lint

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

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
env:
RUFF_OUTPUT_FORMAT: github
45 changes: 45 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run tests

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

jobs:
tests:
name: Tests on ${{ matrix.os }} with python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# os: [ ubuntu-latest, macOS-latest, windows-latest ]
os: [ ubuntu-latest ]
python-version: [ "3.7", "3.x", "pypy3.9" ]
exclude:
- os: macos-latest
python-version: "pypy3.9"

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py

- name: Install dependencies
run: |
# Install local package with tests dependencies extras
python -m pip install --upgrade pip
pip install -e ".[test]"
- name: Test with pytest
run: pytest --cov=./ --cov-report=xml -n auto --durations=0 -v

- name: Codecov
uses: codecov/[email protected]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
**/settings.json
**/__pycache__
**/*.pyc
**/.vscode
**/.vscode
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

The library is written in cpp and based on [minimidi](https://github.com/lzqlzzq/minimidi/tree/main). It offers a python binding using pybind11.

Here, we have added a tutorial.ipynb for you to learn about how to use the library.
Here, we have added a tutorial.ipynb for you to learn about how to use the library.

Tutorial and Benchmark: <a target="_blank" href="https://colab.research.google.com/github/Yikai-Liao/symusic/blob/main/tutorial.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
Expand Down Expand Up @@ -71,5 +71,3 @@ pip install ./symusic
* [pybind11-stubgen](https://github.com/sizmailov/pybind11-stubgen) A nice tool to generate stub files for pybind11 projects.
* [zpp_bits](https://github.com/eyalz800/zpp_bits) : An extraordinary fast and lightweight single header library for serialization and deserialization. I use it to support pickle.
* [geek_time_cpp](https://github.com/adah1972/geek_time_cpp/tree/master) The example code of the book "Modern C++ Programming Practice". We use the [metamacro.h](https://github.com/adah1972/geek_time_cpp/blob/master/40/metamacro.h#L1-L622) in it for shortening the code.


2 changes: 1 addition & 1 deletion generate_stub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ python3 setup.py build bdist_wheel
pip install dist/*.whl
pybind11-stubgen symusic.core --numpy-array-remove-parameters -o .
pip uninstall -y symusic
rm -rf dist build *.egg-info
rm -rf dist build *.egg-info
2 changes: 1 addition & 1 deletion include/MetaMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,4 @@
#define PAIR(x) EXPAND x // PAIR((int) x) => EXPAND(int) x => int x
#define STRIP(x) EAT x // STRIP((int) x) => EAT(int) x => x

#endif // METAMACRO_H
#endif // METAMACRO_H
18 changes: 9 additions & 9 deletions include/Score.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ inline std::string strip_non_utf_8(const std::string *str) {
}

if (c < 127) { //normal ASCII
to.append(1, c);
to.append(1, c);
continue;
}
}
//control char (nothing should be defined here either ASCII, ISO_8859-1 or UTF8, so skipping)
if (c < 160) {
//fix microsoft mess, add euro
Expand All @@ -70,19 +70,19 @@ inline std::string strip_non_utf_8(const std::string *str) {
to.append(1, 10);
to.append(1, 13);
} continue;
}
}
//invalid for UTF8, converting ASCII
if (c < 192) {
to.append(1, (unsigned char) 194);
to.append(1, c);
continue;
}
}
//invalid for UTF8, converting ASCII
if (c < 194) {
to.append(1, (unsigned char) 195);
to.append(1, c - 64);
continue;
}
}
//possibly 2byte UTF8
if (c < 224 && i + 1 < f_size) {
const u8 c2 = static_cast<u8>((*str)[i + 1]);
Expand All @@ -94,7 +94,7 @@ inline std::string strip_non_utf_8(const std::string *str) {
to.append(1, c2);
} i++; continue;
}
}
}
//possibly 3byte UTF8
else if (c < 240 && i + 2 < f_size) {
const u8 c2 = static_cast<u8> ((*str)[i + 1]),
Expand All @@ -106,7 +106,7 @@ inline std::string strip_non_utf_8(const std::string *str) {
to.append(1, c3);
i += 2; continue;
}
}
}
//possibly 4byte UTF8
else if (c < 245 && i + 3 < f_size) {

Expand Down Expand Up @@ -1270,7 +1270,7 @@ Score<T>::Score(const minimidi::file::MidiFile &midi) {
uint32_t duration = cur_tick - note_on.time;
track.notes.emplace_back(
// note_on.time, duration,
helper.convert_ttype<T>(note_on.time),
helper.convert_ttype<T>(note_on.time),
helper.convert_ttype<T>(duration),
pitch, note_on.velocity
);
Expand Down Expand Up @@ -1505,4 +1505,4 @@ minimidi::file::MidiFile Score<T>::to_midi() const {
return midi;
} // Score<T>::to_midi end
} // namespace score end
#endif //SCORE_HPP
#endif //SCORE_HPP
File renamed without changes.
Loading

0 comments on commit 01678c7

Please sign in to comment.