Skip to content

Commit

Permalink
add github check workflow
Browse files Browse the repository at this point in the history
Change-Id: Iad9c4718ee80a7d16d461ab12e447134c604243e
  • Loading branch information
oliverlee committed Aug 20, 2024
1 parent 55a28fc commit 71d7295
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example
80 changes: 80 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: check

on:
push:
branches: [ main ]
pull_request:
branches: [ "*" ]
types: [synchronize, opened, reopened, edited]
workflow_dispatch:

jobs:
buildifier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- shell: bash
run: |
bazel run //tools:buildifier.check
check-tidy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
bazel:
#- latest
- 7.x
#- 6.x
#- 5.x
compiler:
- clang-18
#- clang-17
#- clang-16
#- clang-15
#- clang-14
example:
- misc-unused-alias-decls

steps:
- name: install ${{ matrix.compiler }}
shell: bash
run: |
version=$(echo ${{ matrix.compiler }} | cut -d'-' -f2)
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh $version
sudo ln -sf $(which clang-tidy-$version) /usr/bin/clang-tidy
clang-tidy --version
clang-tidy-$version --version
ls -al /usr/bin
- uses: actions/checkout@v4

- name: run clang-tidy
shell: bash
env:
USE_BAZEL_VERION: ${{ matrix.bazel }}
CC: ${{ matrix.compiler }}
run: |
cd example/${{ matrix.example }}
if [[ "${{ matrix.bazel }}" < 6 ]]; then
sed -i '/enable_bzlmod/d' .bazelrc
fi
bazel build --announce_rc --config=clang-tidy --color=yes //... | tee log || true
grep "error: .*${{ matrix.example }}" log
all:
runs-on: ubuntu-latest
if: ${{ github.base_ref == 'main' }}
needs:
- buildifier
- check-tidy
steps:
- run: true
5 changes: 5 additions & 0 deletions example/misc-unused-alias-decls/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
common --enable_bzlmod=false

build:clang-tidy --aspects=@rules_clang_tidy//:aspects.bzl%check
build:clang-tidy --output_groups=report

4 changes: 4 additions & 0 deletions example/misc-unused-alias-decls/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cc_binary(
name = "main",
srcs = ["main.cpp"],
)
4 changes: 4 additions & 0 deletions example/misc-unused-alias-decls/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local_repository(
name = "rules_clang_tidy",
path = "../..",
)
8 changes: 8 additions & 0 deletions example/misc-unused-alias-decls/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>

namespace std2 = ::std;

auto main() -> int
{
std::cout << "hello, world!" << '\n';
}

0 comments on commit 71d7295

Please sign in to comment.