diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml deleted file mode 100644 index 9c9562a64a..0000000000 --- a/.github/workflows/check-labels.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Check PR Labels -on: - pull_request: - types: [opened, reopened, synchronize, labeled, unlabeled] - -env: - triggerLabelFull: "tests-requested: full" - triggerLabelQuick: "tests-requested: quick" - statusLabelInProgress: "tests: in-progress" - statusLabelFailed: "tests: failed" - -jobs: - check_integration_test_labels: - # This check fails if integration tests are queued, in progress, or failed. - runs-on: ubuntu-latest - steps: - - uses: docker://agilepathway/pull-request-label-checker:latest - with: - none_of: "${{ env.statusLabelInProgress }},${{ env.statusLabelFailed }},${{ env.triggerLabelFull }},${{ env.triggerLabelQuick }}" - repo_token: ${{ github.token }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000000..341cb33bc5 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,44 @@ +name: Checks + +on: + pull_request: + types: [opened, reopened, synchronize, labeled, unlabeled] + +env: + triggerLabelFull: "tests-requested: full" + triggerLabelQuick: "tests-requested: quick" + statusLabelInProgress: "tests: in-progress" + statusLabelFailed: "tests: failed" + +jobs: + check_integration_test_labels: + # This check fails if integration tests are queued, in progress, or failed. + runs-on: ubuntu-latest + steps: + - uses: docker://agilepathway/pull-request-label-checker:latest + with: + none_of: "${{ env.statusLabelInProgress }},${{ env.statusLabelFailed }},${{ env.triggerLabelFull }},${{ env.triggerLabelQuick }}" + repo_token: ${{ github.token }} + file_format_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: false + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install prerequisites + run: python scripts/gha/install_prereqs_desktop.py + - name: log clang format version + shell: bash + run: clang-format --version + - name: git fetch origin main + shell: bash + run: git fetch origin main + - name: Detect Formatting Changes + shell: bash + run: python3 scripts/format_code.py -git_diff -noformat_file -verbose + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3bc342a7cb..5d0584c2af 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,6 +118,11 @@ Before you submit your pull request consider the following guidelines: * Follow our [Coding Rules](#rules). * Avoid checking in files that shouldn't be tracked (e.g `.tmp`, `.idea`). We recommend using a [global](#global-gitignore) gitignore for this. +* Format your code: + ```shell + python3 scripts/format_code.py -git_diff -verbose + ``` + * Commit your changes using a descriptive commit message. ```shell diff --git a/scripts/format_code.py b/scripts/format_code.py index c75dd923e6..ac5811142e 100755 --- a/scripts/format_code.py +++ b/scripts/format_code.py @@ -39,20 +39,20 @@ # Flag Definitions: FLAGS = flags.FLAGS -flags.DEFINE_boolean("git_diff", False, "Use git-diff to assemble a file list") -flags.DEFINE_string("git_range", "origin/main..", "the range string when using " - "git-diff.") -flags.DEFINE_multi_string("f", None, "Append the filename to the list of " - "files to check.") -flags.DEFINE_multi_string("d", None, - "Append the directory to the file list to format.") -flags.DEFINE_boolean("r", False, +flags.DEFINE_boolean('git_diff', False, 'Use git-diff to assemble a file list') +flags.DEFINE_string('git_range', 'origin/main..', 'the range string when using ' + 'git-diff.') +flags.DEFINE_multi_string('f', None, 'Append the filename to the list of ' + 'files to check.') +flags.DEFINE_multi_string('d', None, + 'Append the directory to the file list to format.') +flags.DEFINE_boolean('r', False, "Recurse through the directory's children When formatting a target directory.") -flags.DEFINE_boolean("format_file", True, "Format files in place.") -flags.DEFINE_boolean("verbose", False, "Execute in verbose mode.") +flags.DEFINE_boolean('format_file', True, 'Format files in place.') +flags.DEFINE_boolean("verbose", False, 'Execute in verbose mode.') # Constants: -FILE_TYPE_EXTENSIONS = (".cpp", ".cc", ".c", ".h") +FILE_TYPE_EXTENSIONS = ('.cpp', '.cc', '.c', '.h') """Tuple: The file types to run clang-format on. Used to filter out results when searching across directories or git diffs. """ @@ -73,7 +73,7 @@ def does_file_need_formatting(filename): for line in result.stdout.decode('utf-8').splitlines(): if line.strip().startswith("