diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml new file mode 100644 index 000000000..8b823cddd --- /dev/null +++ b/.github/workflows/cpp.yml @@ -0,0 +1,73 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: C++ + +on: + + pull_request: + branches: + - master + + push: + branches: + - master + +jobs: + + format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Format (clang-format) + run: | + sudo apt-get install clang-format-9 + find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-9 -i + git diff --exit-code + + - name: Format (buildifier) + run: | + go get -u github.com/bazelbuild/buildtools/buildifier + export PATH=$PATH:$(go env GOPATH)/bin + find . -name "BUILD" | xargs -n1 buildifier -mode=check + - name: Format (addlicense) + run: | + go get -u github.com/google/addlicense + export PATH=$PATH:$(go env GOPATH)/bin + addlicense -check . + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Mount bazel cache + uses: actions/cache@v1 + with: + path: "/home/runner/.cache/bazel" + key: bazel + + - name: Install bazelisk + run: | + curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64" + mkdir -p "${GITHUB_WORKSPACE}/bin/" + mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel" + chmod +x "${GITHUB_WORKSPACE}/bin/bazel" + + - name: Test + run: | + "${GITHUB_WORKSPACE}/bin/bazel" test //...