diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index 42fe353..2a9d76e 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -20,6 +20,44 @@ jobs: - name: Run linters run: make lint + clang-format: + name: Check clang-format + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - 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: name: Tests runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index b834155..6cbd393 100644 --- a/Makefile +++ b/Makefile @@ -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") GO_VERSION ?= 1.22 LINT_VERSION ?= 1.60.3 +LLVM_VERSION ?= 19.1.3 TRUECLOUDLAB_LINT_VERSION ?= 0.0.7 BINDIR = bin @@ -74,6 +75,22 @@ lint: fi $(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 lint-install: @rm -rf $(OUTPUT_LINT_DIR)