Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/scripts/test_analyze_parse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Smoke test: run CodeChecker analyze + parse on a trivial source file.
set -euo pipefail

WORK="${RUNNER_TEMP:-/tmp}/analyze-test"
mkdir -p "$WORK"

cat > "$WORK/main.c" <<'EOF'
int main() { int i = 1 / 0; return i; }
EOF

cat > "$WORK/compile_commands.json" <<EOF
[{"directory": "$WORK", "command": "gcc -c $WORK/main.c", "file": "$WORK/main.c"}]
EOF

# analyze exits 0: clangsa, clang-tidy, cppcheck all succeed.
# gcc has no checkers enabled but is not considered a failure.
CodeChecker analyze "$WORK/compile_commands.json" -o "$WORK/reports"

# parse exits 2: at least one report was emitted (division by zero).
COUNT="$( (CodeChecker parse "$WORK/reports" -e json; rc=$?; [ $rc -eq 2 ] || exit $rc) | jq '.reports | length')"
if [ "$COUNT" -lt 1 ]; then
echo "ERROR: Expected at least one report, got $COUNT" >&2
exit 1
fi

echo "OK: found $COUNT report(s)"
18 changes: 18 additions & 0 deletions .github/scripts/verify_data_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Verify that CodeChecker data files are installed in the expected location.
set -euo pipefail

DATA_DIR="$(python -c "import sysconfig; print(sysconfig.get_path('data'))")"
CFG_DIR="$DATA_DIR/share/codechecker/config"

if [ ! -d "$CFG_DIR" ]; then
echo "ERROR: Config dir missing: $CFG_DIR" >&2
exit 1
fi

if [ ! -f "$CFG_DIR/package_layout.json" ]; then
echo "ERROR: package_layout.json missing in $CFG_DIR" >&2
exit 1
fi

echo "OK: data files verified in $CFG_DIR"
108 changes: 108 additions & 0 deletions .github/workflows/pip-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: pip install

on:
push:
branches: [master]
paths:
- 'setup.py'
- 'pyproject.toml'
- 'MANIFEST.in'
- 'config/**'
- 'codechecker_common/**'
- 'analyzer/**'
- 'web/**'
- 'tools/**'
- '.github/workflows/pip-install.yml'
- '.github/scripts/**'
pull_request:
paths:
- 'setup.py'
- 'pyproject.toml'
- 'MANIFEST.in'
- 'config/**'
- 'codechecker_common/**'
- 'analyzer/**'
- 'web/**'
- 'tools/**'
- '.github/workflows/pip-install.yml'
- '.github/scripts/**'

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pip-install-smoke:
name: "pip install (${{ matrix.os }}, Python ${{ matrix.python }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest, windows-latest]
python: ['3.9', '3.12', '3.13']

steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}

- name: pip install .
run: pip install .

- name: Smoke test
run: |
CodeChecker --help
CodeChecker version
report-converter --help
merge-clang-extdef-mappings --help
post-process-stats --help
tu_collector --help

- name: Verify data files installed
shell: bash
run: .github/scripts/verify_data_files.sh

pip-install-editable:
name: "pip install -e . (ubuntu, Python 3.12)"
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: '3.12'

- name: pip install -e .
run: pip install -e .

- name: Smoke test
run: |
CodeChecker --help
CodeChecker version

pip-install-analyze:
name: "pip install + analyze (ubuntu, Python 3.12)"
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: '3.12'

- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y clang clang-tidy cppcheck jq

- name: pip install .
run: pip install .

- name: Test analyze and parse
run: .github/scripts/test_analyze_parse.sh
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ venv_dev
.coverage
Makefile.local

# Generated config files (copied/extended from sub-project dirs by setup.py)
config/analyzer_version.json
config/web_version.json
config/git_commit_urls.json
config/session_client.json
config/system_comment_kinds.json
config/server_config.json

# Setuptools artifacts
*.egg-info
dist

/web/server/vue-cli/dist

# tools
Expand Down
9 changes: 8 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
recursive-include build_dist/CodeChecker/lib/python3/codechecker_report_converter/report/output/html/static *
recursive-include tools/report-converter/codechecker_report_converter/report/output/html/static *
recursive-include config *
recursive-include analyzer/config *
recursive-include web/config *
recursive-include web/server/config *
include LICENSE.TXT
include docs/README.md
include analyzer/requirements.txt
include web/requirements.txt
12 changes: 12 additions & 0 deletions codechecker_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ def get_data_files_dir_path():
if os.path.exists(data_dir_path):
return data_dir_path

# Editable / development install fallback: config/ lives at the
# repository root, which is the parent of this package's directory.
repo_root = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir)
)
if os.path.isfile(
os.path.join(repo_root, "pyproject.toml")
) and os.path.isfile(
os.path.join(repo_root, "config", "package_layout.json")
):
return repo_root

print("Failed to get CodeChecker data files directory path in: ",
data_dir_paths)
sys.exit(1)
Expand Down
23 changes: 23 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,29 @@ set the `BUILD_UI_DIST` environment variable to `NO` before the package build:
- Use `make standalone_package` instead of `make package` to avoid
having to manually activate the environment before running CodeChecker.

### Alternative: `pip install`

```sh
# Standard install:
pip install .

# Editable install (source changes take effect immediately):
pip install -e .

# Verify:
CodeChecker version
```

#### `make package` vs `pip install`

| Feature | `make package` | `pip install` |
|---------|---------------|---------------|
| Static analysis (`analyze`, `parse`, `check`) | supported | supported |
| Build logging (`CodeChecker log`) | supported (with ldlogger 32+64 bit on Linux and `intercept-build` on OSX) | **not** supported (unless you use `intercept-build` on OSX) |
| Web server and storage | supported | supported, but must build API packages with `make package_api`, then `pip install api/py/codechecker_api/dist/codechecker_api.tar.gz api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz` |
| Web frontend (Vue.js UI) | supported | **not** supported |
| Editable / development install | **not** supported | supported (`pip install -e .`) |

### Minimum Recommended package versions

* In production it is recommended to execute CodeChecker with the minimum Python versions: 3.7.14, 3.8.14, 3.9.14, 3.10.6, 3.11.0, otherwise it may be vulnerable to open-redirect attacks. For more info see https://python-security.readthedocs.io/vuln/http-server-redirection.html (CVE-2021-28861).
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

[tool.mypy]
verbosity = 1
show_error_codes = true
Expand Down
Loading
Loading