Skip to content

Commit cfca353

Browse files
committed
Add OSS readiness templates and CI, fix clippy
1 parent 206a35e commit cfca353

22 files changed

Lines changed: 1240 additions & 395 deletions

File tree

.codacy/cli.sh

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/usr/bin/env bash
2+
3+
4+
set -e +o pipefail
5+
6+
# Set up paths first
7+
bin_name="codacy-cli-v2"
8+
9+
# Determine OS-specific paths
10+
os_name=$(uname)
11+
arch=$(uname -m)
12+
13+
case "$arch" in
14+
"x86_64")
15+
arch="amd64"
16+
;;
17+
"x86")
18+
arch="386"
19+
;;
20+
"aarch64"|"arm64")
21+
arch="arm64"
22+
;;
23+
esac
24+
25+
if [ -z "$CODACY_CLI_V2_TMP_FOLDER" ]; then
26+
if [ "$(uname)" = "Linux" ]; then
27+
CODACY_CLI_V2_TMP_FOLDER="$HOME/.cache/codacy/codacy-cli-v2"
28+
elif [ "$(uname)" = "Darwin" ]; then
29+
CODACY_CLI_V2_TMP_FOLDER="$HOME/Library/Caches/Codacy/codacy-cli-v2"
30+
else
31+
CODACY_CLI_V2_TMP_FOLDER=".codacy-cli-v2"
32+
fi
33+
fi
34+
35+
version_file="$CODACY_CLI_V2_TMP_FOLDER/version.yaml"
36+
37+
38+
get_version_from_yaml() {
39+
if [ -f "$version_file" ]; then
40+
local version=$(grep -o 'version: *"[^"]*"' "$version_file" | cut -d'"' -f2)
41+
if [ -n "$version" ]; then
42+
echo "$version"
43+
return 0
44+
fi
45+
fi
46+
return 1
47+
}
48+
49+
get_latest_version() {
50+
local response
51+
if [ -n "$GH_TOKEN" ]; then
52+
response=$(curl -Lq --header "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/codacy/codacy-cli-v2/releases/latest" 2>/dev/null)
53+
else
54+
response=$(curl -Lq "https://api.github.com/repos/codacy/codacy-cli-v2/releases/latest" 2>/dev/null)
55+
fi
56+
57+
handle_rate_limit "$response"
58+
local version=$(echo "$response" | grep -m 1 tag_name | cut -d'"' -f4)
59+
echo "$version"
60+
}
61+
62+
handle_rate_limit() {
63+
local response="$1"
64+
if echo "$response" | grep -q "API rate limit exceeded"; then
65+
fatal "Error: GitHub API rate limit exceeded. Please try again later"
66+
fi
67+
}
68+
69+
download_file() {
70+
local url="$1"
71+
72+
echo "Downloading from URL: ${url}"
73+
if command -v curl > /dev/null 2>&1; then
74+
curl -# -LS "$url" -O
75+
elif command -v wget > /dev/null 2>&1; then
76+
wget "$url"
77+
else
78+
fatal "Error: Could not find curl or wget, please install one."
79+
fi
80+
}
81+
82+
download() {
83+
local url="$1"
84+
local output_folder="$2"
85+
86+
( cd "$output_folder" && download_file "$url" )
87+
}
88+
89+
download_cli() {
90+
# OS name lower case
91+
suffix=$(echo "$os_name" | tr '[:upper:]' '[:lower:]')
92+
93+
local bin_folder="$1"
94+
local bin_path="$2"
95+
local version="$3"
96+
97+
if [ ! -f "$bin_path" ]; then
98+
echo "📥 Downloading CLI version $version..."
99+
100+
remote_file="codacy-cli-v2_${version}_${suffix}_${arch}.tar.gz"
101+
url="https://github.com/codacy/codacy-cli-v2/releases/download/${version}/${remote_file}"
102+
103+
download "$url" "$bin_folder"
104+
tar xzfv "${bin_folder}/${remote_file}" -C "${bin_folder}"
105+
fi
106+
}
107+
108+
# Warn if CODACY_CLI_V2_VERSION is set and update is requested
109+
if [ -n "$CODACY_CLI_V2_VERSION" ] && [ "$1" = "update" ]; then
110+
echo "⚠️ Warning: Performing update with forced version $CODACY_CLI_V2_VERSION"
111+
echo " Unset CODACY_CLI_V2_VERSION to use the latest version"
112+
fi
113+
114+
# Ensure version.yaml exists and is up to date
115+
if [ ! -f "$version_file" ] || [ "$1" = "update" ]; then
116+
echo "ℹ️ Fetching latest version..."
117+
version=$(get_latest_version)
118+
mkdir -p "$CODACY_CLI_V2_TMP_FOLDER"
119+
echo "version: \"$version\"" > "$version_file"
120+
fi
121+
122+
# Set the version to use
123+
if [ -n "$CODACY_CLI_V2_VERSION" ]; then
124+
version="$CODACY_CLI_V2_VERSION"
125+
else
126+
version=$(get_version_from_yaml)
127+
fi
128+
129+
130+
# Set up version-specific paths
131+
bin_folder="${CODACY_CLI_V2_TMP_FOLDER}/${version}"
132+
133+
mkdir -p "$bin_folder"
134+
bin_path="$bin_folder"/"$bin_name"
135+
136+
# Download the tool if not already installed
137+
download_cli "$bin_folder" "$bin_path" "$version"
138+
chmod +x "$bin_path"
139+
140+
run_command="$bin_path"
141+
if [ -z "$run_command" ]; then
142+
fatal "Codacy cli v2 binary could not be found."
143+
fi
144+
145+
if [ "$#" -eq 1 ] && [ "$1" = "download" ]; then
146+
echo "Codacy cli v2 download succeeded"
147+
else
148+
eval "$run_command $*"
149+
fi

