From 94d01a97d997eec4749a3c165f8d5ff662af1b7a Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Mon, 1 May 2023 16:46:13 +0100 Subject: [PATCH] add ci --- .github/workflows/ci-pytest.yml | 46 +++++++++++++++++++++++++++ .github/workflows/code-formatting.yml | 34 ++++++++++++++++++++ .pre-commit-config.yaml | 12 +++++++ 3 files changed, 92 insertions(+) create mode 100644 .github/workflows/ci-pytest.yml create mode 100644 .github/workflows/code-formatting.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci-pytest.yml b/.github/workflows/ci-pytest.yml new file mode 100644 index 0000000..74e9d62 --- /dev/null +++ b/.github/workflows/ci-pytest.yml @@ -0,0 +1,46 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: CI - Python-based Testing + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10'] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade pip + run: | + pip install --upgrade pip + + - name: Install the package locally + run: pip install -e . + + - name: Test with pytest + run: | + pytest -W error + + #- name: Execute lit tests + # run: | + # export PYTHONPATH=$(pwd) + # lit -v tests/filecheck/ diff --git a/.github/workflows/code-formatting.yml b/.github/workflows/code-formatting.yml new file mode 100644 index 0000000..90c2468 --- /dev/null +++ b/.github/workflows/code-formatting.yml @@ -0,0 +1,34 @@ +# This workflow check the format all files in the repository +# * It checks that all nonempty files have a newline at the end +# * It checks that there are no whitespaces at the end of lines +# * It checks that Python files are formatted with black + +name: Code Formatting + +on: + pull_request: + push: + branches: [master] + +jobs: + code-formatting: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10'] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade pip + run: | + pip install --upgrade pip + + - name: Run code formatting checks with pre-commit + uses: pre-commit/action@v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..99da409 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer +- repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black