Giter Club home page Giter Club logo

clang-format-checker's People

Contributors

arichardson avatar wolletd avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clang-format-checker's Issues

source-ref parameter isn't used in check-format.sh

I don't acutally know a use case for that parameter, but it should be supported, especially as it's documented.
check-format.sh always used HEAD and doesn't read the $SOURCE_REF variable.

This is fine in GH actions, as the entrypoint.sh checks out the provided source-ref, but it would be neat to use the container or script manually. In that case, it should be like git diff <target> [source=HEAD] and also not check out the source-ref.

I'd say it doesn't even have to check out the source-ref in GH actions anymore when check-format.sh can work from something different than HEAD.

Confusing failure if actions/checkout isn't used

I tried to use clang-format-checker using the following bare-bones config:

on: [push, pull_request]
jobs:
  check-format:
    runs-on: ubuntu-latest
    steps:
      - uses: wolletd/clang-format-checker@v1
        with:
          target-ref: master

This failed in a somewhat confusing way: it aborts after Initializing repository... without any error message.

I eventually figured out that adding - uses: actions/checkout@v3 before the clang-format-checker fixes the problem. Looking at the code it's not clear to me if this working as intended? If it is, then it would be great to mention the need to checkout first in the example config in the README.

Format check fails on json-Files with clang-format <13

clang-format version 13 learned to format JSON fies. Consequenty, git-clang-format of this version also finds and formats .json-files.

Unfortunately, as we only pack the most recent git-clang-format script, when using a clang-format version older than 13, those files are formatted as if they were C++ code.

I'd propose simply packing all versions of git-clang-format and select the appropriate one together with actual clang-format in set-clang-version.

using custom clang-formt file in action

I like the action in general, but miss the feature to pass a custom BasedOnStyle value to clang-format through the yml-file.

It would be sufficient/perfect if the use of a custom .clang-format file would be supported. Maybe it is, but haven't found it?

Latest version no longer works

I have been using this action in various projects but at some point in the past few months it has stopped working and gives an error message that doesn't make much sense to me (for example here https://github.com/CTSRD-CHERI/llvm-project/runs/5399922258?check_suite_focus=true):

/usr/bin/docker run --name wolletdclangformatlatest_6b30b0 --label 7db2d7 --workdir /github/workspace --rm -e INPUT_SOURCE-REF -e INPUT_TARGET-REF -e INPUT_CLANG-VERSION -e INPUT_FETCH-DEPTH -e FETCH_DEPTH -e CLANG_VERSION -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/llvm-project/llvm-project":"/github/workspace" wolletd/clang-format:latest  "dev" "f3071695d3cc[8](https://github.com/CTSRD-CHERI/llvm-project/runs/5399922258?check_suite_focus=true#step:6:8)f23670417bd91281d1fcf7a1c89"
From https://github.com/CTSRD-CHERI/llvm-project
 * branch                f30716[9](https://github.com/CTSRD-CHERI/llvm-project/runs/5399922258?check_suite_focus=true#step:6:9)5d3cc8f23670417bd91281d1fcf7a1c89 -> FETCH_HEAD
fatal: couldn't find remote ref refs/tags/f3071695d3cc8f23670417bd91281d1fcf7a1c89

I don't see anywhere in the script that would emit the couldn't find remove ref error message, only die "fatal: couldn't find ref ${src}". I am also surprised that there is a refs/tags prefix.
The latest successful PR that I can find is 11 Nov 2021, so it must be one of the commits after that. I wonder if the problem is that we are passing an explicit source ref that is just a SHA? source-ref: "${{ github.event.pull_request.head.sha }}"

The github action definition is as follows:


name: Check coding style
on: [pull_request]
defaults:
  run:
    shell: bash
jobs:
  check-format:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Try to fetch required commits
        run: |
          set -xe
          echo "base_ref=${{ github.base_ref }}"
          echo "github.event.pull_request.head.sha=${{ github.event.pull_request.head.sha }}"
          # Based on https://stackoverflow.com/questions/54181901/fetching-only-the-range-of-commits-not-present-in-base-branch
          for ((depth = 8; depth <= 65536; depth *= 2)); do
              echo "trying depth $depth ..."
              git fetch "--depth=$depth" origin "${{ github.base_ref }}:${{ github.base_ref }}"
              git fetch "--depth=$depth" origin "+${{ github.event.pull_request.head.sha }}"
              if git merge-base "${{ github.base_ref }}" "${{ github.event.pull_request.head.sha }}"; then
                  echo "found with depth=$depth"
                  break
              fi
          done
      - name: List commits
        run: git log --oneline "${{ github.base_ref }}..${{ github.event.pull_request.head.sha }}"
      - name: Run clang-format
        uses: wolletd/clang-format-checker@v1
        with:
          source-ref: "${{ github.event.pull_request.head.sha }}"
          target-ref: "${{ github.base_ref }}" # required, merge target
          clang-version: 12     # optional, default: 12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.