Repository navigation
110 lines (96 loc) · 3.21 KB
/
Copy pathcpp-lint-package.yml
File metadata and controls
110 lines (96 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: cpp-linter as pkg
on:
workflow_dispatch:
inputs:
branch:
description: 'which branch to test'
default: 'main'
required: true
jobs:
pre-seed-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.extract-version-range.outputs.versions }}
steps:
- env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release download
-R cpp-linter/clang-tools-static-binaries
--pattern versions.json
--output versions.json
- name: Extract version range
id: extract-version-range
shell: python
run: |-
import json
from os import environ
from pathlib import Path
content = Path("versions.json").read_text(encoding="utf-8")
metadata = json.loads(content)
versions = list(metadata["llvm_versions"].keys())
versions.sort()
with open(environ["GITHUB_OUTPUT"], mode="a") as gh_out:
gh_out.write(f"versions={json.dumps(versions)}\n")
cpp-linter:
runs-on: windows-latest
needs: pre-seed-versions
strategy:
matrix:
clang-version: ${{ fromJSON(needs.pre-seed-versions.outputs.versions) }}
repo: ['cpp-linter/cpp-linter']
branch: ['${{ inputs.branch }}']
fail-fast: false
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
submodules: true
- uses: actions/setup-python@v7
with:
python-version: 3.x
- name: Install workflow deps
run: python -m pip install clang-tools git+https://github.com/${{ matrix.repo }}/@${{ matrix.branch }}
- name: Install clang-tools
run: >-
clang-tools install
clang-format clang-tidy
--version ${{ matrix.clang-version }}
--directory ${{ runner.temp }}/llvm
- name: Setup VS dev env
uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: x64
- name: Cache the build artifacts
id: cache-build
uses: actions/cache@v6
with:
path: build
key: ${{ hashFiles('src/CMakeLists.txt', 'src/demo.cpp', 'src/demo.hpp') }}
- name: Generate compiler database
if: steps.cache-build.outputs.cache-hit != 'true'
run: mkdir build && cmake -Bbuild src -G "NMake Makefiles"
- name: Run linter as package
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
cpp-linter
-s=file
-v=debug
-i=build
-p=build
-V=${{ runner.temp }}/llvm
-f=false
--extra-arg="-std=c++14 -Wall"
--thread-comments=${{ matrix.clang-version == '17' && 'update' }}
-a=${{ matrix.clang-version == '17' }}
- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
run: |
echo "some linter checks failed"
echo "total: ${{ steps.linter.outputs.checks-failed }}"
echo "clang-format: ${{ steps.linter.outputs.clang-format-checks-failed }}"
echo "clang-tidy: ${{ steps.linter.outputs.clang-tidy-checks-failed }}"
# for actual deployment
# run: exit 1