.codacy/codacy.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
runtimes:
2+
- node@22.2.0
3+
4+
1
5+
- java@17.0.10
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Bug report
2+
description: File a bug report to help us improve NexumDB
3+
labels: [bug]
4+
title: "bug: "
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to file a bug report.
10+
11+
- type: textarea
12+
id: summary
13+
attributes:
14+
label: Summary
15+
description: A clear and concise description of the problem.
16+
placeholder: The database crashes when executing SELECT ...
17+
validations:
18+
required: true
19+
20+
- type: textarea
21+
id: reproduction
22+
attributes:
23+
label: Steps to Reproduce
24+
description: Provide a minimal set of steps or a query to trigger the issue.
25+
placeholder: |
26+
1. Run nexum
27+
2. Execute: SELECT * FROM users WHERE ...
28+
3. Observe error output
29+
validations:
30+
required: true
31+
32+
- type: textarea
33+
id: expected
34+
attributes:
35+
label: Expected Behavior
36+
description: What should have happened instead?
37+
validations:
38+
required: true
39+
40+
- type: textarea
41+
id: actual
42+
attributes:
43+
label: Actual Behavior
44+
description: What actually happened (include full error messages or logs).
45+
validations:
46+
required: true
47+
48+
- type: textarea
49+
id: environment
50+
attributes:
51+
label: Environment
52+
description: OS, Rust version, Python version, NexumDB version/commit.
53+
placeholder: |
54+
- OS: Ubuntu 22.04
55+
- Rust: 1.74
56+
- Python: 3.11
57+
- Commit: abc123
58+
validations:
59+
required: true
60+
61+
- type: textarea
62+
id: logs
63+
attributes:
64+
label: Logs and Traces
65+
description: Paste relevant logs (wrap in triple backticks) or attach files.
66+
render: shell
67+
68+
- type: checkboxes
69+
id: terms
70+
attributes:
71+
label: Code of Conduct
72+
description: By submitting this issue, you agree to follow our Code of Conduct.
73+
options:
74+
- label: I agree to follow this project's Code of Conduct
75+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Questions or discussions
4+
url: https://github.com/aviralgarg05/NexumDB/discussions
5+
about: Ask questions, brainstorm ideas, or request guidance.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Feature request
2+
description: Suggest an idea or improvement for NexumDB
3+
labels: [enhancement]
4+
title: "feat: "
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for suggesting an improvement!
10+
11+
- type: textarea
12+
id: summary
13+
attributes:
14+
label: Summary
15+
description: What problem does this feature solve? What is the desired outcome?
16+
placeholder: Support SQL JOIN between tables...
17+
validations:
18+
required: true
19+
20+
- type: textarea
21+
id: proposal
22+
attributes:
23+
label: Proposed Solution
24+
description: Describe the solution you'd like to see.
25+
placeholder: Add a JOIN operator with nested loop execution...
26+
validations:
27+
required: true
28+
29+
- type: textarea
30+
id: alternatives
31+
attributes:
32+
label: Alternatives Considered
33+
description: List any alternative solutions or workarounds you have considered.
34+
35+
- type: textarea
36+
id: additional
37+
attributes:
38+
label: Additional Context
39+
description: Add any other context, diagrams, or references to existing issues.
40+
41+
- type: checkboxes
42+
id: terms
43+
attributes:
44+
label: Code of Conduct
45+
description: By submitting this issue, you agree to follow our Code of Conduct.
46+
options:
47+
- label: I agree to follow this project's Code of Conduct
48+
required: true

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Summary
2+
- What does this PR change?
3+
- Why is it needed?
4+
5+
## Testing
6+
- [ ] `cargo fmt --all -- --check`
7+
- [ ] `cargo clippy --workspace --all-targets -- -D warnings`
8+
- [ ] `cargo test --workspace -- --test-threads=1`
9+
- [ ] `python -m compileall nexum_ai`
10+
- [ ] Other (describe):
11+
12+
## Checklist
13+
- [ ] Linked issue (or explained why not)
14+
- [ ] Docs updated (README/CHANGELOG/inline)
15+
- [ ] Added or updated tests
16+
- [ ] Follows Code of Conduct
17+
18+
## Additional Notes
19+
- Risks, deployment notes, or follow-up tasks.

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
rust:
19+
name: Rust fmt, clippy, tests
20+
runs-on: ubuntu-latest
21+
env:
22+
CARGO_TERM_COLOR: always
23+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Rust
29+
uses: dtolnay/rust-toolchain@stable
30+
31+
- name: Cache cargo
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
~/.cargo/registry
36+
~/.cargo/git
37+
target
38+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
39+
restore-keys: ${{ runner.os }}-cargo-
40+
41+
- name: fmt
42+
run: cargo fmt --all -- --check
43+
44+
- name: clippy
45+
run: cargo clippy --workspace --all-targets -- -D warnings
46+
47+
- name: tests
48+
run: cargo test --workspace -- --test-threads=1
49+
50+
python:
51+
name: Python syntax check
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
57+
- name: Set up Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: '3.10'
61+
62+
- name: Byte-compile nexum_ai
63+
run: python -m compileall nexum_ai

0 commit comments

Comments
 (0)