Skip to content

Commit 5dbb587

Browse files
authored
add more testing and various improvements (#4)
* avoid making relative paths from non-project source's path * move pre-commit local hooks into CI workflow * separate CLI options into categories and add a version subcommand (to print cpp-linter version) * consolidate cpp-linter-cli crate into cpp-linter-lib crate. * increment version in toml during CI runs * use cross tool in CI to build standalone binary executables * add cargo ecosystem to dependabot config * conditionally truncate thread comment length * check in cargo.lock for caching in CI * uses tokio to spawn async tasks for running clang-format/tidy on each file * allow filtering files per clang tool
1 parent 3ffe78b commit 5dbb587

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3667
-1205
lines changed

.gitattributes

+16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@
55
# to native line endings on checkout.
66
*.py text eol=lf
77
*.rst text eol=lf
8+
*.css text eol=lf
9+
*.md text eol=lf
10+
*.rs text eol=lf
11+
*.yaml text eol=lf
12+
*.toml text eol=lf
13+
*.lock text eol=lf
14+
*.yml text eol=lf
815
*.sh text eol=lf
916
*.cpp text eol=lf
1017
*.hpp text eol=lf
1118
*.patch text eol=lf
19+
*.diff text eol=lf
20+
.gitattributes text eol=lf
21+
.gitmodules text eol=lf
22+
.gitignore text eol=lf
23+
*.txt text eol=lf
24+
*.json text eol=lf
25+
*.code-workspace text eol=lf
26+
*.clang-tidy text eol=lf
27+
*.clang-format text eol=lf

.github/dependabot.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: github-actions
9+
directory: /
10+
schedule:
11+
interval: "weekly"
12+
groups:
13+
actions:
14+
patterns:
15+
- "*"
16+
- package-ecosystem: pip
17+
directory: cpp-linter-py/
18+
schedule:
19+
interval: "daily"
20+
groups:
21+
pip:
22+
patterns:
23+
- "*"
24+
- package-ecosystem: cargo
25+
directories:
26+
- cpp-linter-lib/
27+
- cpp-linter-py/
28+
schedule:
29+
interval: "daily"
30+
ignore:
31+
- dependency-name: cpp-linter-lib
32+
groups:
33+
cargo:
34+
patterns:
35+
- "*"

.github/workflows/binary-builds.yml

+87-109
Original file line numberDiff line numberDiff line change
@@ -34,118 +34,110 @@ jobs:
3434
include:
3535
- target: aarch64-unknown-linux-gnu
3636
os: ubuntu-latest
37-
## I GIVE UP! For this target, OpenSSL needs to be cross compiled
38-
## which is driven by openssl-sys crate's custom build script...
39-
## Linux users with aarch64 (aka ARM64) using musl C lib can go fish (or build from source).
40-
# - target: aarch64-unknown-linux-musl
41-
# os: ubuntu-latest
37+
vendered: true
38+
cross: true
39+
- target: aarch64-unknown-linux-musl
40+
os: ubuntu-latest
41+
vendered: true
42+
cross: true
4243
- target: x86_64-unknown-linux-gnu
4344
os: ubuntu-latest
45+
vendered: false
46+
cross: false
4447
- target: x86_64-unknown-linux-musl
4548
os: ubuntu-latest
49+
vendered: true
50+
cross: true
51+
- target: arm-unknown-linux-gnueabi
52+
os: ubuntu-latest
53+
vendered: true
54+
cross: true
55+
- target: arm-unknown-linux-gnueabihf
56+
os: ubuntu-latest
57+
vendered: true
58+
cross: true
59+
- target: armv7-unknown-linux-gnueabihf
60+
os: ubuntu-latest
61+
vendered: true
62+
cross: true
63+
- target: powerpc-unknown-linux-gnu
64+
os: ubuntu-latest
65+
vendered: true
66+
cross: true
67+
- target: powerpc64-unknown-linux-gnu
68+
os: ubuntu-latest
69+
vendered: true
70+
cross: true
71+
- target: powerpc64le-unknown-linux-gnu
72+
os: ubuntu-latest
73+
vendered: true
74+
cross: true
75+
- target: s390x-unknown-linux-gnu
76+
os: ubuntu-latest
77+
vendered: true
78+
cross: true
4679
- target: aarch64-apple-darwin
4780
os: macos-latest
81+
vendered: true
82+
cross: false
4883
- target: x86_64-apple-darwin
4984
os: macos-latest
85+
vendered: true
86+
cross: false
5087
- target: x86_64-pc-windows-msvc
5188
os: windows-latest
89+
vendered: false
90+
cross: false
91+
- target: aarch64-pc-windows-msvc
92+
os: windows-latest
93+
vendered: false
94+
cross: false
5295
runs-on: ${{ matrix.os }}
5396
permissions:
5497
contents: write
5598
steps:
56-
- name: Calculate Release Version
57-
id: calc-version
58-
run: |
59-
if [ "${{ github.event_name }}" = "pull_request" ]; then
60-
short_sha=$(echo "${{ github.sha }}" | awk '{print substr($0,0,5)}')
61-
echo "RELEASE_VERSION=nightly-$(date '+%Y-%m-%d')-$short_sha" >> $GITHUB_OUTPUT
62-
else
63-
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
64-
fi
65-
66-
- name: Install native OpenSSL on Linux
67-
if: runner.os == 'Linux' && !(startsWith(matrix.target, 'aarch64') || endsWith(matrix.target, 'musl'))
68-
run: sudo apt-get install -y pkg-config libssl-dev
69-
- name: Install GCC for aarch64 (for cross-compiling openssl)
70-
if: runner.os == 'Linux' && startsWith(matrix.target, 'aarch64')
71-
run: |
72-
sudo apt-get update
73-
sudo apt-get install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
74-
if [[ "${{matrix.target}}" == *musl ]]; then
75-
sudo apt-get install musl-dev musl-tools
76-
fi
77-
- name: Install musl-gcc (for compiling OpenSSL)
78-
if: matrix.target == 'x86_64-unknown-linux-musl'
79-
run: sudo apt-get install musl-tools
80-
81-
- name: Calculate openssl-vendored
82-
shell: bash
83-
id: is-openssl-vendored
84-
run: |
85-
case "${{ matrix.target }}" in
86-
"aarch64-apple-darwin" | "x86_64-apple-darwin" | "aarch64-unknown-linux-gnu" | "aarch64-unknown-linux-musl" | "x86_64-unknown-linux-musl")
87-
echo "enabled=--features openssl-vendored" >> $GITHUB_OUTPUT
88-
;;
89-
*)
90-
echo "enabled=" >> $GITHUB_OUTPUT
91-
;;
92-
esac
93-
9499
- name: Checkout
95100
uses: actions/checkout@v4
96101

