Skip to content

Commit

Permalink
Set up CI with Azure Pipelines that checks that sources are clang-for…
Browse files Browse the repository at this point in the history
…mat'd (#132)

This script runs clang-format on the sources, then runs git status --porcelain on the result, redirected to stderr. If any output goes to stderr, Azure Pipelines marks the build as failed, which enforces that no changes were made to the repo by the clang-format pass.

Resolves #88
  • Loading branch information
BillyONeal authored Sep 25, 2019
1 parent 62482a6 commit a8e1358
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ soon as possible.)
* Tests: **Coming soon.** We rely on three test suites: devcrt, tr1, and [libcxx][]. We need to replace our current test
harness, which extensively uses Microsoft-internal machinery.

* Continuous Integration: **Coming soon.** We need tests first.
* Continuous Integration: **In progress.** We've set up Azure Pipelines to validate changes to the repository.
However, that infrastructure requires manual review before building community-submitted pull requests, as we haven't
yet hardened it against untrusted changes.

* Contribution Guidelines: **Coming soon.** Working on the STL's code involves following many rules. We have codebase
conventions, Standard requirements, Microsoft-specific requirements, binary compatibility (ABI) requirements, and more.
Expand Down
6 changes: 6 additions & 0 deletions azure-devops/enforce-clang-format.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:: Copyright (c) Microsoft Corporation.
:: SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@echo off
clang-format -style=file -i stl/inc/* stl/inc/cvt/* stl/inc/experimental/* stl/src/* 2>&1
echo If your build fails here, you need to format the following files with clang-format 8.0.1.
git status --porcelain 1>&2
10 changes: 10 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
pool: 'STL'

steps:
- task: BatchScript@1
inputs:
filename: 'azure-devops/enforce-clang-format.cmd'
failOnStandardError: true
displayName: 'Enforce clang-format'
2 changes: 0 additions & 2 deletions docs/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ README.md.
- [ ] I understand README.md.
- [ ] If this is a feature addition, that feature has been voted into the C++
Working Draft.
- [ ] Any code files edited have been processed by clang-format 8.0.1.
(The version is important because clang-format's behavior sometimes changes.)
- [ ] Identifiers in any product code changes are properly `_Ugly` as per
https://eel.is/c++draft/lex.name#3.1 .
- [ ] Identifiers in test code changes are *not* `_Ugly`.
Expand Down

0 comments on commit a8e1358

Please sign in to comment.