Skip to content

Commit 0c24290

Browse files
authored
use separate crates for different entry points (#2)
* skip building `aarch64-unknown-linux-musl` target I GIVE UP Has something to do with cross-compiling OpenSSL. I don't think all the cross-compiling env vars are propagated to the custom build script in `openssl-sys` crate.
1 parent 2e25fec commit 0c24290

File tree

79 files changed

+833548
-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

+833548
-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: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
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+
## 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
42+
- target: x86_64-unknown-linux-gnu
43+
os: ubuntu-latest
44+
- target: x86_64-unknown-linux-musl
45+
os: ubuntu-latest
46+
- target: aarch64-apple-darwin
47+
os: macos-latest
48+
- target: x86_64-apple-darwin
49+
os: macos-latest
50+
- target: x86_64-pc-windows-msvc
51+
os: windows-latest
52+
runs-on: ${{ matrix.os }}
53+
permissions:
54+
contents: write
55+
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+
94+
- name: Checkout
95+
uses: actions/checkout@v4
96+
97+
- name: Setup Rust
98+
uses: dtolnay/rust-toolchain@stable
99+
with:
100+
target: ${{ matrix.target }}
101+
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'
109+
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 }}
115+
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/
140+
- name: Upload artifacts
141+
uses: actions/upload-artifact@v4
142+
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 }}
145+
if-no-files-found: error
146+
147+
create-release:
148+
if: startswith(github.ref, 'refs/tags')
149+
runs-on: ubuntu-latest
150+
needs: [create-assets]
151+
permissions:
152+
contents: write
153+
steps:
154+
- uses: actions/checkout@v4
155+
with:
156+
persist-credentials: false
157+
- name: Install Rust
158+
run: rustup update stable --no-self-update
159+
- run: cargo package
160+
- name: Create a Github Release
161+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
162+
env:
163+
GH_TOKEN: ${{ github.token }}
164+
run: gh release create ${{ github.ref_name }} --generate-notes
165+
- run: cargo publish
166+
working-directory: cpp-linter-lib
167+
env:
168+
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

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

0 commit comments

Comments
 (0)