102+
- uses: actions/setup-python@v5
103+
if: startsWith(github.ref, 'refs/tags/')
104+
with:
105+
python-version: '3.x'
106+
107+
- name: Increment version
108+
if: startsWith(github.ref, 'refs/tags/')
109+
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
110+
97111
- name: Setup Rust
98112
uses: dtolnay/rust-toolchain@stable
99113
with:
100114
target: ${{ matrix.target }}
101115

102-
# problems with cross-compiling linux with musl
103-
- run: echo "RUSTFLAGS=-D warnings -C target-feature=+crt-static -C link-self-contained=yes" >> "${GITHUB_ENV}"
104-
if: contains(matrix.target, '-linux-musl')
105-
- run: |
106-
echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
107-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
108-
if: matrix.target == 'aarch64-unknown-linux-musl'
116+
- name: Install cross (cargo cross compiler)
117+
if: matrix.cross
118+
uses: taiki-e/install-action@v2
119+
with:
120+
tool: cross
121+
122+
- name: Build (native)
123+
if: ${{ !matrix.cross }}
124+
run: cargo build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}
109125

110-
- name: Build
111-
env:
112-
# problems with cross-compiling aarch64 linux with gnu
113-
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: /usr/bin/aarch64-linux-gnu-gcc
114-
run: cargo build --manifest-path cpp-linter-cli/Cargo.toml --release --bin cpp-linter-cli --target ${{ matrix.target }} ${{ steps.is-openssl-vendored.outputs.enabled }}
126+
- name: Build (cross)
127+
if: matrix.cross
128+
run: cross build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}
115129

116-
- name: Prepare artifacts [Windows]
117-
shell: bash
118-
if: matrix.os == 'windows-latest'
119-
id: prep-artifacts-windows
120-
run: |
121-
release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
122-
artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.zip"
123-
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
124-
mkdir $release_dir
125-
cp target/${{ matrix.target }}/release/cpp-linter-cli.exe $release_dir/
126-
cp LICENSE $release_dir/
127-
7z a -tzip $artifact_path $release_dir/
128-
- name: Prepare artifacts [Unix]
129-
shell: bash
130-
id: prep-artifacts-unix
131-
if: matrix.os != 'windows-latest'
132-
run: |
133-
release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
134-
artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz"
135-
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
136-
mkdir $release_dir
137-
cp target/${{ matrix.target }}/release/cpp-linter-cli $release_dir/
138-
cp LICENSE $release_dir
139-
tar -czvf $artifact_path $release_dir/
130+
- name: Prepare artifacts
131+
run: mv target/${{ matrix.target }}/release/cpp-linter${{ runner.os == 'Windows' && '.exe' || '' }} ./cpp-linter-${{ matrix.target }}${{ runner.os == 'Windows' && '.exe' || '' }}
140132
- name: Upload artifacts
141133
uses: actions/upload-artifact@v4
142134
with:
143-
name: ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
144-
path: ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
135+
name: cpp-linter-${{ matrix.target }}
136+
path: cpp-linter-${{ matrix.target }}*
145137
if-no-files-found: error
146138

