Skip to content

Commit 19a72db

Browse files
committed
use separate crates for different entry points
1 parent 2e25fec commit 19a72db

File tree

79 files changed

+833518
-6
lines changed

Some content is hidden

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

79 files changed

+833518
-6
lines changed

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.py text eol=lf
7+
*.rst text eol=lf
8+
*.sh text eol=lf
9+
*.cpp text eol=lf
10+
*.hpp text eol=lf
11+
*.patch text eol=lf

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: 2bndy5

.github/stale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_extends: .github

.github/workflows/binary-builds.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Binary executable builds
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches: [main]
9+
tags:
10+
- v[0-9]+.*
11+
pull_request:
12+
branches: [main]
13+
14+
env:
15+
CARGO_INCREMENTAL: 0
16+
CARGO_NET_GIT_FETCH_WITH_CLI: true
17+
CARGO_NET_RETRY: 10
18+
CARGO_TERM_COLOR: always
19+
RUST_BACKTRACE: 1
20+
RUSTFLAGS: -D warnings
21+
RUSTUP_MAX_RETRIES: 10
22+
23+
defaults:
24+
run:
25+
shell: bash
26+
27+
jobs:
28+
29+
create-assets:
30+
name: ${{ matrix.target }}
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- target: aarch64-unknown-linux-gnu
36+
os: ubuntu-latest
37+
- target: aarch64-unknown-linux-musl
38+
os: ubuntu-latest
39+
- target: x86_64-unknown-linux-gnu
40+
os: ubuntu-latest
41+
- target: x86_64-unknown-linux-musl
42+
os: ubuntu-latest
43+
- target: aarch64-apple-darwin
44+
os: macos-latest
45+
- target: x86_64-apple-darwin
46+
os: macos-latest
47+
- target: x86_64-pc-windows-msvc
48+
os: windows-latest
49+
runs-on: ${{ matrix.os }}
50+
permissions:
51+
contents: write
52+
steps:
53+
- name: Calculate Release Version
54+
id: calc-version
55+
run: |
56+
if [ "${{ github.event_name }}" = "pull_request" ]; then
57+
short_sha=$(echo "${{ github.sha }}" | awk '{print substr($0,0,5)}')
58+
echo "RELEASE_VERSION=nightly-$(date '+%Y-%m-%d')-$short_sha" >> $GITHUB_OUTPUT
59+
else
60+
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
61+
fi
62+
63+
- name: Install native OpenSSL on Linux
64+
if: runner.os == 'Linux' && !(startsWith(matrix.target, 'aarch64') || endsWith(matrix.target, 'musl'))
65+
run: sudo apt-get install -y pkg-config libssl-dev
66+
- name: Install GCC for aarch64 (for cross-compiling openssl)
67+
if: runner.os == 'Linux' && startsWith(matrix.target, 'aarch64')
68+
run: |
69+
if [[ "${{matrix.target}}" == *musl ]]; then
70+
sudo apt-get install musl-dev musl-tools
71+
else
72+
sudo apt-get install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
73+
fi
74+
- name: Install musl-gcc (fom compiling OpenSSL)
75+
if: matrix.target == 'x86_64-unknown-linux-musl'
76+
run: sudo apt-get install musl-tools
77+
78+
- name: Calculate openssl-vendored
79+
shell: bash
80+
id: is-openssl-vendored
81+
run: |
82+
case "${{ matrix.target }}" in
83+
"aarch64-apple-darwin" | "x86_64-apple-darwin" | "aarch64-unknown-linux-gnu" | "aarch64-unknown-linux-musl" | "x86_64-unknown-linux-musl")
84+
echo "enabled=--features openssl-vendored" >> $GITHUB_OUTPUT
85+
;;
86+
*)
87+
echo "enabled=" >> $GITHUB_OUTPUT
88+
;;
89+
esac
90+
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
94+
- name: Setup Rust
95+
uses: dtolnay/rust-toolchain@stable
96+
with:
97+
target: ${{ matrix.target }}
98+
99+
- name: Build
100+
run: cargo build --manifest-path cpp-linter-cli/Cargo.toml --release --bin cpp-linter-cli --target ${{ matrix.target }} ${{ steps.is-openssl-vendored.outputs.enabled }}
101+
102+
- name: Prepare artifacts [Windows]
103+
shell: bash
104+
if: matrix.os == 'windows-latest'
105+
id: prep-artifacts-windows
106+
run: |
107+
release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
108+
artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.zip"
109+
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
110+
mkdir $release_dir
111+
cp target/${{ matrix.target }}/release/cpp-linter-cli.exe $release_dir/
112+
cp LICENSE $release_dir/
113+
7z a -tzip $artifact_path $release_dir/
114+
- name: Prepare artifacts [Unix]
115+
shell: bash
116+
id: prep-artifacts-unix
117+
if: matrix.os != 'windows-latest'
118+
run: |
119+
release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
120+
artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz"
121+
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
122+
mkdir $release_dir
123+
cp target/${{ matrix.target }}/release/cpp-linter-cli $release_dir/
124+
cp LICENSE $release_dir
125+
tar -czvf $artifact_path $release_dir/
126+
- name: Upload artifacts
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
130+
path: ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
131+
if-no-files-found: error
132+
133+
create-release:
134+
if: startswith(github.ref, 'refs/tags')
135+
runs-on: ubuntu-latest
136+
needs: [create-assets]
137+
permissions:
138+
contents: write
139+
steps:
140+
- uses: actions/checkout@v4
141+
with:
142+
persist-credentials: false
143+
- name: Install Rust
144+
run: rustup update stable --no-self-update
145+
- run: cargo package
146+
- name: Create a Github Release
147+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
148+
env:
149+
GH_TOKEN: ${{ github.token }}
150+
run: gh release create ${{ github.ref_name }} --generate-notes
151+
- run: cargo publish
152+
working-directory: cpp-linter-lib
153+
env:
154+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
155+
156+
upload-assets:
157+
needs: [create-release]
158+
runs-on: ubuntu-latest
159+
strategy:
160+
matrix:
161+
target:
162+
- aarch64-unknown-linux-gnu
163+
- aarch64-unknown-linux-musl
164+
- x86_64-unknown-linux-gnu
165+
- x86_64-unknown-linux-musl
166+
- aarch64-apple-darwin
167+
- x86_64-apple-darwin
168+
- x86_64-pc-windows-msvc
169+
steps:
170+
- name: Download build asset
171+
uses: actions/download-artifact@v4
172+
with:
173+
name: cpp-linter-cli-${{ matrix.target }}
174+
path: dist
175+
- name: Upload release assets
176+
env:
177+
GH_TOKEN: ${{ github.token }}
178+
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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Docs
2+
3+
on: [push, workflow_dispatch]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- uses: actions/setup-python@v5
12+
with:
13+
python-version: 3.x
14+
15+
- name: Install docs dependencies
16+
working-directory: cpp-linter-py
17+
run: pip install -r docs/requirements.txt
18+
19+
- name: Build docs
20+
working-directory: cpp-linter-py
21+
run: sphinx-build docs docs/_build/html
22+
23+
- name: upload docs build as artifact
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: "cpp-linter-py-docs"
27+
path: cpp-linter-py/docs/_build/html
28+
29+
- name: upload to github pages
30+
# only publish doc changes from main branch
31+
if: github.ref == 'refs/heads/main'
32+
uses: peaceiris/actions-gh-pages@v3
33+
with:
34+
github_token: ${{ secrets.GITHUB_TOKEN }}
35+
publish_dir: cpp-linter-py/docs/_build/html
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Pre-commit
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: opened
7+
8+
jobs:
9+
check-source-files:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.x'
16+
- run: python3 -m pip install pre-commit
17+
- run: pre-commit run --all-files
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Python packaging
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- '*'
10+
pull_request:
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
linux:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.10'
28+
29+
- name: Calculate openssl-vendored
30+
shell: bash
31+
id: is-openssl-vendored
32+
run: |
33+
if [[ "${{ startsWith(matrix.target, 'x86') }}" == "true" ]]; then
34+
echo "enabled=" >> $GITHUB_OUTPUT
35+
else
36+
echo "enabled=--features openssl-vendored" >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: Build wheels
40+
uses: PyO3/maturin-action@v1
41+
with:
42+
target: ${{ matrix.target }}
43+
args: --manifest-path cpp-linter-py/Cargo.toml --release --out dist --find-interpreter ${{ steps.is-openssl-vendored.outputs.enabled }}
44+
manylinux: auto
45+
before-script-linux: |
46+
case "${{ matrix.target }}" in
47+
"aarch64" | "armv7" | "s390x" | "ppc64le")
48+
# NOTE: pypa/manylinux docker images are Debian based
49+
sudo apt-get update
50+
sudo apt-get install -y pkg-config libssl-dev
51+
;;
52+
"x86" | "x86_64")
53+
# NOTE: rust-cross/manylinux docker images are CentOS based
54+
yum update -y
55+
yum install -y openssl openssl-devel
56+
;;
57+
esac
58+
- name: Upload wheels
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: wheels-linux-${{ matrix.target }}
62+
path: dist/*
63+
64+
windows:
65+
runs-on: windows-latest
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
target: [x64, x86]
70+
steps:
71+
- uses: actions/checkout@v4
72+
- uses: actions/setup-python@v5
73+
with:
74+
python-version: '3.10'
75+
architecture: ${{ matrix.target }}
76+
- name: Build wheels
77+
uses: PyO3/maturin-action@v1
78+
with:
79+
target: ${{ matrix.target }}
80+
args: --manifest-path cpp-linter-py/Cargo.toml --release --out dist --find-interpreter
81+
- name: Upload wheels
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: wheels-windows-${{ matrix.target }}
85+
path: dist/*
86+
87+
macos:
88+
runs-on: macos-latest
89+
strategy:
90+
fail-fast: false
91+
matrix:
92+
target: [x86_64, aarch64]
93+
steps:
94+
- uses: actions/checkout@v4
95+
- uses: actions/setup-python@v5
96+
with:
97+
python-version: '3.10'
98+
- name: Build wheels
99+
uses: PyO3/maturin-action@v1
100+
with:
101+
target: ${{ matrix.target }}
102+
args: --manifest-path cpp-linter-py/Cargo.toml --release --out dist --find-interpreter --features openssl-vendored
103+
- name: Upload wheels
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: wheels-macos-${{ matrix.target }}
107+
path: dist/*
108+
109+
sdist:
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@v4
113+
- name: Build sdist
114+
uses: PyO3/maturin-action@v1
115+
with:
116+
command: sdist
117+
args: --manifest-path cpp-linter-py/Cargo.toml --out dist
118+
- name: Upload sdist
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: wheels-sdist
122+
path: dist/*
123+
124+
release:
125+
name: Release
126+
runs-on: ubuntu-latest
127+
if: startsWith(github.ref, 'refs/tags/')
128+
needs: [linux, windows, macos, sdist]
129+
steps:
130+
- uses: actions/download-artifact@v4
131+
with:
132+
path: dist
133+
- run: mv dist/**/*.{whl,gz} dist/
134+
- name: Publish to PyPI
135+
uses: PyO3/maturin-action@v1
136+
env:
137+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
138+
with:
139+
command: upload
140+
args: --non-interactive --skip-existing dist/*

0 commit comments

Comments
 (0)