diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000000000..02b72292b60d3 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,30 @@ +name: Format suggestions + +on: + pull_request: + +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: julia-actions/setup-julia@19bd4db8c427e07d56602f1c432e1a26a55d6735 # v1.8.2 + with: + version: 1 + - shell: julia --color=yes {0} + - run: | + using Pkg + Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.10")) + using JuliaFormatter + format(".", MinimalStyle(); normalize_line_endings = "unix") + - uses: reviewdog/action-suggester@v1 + with: + tool_name: JuliaFormatter + fail_on_error: true + filter_mode: added diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000..6c113d1e33b45 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: v15.0.0 + hooks: + - id: clang-format + types_or: [c++, c]