147139
create-release:
148-
if: startswith(github.ref, 'refs/tags')
140+
if: startswith(github.ref, 'refs/tagsv')
149141
runs-on: ubuntu-latest
150142
needs: [create-assets]
151143
permissions:
@@ -156,38 +148,24 @@ jobs:
156148
persist-credentials: false
157149
- name: Install Rust
158150
run: rustup update stable --no-self-update
151+
- uses: actions/setup-python@v5
152+
with:
153+
python-version: '3.x'
154+
- name: Increment version
155+
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
159156
- run: cargo package
157+
- name: Download built assets
158+
uses: actions/download-artifact@v4
159+
with:
160+
pattern: cpp-linter-*
161+
path: dist
160162
- name: Create a Github Release
161-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
162163
env:
163164
GH_TOKEN: ${{ github.token }}
164-
run: gh release create ${{ github.ref_name }} --generate-notes
165+
run: |
166+
files=$(ls dist/cpp-linter*
167+
gh release create ${{ github.ref_name }} --generate-notes $files
165168
- run: cargo publish
166169
working-directory: cpp-linter-lib
167170
env:
168171
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
169-
170-
upload-assets:
171-
needs: [create-release]
172-
runs-on: ubuntu-latest
173-
strategy:
174-
matrix:
175-
target:
176-
- aarch64-unknown-linux-gnu
177-
# skip this target due to cross-compiling OpenSSL for musl C lib
178-
# - aarch64-unknown-linux-musl
179-
- x86_64-unknown-linux-gnu
180-
- x86_64-unknown-linux-musl
181-
- aarch64-apple-darwin
182-
- x86_64-apple-darwin
183-
- x86_64-pc-windows-msvc
184-
steps:
185-
- name: Download build asset
186-
uses: actions/download-artifact@v4
187-
with:
188-
name: cpp-linter-cli-${{ matrix.target }}
189-
path: dist
190-
- name: Upload release assets
191-
env:
192-
GH_TOKEN: ${{ github.token }}
193-
run: gh release upload ${{ github.ref_name }} dist/cpp-linter-cli${{ contains(matrix.target, 'windows') || '.exe' }}%#%cpp-linter-cli_${{ matrix.target }} --clobber

.github/workflows/build-docs.yml

+45-8
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,73 @@ name: Docs
22

33
on: [push, workflow_dispatch]
44

5+
env:
6+
CARGO_TERM_COLOR: always
7+
58
jobs:
6-
build:
7-
permissions:
8-
contents: write
9+
cache-deps:
910
runs-on: ubuntu-latest
1011
steps:
1112
- uses: actions/checkout@v4
13+
- run: rustup update --no-self-update
14+
- name: Cache .cargo locked resources
15+
uses: actions/cache@v4
16+
with:
17+
path: ~/.cargo
18+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
19+
- run: cargo fetch
1220

21+
build-sphinx:
22+
runs-on: ubuntu-latest
23+
needs: [cache-deps]
24+
steps:
25+
- uses: actions/checkout@v4
1326
- uses: actions/setup-python@v5
1427
with:
1528
python-version: 3.x
1629

17-
- name: Install docs dependencies
30+
- name: Install dependencies
1831
working-directory: cpp-linter-py
1932
run: pip install -r docs/requirements.txt
2033

34+
- name: Cache .cargo locked resources
35+
uses: actions/cache@v4
36+
with:
37+
path: ~/.cargo
38+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
39+
2140
- name: Build docs
2241
working-directory: cpp-linter-py
2342
run: sphinx-build docs docs/_build/html
2443

25-
- name: upload docs build as artifact
44+
- name: Upload docs build as artifact
2645
uses: actions/upload-artifact@v4
2746
with:
28-
name: "cpp-linter-py-docs"
47+
name: cpp-linter-py_docs
2948
path: cpp-linter-py/docs/_build/html
3049

31-
- name: upload to github pages
50+
- name: Upload to github pages
3251
# only publish doc changes from main branch
3352
if: github.ref == 'refs/heads/main'
34-
uses: peaceiris/actions-gh-pages@v3
53+
uses: peaceiris/actions-gh-pages@v4
3554
with:
3655
github_token: ${{ secrets.GITHUB_TOKEN }}
3756
publish_dir: cpp-linter-py/docs/_build/html
57+
58+
build-rustdoc:
59+
runs-on: ubuntu-latest
60+
needs: [cache-deps]
61+
steps:
62+
- uses: actions/checkout@v4
63+
- run: rustup update --no-self-update
64+
- name: Cache .cargo locked resources
65+
uses: actions/cache@v4
66+
with:
67+
path: ~/.cargo
68+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
69+
- run: cargo doc --no-deps --manifest-path cpp-linter-lib/Cargo.toml
70+
- name: upload rustdoc build as artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
path: target/doc
74+
name: cpp-linter-lib_docs

0 commit comments

Comments
 (0)