| name: Formatting |
| |
| on: |
| push: |
| branches: |
| - main |
| pull_request: |
| types: |
| - opened |
| - synchronize |
| |
| jobs: |
| code-format-checks: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v2 |
| - name: Buildifier |
| run: | |
| wget "https://github.com/bazelbuild/buildtools/releases/download/v${BUILDIFIER_VERSION}/buildifier-linux-amd64" -O buildifier |
| chmod +x ./buildifier |
| ./buildifier -lint=warn -mode=check -warnings=all -r ${{ github.workspace }} |
| rm ./buildifier |
| env: |
| BUILDIFIER_VERSION: 8.0.2 |
| - uses: DoozyX/clang-format-lint-action@v0.14 |
| with: |
| source: '.' |
| extensions: 'h,c,cc,proto,java,m' |
| clangFormatVersion: 14 |
| - uses: actionsx/prettier@v2 |
| with: |
| args: --config "${{ github.workspace }}/.prettierrc.toml" --write "**/*.{js,mjs,cjs,jsx,ts,tsx}" |
| # Prettier has no diff view so we must make one ourselves |
| # https://github.com/prettier/prettier/issues/6885 |
| - run: | |
| git diff |
| if [[ -n "$(git status --porcelain)" ]]; then |
| exit 1 |
| fi |
| - name: Set up Python |
| uses: actions/setup-python@v2 |
| with: |
| python-version: 3.11 |
| - name: Install dependencies |
| run: | |
| pip install 'black==24.10.0' 'isort==5.13.2' |
| - name: Run black |
| run: | |
| python -m black --check --diff ./ |
| - name: Run isort |
| run: | |
| python -m isort --profile=black --check-only ./ |