From 1f018362d0c5b107e83108e5ce570132cff5778d Mon Sep 17 00:00:00 2001 From: christophkloeffel Date: Wed, 10 Apr 2024 18:40:13 +0200 Subject: [PATCH] adds ci workflow --- .github/workflows/ci.yml | 68 ++++++++++++++++++++++++++++++++++++++ Makefile | 22 ++++++------ lobster/io.py | 10 +++--- lobster/tools/json/json.py | 1 - requirements.txt | 3 ++ requirements_dev.txt | 3 ++ 6 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 requirements.txt create mode 100644 requirements_dev.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..5e978532 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +name: LOBSTER CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + lint: + name: PyLint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements_dev.txt + make lobster/html/assets.py + - name: Executing linter + run: | + make lint + test: + name: TestSuite + needs: lint + if: success() + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + py-version: ["3.8", "3.9", "3.10", "3.11"] + include: + - os: macos-13 + brew: "/usr/local" + - os: macos-14 + brew: "/opt/homebrew" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Install python version + if: matrix.os != 'macos-14' || matrix.py-version == '3.11' || matrix.py-version == '3.12' + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.py-version }} + - name: Install python (3.8, 3.9, 3.10) on macOS-arm64 + if: matrix.os == 'macos-14' && (matrix.py-version == '3.8' || matrix.py-version == '3.9' || matrix.py-version == '3.10') + run: | + brew install python@${{ matrix.py-version }} + echo "${{ matrix.brew }}/opt/python@${{ matrix.py-version }}/libexec/bin" >> $GITHUB_PATH + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python${{ matrix.py-version }} get-pip.py + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + - name: Install gnu make on macos + if: startsWith(matrix.os, 'macos') + run: | + brew install make + echo "${{ matrix.brew }}/opt/make/libexec/gnubin" >> $GITHUB_PATH + - name: Executing system tests + run: | + make system-tests + - name: Executing unit tests + run: | + make unit-tests diff --git a/Makefile b/Makefile index 05d6a805..fa4eccc7 100644 --- a/Makefile +++ b/Makefile @@ -40,37 +40,37 @@ packages: diff -Naur test_install/lib/python*/site-packages/lobster test_install_monolithic/lib/python*/site-packages/lobster -x "*.pyc" diff -Naur test_install/bin test_install_monolithic/bin -integration_tests: packages +integration-tests: packages (cd integration-tests/projects/basic; make) (cd integration-tests/projects/filter; make) -system_tests: +system-tests: make -B -C test-system/lobster-json make -B -C test-system/lobster-python -unit_tests: +unit-tests: python3 -m unittest discover -s test-unit -v -test: integration_tests system_tests unit_tests +test: integration-tests system-tests unit-tests -upload_main: packages +upload-main: packages python3 -m twine upload --repository pypi packages/*/dist/* python3 -m twine upload --repository pypi packages/*/meta_dist/* -remove_dev: +remove-dev: python3 -m util.release -github_release: +github-release: git push python3 -m util.github_release bump: python3 -m util.bump_version_post_release -full_release: - make remove_dev +full-release: + make remove-dev git push - make upload_main - make github_release + make upload-main + make github-release make bump git push diff --git a/lobster/io.py b/lobster/io.py index dea829a5..48e2fa4f 100644 --- a/lobster/io.py +++ b/lobster/io.py @@ -114,7 +114,7 @@ def lobster_read(mh, filename, level, items, source_info=None): if source_info is not None: item.perform_source_checks(source_info) - + # evaluate source_info filters for f, v in source_info['filters']: if f == 'prefix': @@ -125,9 +125,9 @@ def lobster_read(mh, filename, level, items, source_info=None): if all(filter_conditions): if item.tag.key() in items: mh.error(item.location, - "duplicate definition of %s, " - "previously defined at %s" % - (item.tag.key(), - items[item.tag.key()].location.to_string())) + "duplicate definition of %s, " + "previously defined at %s" % + (item.tag.key(), + items[item.tag.key()].location.to_string())) items[item.tag.key()] = item diff --git a/lobster/tools/json/json.py b/lobster/tools/json/json.py index 27fe011b..b4317dbd 100755 --- a/lobster/tools/json/json.py +++ b/lobster/tools/json/json.py @@ -18,7 +18,6 @@ # . import sys -import os.path import json from pathlib import PurePath from pprint import pprint diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..ce3b7498 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +trlc>=1.2.2 +requests>=2.31.0 +libcst>=1.1.0 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 00000000..d7bb926f --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,3 @@ +-r requirements.txt +pycodestyle>=2.11.1 +pylint>=3.1.0