From 925c3af21b1de1ba76fe48a5a6b2298f38f25a3c Mon Sep 17 00:00:00 2001 From: Mohamed Awnallah Date: Wed, 27 Dec 2023 07:48:23 +0200 Subject: [PATCH] Add pre-commit ci hooks --- .github/workflows/format-and-lint.yml | 33 --------------------------- .github/workflows/pre-commit.yml | 26 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/format-and-lint.yml create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/format-and-lint.yml b/.github/workflows/format-and-lint.yml deleted file mode 100644 index c961ba4..0000000 --- a/.github/workflows/format-and-lint.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Code format and linting - -on: [pull_request] - -jobs: - format: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: 'pip' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Checking code format with autopep8 - run: autopep8 --diff --exit-code $(git ls-files '*.py') - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: 'pip' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Analysing the code with flake8 - run: flake8 $(git ls-files '*.py') diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..61b31c7 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,26 @@ +name: Pre-commit CI + +on: [push, pull_request] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies + run: pip install -r requirements.txt + + # This will configure the pre-commit hooks in + # '.pre-commit-config.yaml' file. + - name: Configure pre-commit + run: pre-commit install + + - name: Run pre-commit hooks + run: pre-commit run --all-files