From 3139e9359cfdccbc3cf00747d8a0c356249f67d9 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Tue, 12 Aug 2025 11:37:26 -0500 Subject: [PATCH 1/2] use pre-commit for format checks --- .github/workflows/check_formatting.yaml | 65 +++---------------------- .github/workflows/pull_request.yaml | 3 -- 2 files changed, 8 insertions(+), 60 deletions(-) diff --git a/.github/workflows/check_formatting.yaml b/.github/workflows/check_formatting.yaml index 78d5b15..278a901 100644 --- a/.github/workflows/check_formatting.yaml +++ b/.github/workflows/check_formatting.yaml @@ -18,71 +18,22 @@ name: Check Formatting on: workflow_call: - inputs: - license_config: - description: "The license configuration file for SkyWalking Eyes" - type: string - required: false - default: ".licenserc.yaml" - cpp_source_dirs: - description: "Space seperated list of dirs to apply clang-format to" - type: string - required: false - default: "include src tests" - format_python: - description: "Whether or not to format python files" - type: boolean - required: false - default: true jobs: - # Check licensing. - check_licensing: - if: inputs.license_config != '' - runs-on: ubuntu-latest - steps: - - name: Checkout Source - uses: actions/checkout@v4 - - name: Check for License Config - if: hashFiles(inputs.license_config) == '' - uses: actions/github-script@v3 - with: - script: | - core.setFailed("License Config file doesn't exist: ${{inputs.license_config}}") - - name: Check License - uses: apache/skywalking-eyes@v0.4.0 - with: - config: ${{ inputs.license_config }} - mode: check - - # Check C++ formatting. - check_cpp_format: - if: inputs.cpp_source_dirs != '' - runs-on: ubuntu-latest - steps: - - name: Checkout Source - uses: actions/checkout@v4 - - name: Check C++ Formatting - uses: DoozyX/clang-format-lint-action@v0.20 - with: - source: ${{ inputs.cpp_source_dirs }} - extensions: "hpp,cpp,ipp,h,c" - clangFormatVersion: 20 - inplace: False - - # Check Python formatting. - check_python_format: - if: inputs.format_python == true + pre-commit: runs-on: ubuntu-latest steps: - name: Checkout Source uses: actions/checkout@v4 + - name: Download .pre-commit-config.yaml + run: wget https://raw.githubusercontent.com/NWChemEx/pre-commit-config/master/.pre-commit-config.yaml + shell: bash - uses: actions/setup-python@v2 with: python-version: "3.x" - - name: Install black - run: pip install black + - name: Install pre-commit + run: pip install pre-commit shell: bash - - name: Check Python Formatting - run: black --check --line-length=79 . + - name: Run pre-commit + run: pre-commit run --all-files shell: bash diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index ebdd206..db54bfb 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -23,9 +23,6 @@ on: jobs: check_formatting: uses: ./.github/workflows/check_formatting.yaml - with: - license_config: ".licenserc.yaml" - cpp_source_dirs: "" # Skip clang-format check test_nwx_docs: uses: ./.github/workflows/test_nwx_docs.yaml From 42db55c9964122d8b44340168a11794742bc317e Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Tue, 12 Aug 2025 14:36:09 -0500 Subject: [PATCH 2/2] review changes --- .github/workflows/check_formatting.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_formatting.yaml b/.github/workflows/check_formatting.yaml index 278a901..1b2a38d 100644 --- a/.github/workflows/check_formatting.yaml +++ b/.github/workflows/check_formatting.yaml @@ -28,12 +28,19 @@ jobs: - name: Download .pre-commit-config.yaml run: wget https://raw.githubusercontent.com/NWChemEx/pre-commit-config/master/.pre-commit-config.yaml shell: bash - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: "3.x" + - name: Create Python virtual environment + run: python -m venv venv + shell: bash - name: Install pre-commit - run: pip install pre-commit + run: | + source venv/bin/activate + pip install pre-commit shell: bash - name: Run pre-commit - run: pre-commit run --all-files + run: | + source venv/bin/activate + pre-commit run --all-files shell: bash