Skip to content

Commit 7830f07

Browse files
Codebase migration from GitLab (#1)
1. Codebase migrated from internal Gitlab repository 2. Added uv-based CI.
1 parent 7a748d4 commit 7830f07

File tree

108 files changed

+11488
-1
lines changed

Some content is hidden

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

108 files changed

+11488
-1
lines changed

.github/workflows/ci.yml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lints:
10+
name: Run linters
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 15
13+
permissions:
14+
checks: write
15+
pull-requests: write
16+
contents: read
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v2
22+
with:
23+
version: ${{ vars.UV_VERSION || '0.6.9' }}
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.10"
29+
30+
- name: Cache pre-commit
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/.cache/pre-commit
34+
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
35+
36+
- name: Run pre-commit checks
37+
run: |
38+
uv run pre-commit run --all-files --show-diff-on-failure --color always
39+
40+
- name: Run ruff formatter
41+
run: uv run ruff format --check
42+
43+
- name: Run ruff linter
44+
run: uv run ruff check --output-format=github
45+
46+
- name: Run mypy
47+
run: |
48+
uv pip install mypy
49+
uv run mypy .
50+
51+
- name: Run Trivy vulnerability scanner
52+
uses: aquasecurity/trivy-action@master
53+
env:
54+
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db:2,public.ecr.aws/aquasecurity/trivy-db:2
55+
with:
56+
scan-type: "fs"
57+
ignore-unfixed: true
58+
exit-code: 0 # change if you want to fail build on vulnerabilities
59+
severity: "CRITICAL,HIGH,MEDIUM"
60+
skip-dirs: .venv,.ruff_cache,.mypy_cache
61+
format: "table"
62+
output: "trivy-scanning-results.txt"
63+
64+
- name: Format trivy message
65+
run: |
66+
echo "Trivy scanning results." >> trivy.txt
67+
cat trivy-scanning-results.txt >> trivy.txt
68+
69+
70+
tests:
71+
name: Run tests
72+
runs-on: ubuntu-latest
73+
timeout-minutes: 15
74+
permissions:
75+
checks: write
76+
pull-requests: write
77+
contents: write # required for advanced coverage reporting (to keep branch)
78+
strategy:
79+
fail-fast: false # do not stop all jobs if one fails
80+
matrix:
81+
python-version: ["3.10", "3.11", "3.12"]
82+
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Install uv
87+
uses: astral-sh/setup-uv@v2
88+
with:
89+
version: "0.4.20"
90+
91+
- name: Set up Python ${{ matrix.python-version }}
92+
uses: actions/setup-python@v4
93+
with:
94+
python-version: ${{ matrix.python-version }}
95+
96+
- name: Cache Dependencies
97+
uses: actions/cache@v3
98+
with:
99+
path: ~/.cache/uv
100+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
101+
restore-keys: |
102+
${{ runner.os }}-pip-
103+
104+
- name: Cache NLTK data
105+
uses: actions/cache@v3
106+
with:
107+
path: ~/nltk_data
108+
key: nltk-${{ runner.os }}
109+
110+
- name: Install package and dependencies
111+
run: |
112+
uv venv
113+
uv pip install .
114+
115+
- name: Run Tests With Coverage
116+
run: |
117+
# run with coverage to not execute tests twice
118+
uv run coverage run -m pytest -v -p no:warnings --junitxml=report.xml
119+
uv run coverage report
120+
uv run coverage xml
121+
122+
- name: Test Report
123+
uses: mikepenz/action-junit-report@v4
124+
continue-on-error: true
125+
if: always()
126+
with:
127+
report_paths: 'report.xml'
128+
129+
- name: Publish Test Report
130+
uses: actions/upload-artifact@v4
131+
continue-on-error: true
132+
if: always()
133+
with:
134+
name: test-report
135+
path: report.xml
136+
retention-days: 10
137+
138+
# simpler version for code coverage reporting
139+
# - name: Produce Coverage report
140+
# uses: 5monkeys/cobertura-action@v13
141+
# continue-on-error: true
142+
# with:
143+
# path: coverage.xml
144+
# minimum_coverage: 70
145+
# fail_below_threshold: false
146+
147+
# more complex version for better coverage reporting
148+
- name: Produce the coverage report
149+
uses: insightsengineering/coverage-action@v2
150+
continue-on-error: true
151+
with:
152+
# Path to the Cobertura XML report.
153+
path: coverage.xml
154+
# Minimum total coverage, if you want to the
155+
# workflow to enforce it as a standard.
156+
# This has no effect if the `fail` arg is set to `false`.
157+
threshold: 60
158+
# Fail the workflow if the minimum code coverage
159+
# reuqirements are not satisfied.
160+
fail: false
161+
# Publish the rendered output as a PR comment
162+
publish: true
163+
# Create a coverage diff report.
164+
diff: true
165+
# Branch to diff against.
166+
# Compare the current coverage to the coverage
167+
# determined on this branch.
168+
diff-branch: ${{ github.event.repository.default_branch }}
169+
# make report togglable
170+
togglable-report: true
171+
# This is where the coverage reports for the
172+
# `diff-branch` are stored.
173+
# Branch is created if it doesn't already exist'.
174+
diff-storage: _xml_coverage_reports
175+
# A custom title that can be added to the code
176+
# coverage summary in the PR comment.
177+
coverage-summary-title: "Code Coverage Summary"

.github/workflows/docs.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy documentation
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
environment: documentation
14+
permissions:
15+
contents: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v2
21+
with:
22+
version: ${{ vars.UV_VERSION || '0.6.9' }}
23+
24+
- name: Set up Python 3.10
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.10"
28+
29+
- name: Cache Dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/uv
33+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
37+
- name: Install package and dependencies
38+
shell: bash
39+
run: |
40+
uv venv
41+
uv pip install -e .
42+
43+
- name: Deploy docs
44+
shell: bash
45+
run: uv run mkdocs gh-deploy --force

.gitignore

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Directories
2+
.vscode/
3+
.idea/
4+
.neptune/
5+
.pytest_cache/
6+
.mypy_cache/
7+
venv/
8+
__pycache__/
9+
**.egg-info/
10+
11+
# Byte-compiled / optimized / DLL files
12+
__pycache__/
13+
*.py[cod]
14+
*$py.class
15+
16+
# C extensions
17+
*.so
18+
19+
# Distribution / packaging
20+
.Python
21+
env/
22+
build/
23+
develop-eggs/
24+
dist/
25+
downloads/
26+
eggs/
27+
.eggs/
28+
lib/
29+
lib64/
30+
parts/
31+
sdist/
32+
var/
33+
*.egg-info/
34+
.installed.cfg
35+
*.egg
36+
37+
# Sphinx documentation
38+
docs/_build/
39+
public/
40+
# autogenerated package license table
41+
docs/licenses_table.rst
42+
43+
# license dump file
44+
licenses.txt
45+
46+
# File formats
47+
*.onnx
48+
*.pyc
49+
*.pt
50+
*.pth
51+
*.pkl
52+
*.mar
53+
*.torchscript
54+
**/*.db
55+
**/.ipynb_checkpoints
56+
**/dist/
57+
**/checkpoints/
58+
**/outputs/
59+
60+
# Other env files
61+
.python-version
62+
pyvenv.cfg
63+
pip-selfcheck.json
64+
65+
66+
# Unit test / coverage reports
67+
htmlcov/
68+
.tox/
69+
.coverage
70+
.coverage.*
71+
.cache
72+
nosetests.xml
73+
coverage.xml
74+
*,cover
75+
.hypothesis/
76+
77+
# dotenv
78+
.env
79+
80+
# coverage and pytest reports
81+
coverage.xml
82+
report.xml
83+
84+
# CMake
85+
cmake-build-*/
86+
87+
# OS stuff
88+
.DS_Store
89+
90+
**/examples/**/data
91+
**/examples/**/.samples
92+
93+
.pytest/
94+
95+
.binaries/
96+
97+
**/output/

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
default_language_version:
2+
python: python3.10
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: check-case-conflict
8+
- id: check-merge-conflict
9+
- id: trailing-whitespace
10+
exclude: .bumpversion.cfg|notebooks/.*\.py
11+
- id: check-ast
12+
- id: check-added-large-files
13+
- id: check-toml
14+
- id: check-json
15+
- id: check-yaml

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Installation
2+
3+
## Build from source
4+
5+
Dependencies needed to build and run Ragbits from the source code:
6+
7+
1. [**uv**](https://docs.astral.sh/uv/getting-started/installation/)
8+
2. [**python**](https://docs.astral.sh/uv/guides/install-python/) 3.10
9+
10+
11+
## Linting and formatting
12+
We use `ruff` for linting and formatting our code. To format your code, run:
13+
14+
```bash
15+
$ uv run ruff format
16+
```
17+
18+
To lint the code, run:
19+
```bash
20+
$ uv run ruff check --fix
21+
```
22+
23+
## Type checking
24+
We use `mypy` for type checking. To perform type checking, simply run:
25+
26+
```bash
27+
$ uv run mypy .
28+
```
29+
30+
## Testing
31+
We use `pytest` for testing. To run the tests, simply run:
32+
33+
```bash
34+
$ uv run pytest
35+
```

0 commit comments

Comments
 (0)