[#164] wip: Add clang-format
Some checks failed
DCO action / DCO (pull_request) Successful in 1m19s
Tests and linters / Tests (pull_request) Successful in 1m55s
Tests and linters / Tests with -race (pull_request) Successful in 2m45s
Tests and linters / Lint (pull_request) Successful in 3m19s
Tests and linters / Check clang-format (pull_request) Has been cancelled

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2024-11-06 14:34:34 +03:00
parent f5df03c718
commit af5f29e1ff
Signed by: achuprov
GPG key ID: 2D916FFD803B0EDD
2 changed files with 50 additions and 0 deletions

View file

@ -20,6 +20,39 @@ jobs:
- name: Run linters - name: Run linters
run: make lint run: make lint
clang-format:
name: Check clang-format
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore LLVM
id: cache-primes-restore
uses: actions/cache/restore@v4
with:
path: |
bin/linters/clang/clang-format
key: ${{ runner.os }}-clang
- name: Run clang-format
run: make clang
- name: Save LLVM Cache
id: cache-primes-save
uses: actions/cache/save@v4
with:
path: |
bin/linters/clang/clang-format
key: ${{ runner.os }}-clang
# - name: Print diff
# run: git diff HEAD
# - name: Check that nothing has changed
# run: git diff-index --exit-code HEAD
tests: tests:
name: Tests name: Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -5,6 +5,7 @@ REPO ?= $(shell go list -m)
VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop") VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
GO_VERSION ?= 1.22 GO_VERSION ?= 1.22
LINT_VERSION ?= 1.60.3 LINT_VERSION ?= 1.60.3
LLVM_VERSION ?= 19.1.3
TRUECLOUDLAB_LINT_VERSION ?= 0.0.7 TRUECLOUDLAB_LINT_VERSION ?= 0.0.7
BINDIR = bin BINDIR = bin
@ -74,6 +75,22 @@ lint:
fi fi
$(LINT_DIR)/golangci-lint run --timeout=5m $(LINT_DIR)/golangci-lint run --timeout=5m
clang:
@if [ ! -d "$(OUTPUT_LINT_DIR)/clang" ]; then \
make clang-install; \
fi
# @$(OUTPUT_LINT_DIR)/clang/clang-format -i **/*.js
clang-install:
@mkdir -p $(TMP_DIR)/llvm
@curl -L -o $(TMP_DIR)/llvm/llv-$(LLVM_VERSION)-linux-x64.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LLVM_VERSION)/LLVM-$(LLVM_VERSION)-Linux-X64.tar.xz
@mkdir -p $(OUTPUT_LINT_DIR)/clang
@tar -xJf $(TMP_DIR)/llvm/llv-$(LLVM_VERSION)-linux-x64.tar.xz --strip-components=2 -C $(OUTPUT_LINT_DIR)/clang LLVM-$(LLVM_VERSION)-Linux-X64/bin/clang-format
@rm -r $(TMP_DIR) 2>/dev/null || true
llvm-version:
@echo $(LLVM_VERSION)
# Install linters # Install linters
lint-install: lint-install:
@rm -rf $(OUTPUT_LINT_DIR) @rm -rf $(OUTPUT_LINT_DIR)