Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

* @rfprod
Empty file added .github/actions/.gitkeep
Empty file.
31 changes: 31 additions & 0 deletions .github/actions/check-changes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: check-changes
description: Find changes matching a pattern using Git.

inputs:
trunk:
description: The name of the trunk (default branch).
default: main
pattern:
description: A regular expression for giltering Git output.
default: '^.*'
outputs:
change:
description: A string representation of a boolean value denoting presence or absence of changes matching the pattern.
value: ${{ steps.check-changes.outputs.change }}

runs:
using: 'composite'
steps:
- name: Check changes
id: check-changes
shell: bash
run: |
COMPARE_WITH=origin/"$TRUNK"
if [ "$TRUNK" = "" ]; then COMPARE_WITH='HEAD~1'; fi
CHANGE=false
COMMAND=$(git diff --name-only HEAD "$COMPARE_WITH" | grep "$PARRETN" || echo "false")
if [ "$COMMAND" != "false" ]; then CHANGE='true'; fi
echo "change=$(echo ${CHANGE})" >> $GITHUB_OUTPUT
env:
TRUNK: ${{ inputs.trunk }}
PATTERN: ${{ inputs.pattern }}
41 changes: 41 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: setup-environment
description: Create Python venv and install dependencies

inputs:
venv:
description: Python virtual environment path
required: true
install:
description: Indicates whether to install project dependencies
required: false
default: 'true'

runs:
using: "composite"
steps:
- id: setup
shell: bash
run: |
rm -rf "$VENV"
case $VENV in
*py311*)
sudo apt install -y python3.11 python3.11-venv
python3.11 -m venv "$VENV"
;;
*py312*)
sudo apt install -y python3.12 python3.12-venv
python3.12 -m venv "$VENV"
;;
*)
echo "$VENV is not supported"
exit 1
;;
esac
source "$VENV/bin/activate"
python3 --version
if [ "$INSTALL" = "true" ]; then \
python3 -m pip install --quiet -r requirements.txt \
fi
env:
VENV: ${{ inputs.venv }}
INSTALL: ${{ inputs.install }}
51 changes: 51 additions & 0 deletions .github/workflows/validate-codeowners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: validate-codeowners

on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
workflow_call:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.head_ref }}.${{ github.sha }}.validate-codeowners
cancel-in-progress: true

jobs:
codeowners:
runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.codeowners.outputs.matrix }}

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Get codeowners
id: codeowners
run: |
RESULT=$(bash tools/shell/actions/codeowners/codeowners.sh)
echo "matrix=$RESULT" >> $GITHUB_OUTPUT
echo "$RESULT"

validate:
needs: codeowners
runs-on: ubuntu-latest

strategy:
matrix:
name: ${{ fromJSON(needs.codeowners.outputs.matrix) }}

steps:
- name: Validate codeowners
uses: octokit/request-action@v2.x
with:
route: GET /repos/{repository}/collaborators/{collaborator}
repository: ${{ github.repository }}
collaborator: ${{ matrix.name }}
env:
GITHUB_TOKEN: ${{ github.token }}
138 changes: 138 additions & 0 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: validate-pr

on:
pull_request:
branches: [main]

defaults:
run:
shell: bash

concurrency:
group: ${{ github.head_ref }}.${{ github.sha }}.validate-pr
cancel-in-progress: true

jobs:
checks:
runs-on: ubuntu-latest

outputs:
codeowners-change: ${{ steps.codeowners-change.outputs.change }}
src-change: ${{ steps.src-change.outputs.change }}
shelltools-change: ${{ steps.shelltools-change.outputs.change }}

steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: CODEOWNERS shange
id: codeowners-change
uses: ./.github/actions/check-changes
with:
pattern: '^.github/CODEOWNERS'

- name: Source code change
id: src-change
uses: ./.github/actions/check-changes
with:
pattern: '^src'

- name: Shell tools change
id: shelltools-change
uses: ./.github/actions/check-changes
with:
pattern: '^tools'

- name: Print changes
run: |
echo "### Changes" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Name | Value |" >> $GITHUB_STEP_SUMMARY
echo "| ---------- | ------------- |" >> $GITHUB_STEP_SUMMARY
echo "| codeowners | ${CODEOWNERS} |" >> $GITHUB_STEP_SUMMARY
echo "| src | ${SRC} |" >> $GITHUB_STEP_SUMMARY
echo "| tools | ${TOOLS} |" >> $GITHUB_STEP_SUMMARY
env:
CODEOWNERS: ${{ steps.codeowners-change.outputs.change }}
SRC: ${{ steps.src-change.outputs.change }}
SHELLTOOLS: ${{ steps.shelltools-change.outputs.change }}

- name: Setup environment
uses: ./.github/actions/setup-environment
with:
venv: '~/py312-venv'
install: false

- name: Commitlint
run: |
source "$VENV/bin/activate"
python3 -m pip install --upgrade commitizen
git checkout -b premerge
git fetch origin main:main
cz check --rev-range main..premerge
deactivate
env:
VENV: '~/py312-venv'

validate-codeowners:
needs: checks
if: ${{ needs.checks.outputs.codeowners-change == 'true' }}
uses: ./.github/workflows/validate-codeowners.yml
secrets: inherit

premerge-matrix:
needs: checks
runs-on: ubuntu-latest

strategy:
matrix:
venv: ['~/py311-venv', '~/py312-venv']

outputs:
success: ${{ steps.check.outputs.success || 'true' }}

steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup environment
uses: ./.github/actions/check-changes
with:
venv: ${{ matrix.venv }}

- name: Lint tools
if: needs.checks.outputs.shelltools-change == 'true'
run: |
sudo apt install shellcheck
shellcheck tools/actions/**/*.sh

- name: Lint source code
if: needs.checks.outputs.src-change == 'true'
run: |
source "$VENV/bin/activate"
black ./src/ --check
deactivate

- name: Set failure
id: check
if: ${{ failure() || cencelled() }}
run: echo "success=$(echo 'false')" >> $GITHUB_OUTPUT

premerge:
needs: premerge-matrix
if: always()
runs-on: ubuntu-latest

steps:
- name: Check result
run: |
if [[ "$PREMERGE_MATRIX" != "true" ]]; then exit 1; fi
echo "### :rocket: Premerge checks succeeded" >> $GITHUB_STEP_SUMMARY
env:
PREMERGE_MATRIX: ${{ needs.premerge-matrix.outputs.success }}
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"pkief.material-icon-theme",
"atishay-jain.all-autocomplete",
"sadesyllas.vscode-workspace-switcher",
"editorconfig.editorconfig",
"mikestead.dotenv",
"redhat.vscode-yaml",
"ms-python.python",
"foxundermoon.shell-format",
"timonwong.shellcheck",
]
}
36 changes: 36 additions & 0 deletions .vscode/recommended-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"files.encoding": "utf8",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 5000,
"files.hotExit": "onExit",
"files.trimTrailingWhitespace": true,
"[sh]": {
"editor.defaultFormatter": "timonwong.shellcheck"
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"shellcheck.customArgs": ["-x"],
"shellcheck.enable": true,
"shellcheck.enableQuickFix": false,
"shellcheck.exclude": [],
"shellcheck.executablePath": "shellcheck",
"shellcheck.ignoreFileSchemes": ["git", "gitfs"],
"shellcheck.ignorePatterns": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true
},
"shellcheck.run": "onType",
"shellcheck.useWSL": false,
"shellcheck.useWorkspaceRootAsCwd": true,
"yaml.format.enable": true,
"yaml.format.singleQuote": true,
"yaml.format.bracketSpacing": true,
"yaml.format.proseWrap": true,
"yaml.format.printWidth": true,
"yaml.validate": true,
"yaml.hover": true,
"yaml.completion": true
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Vadim
Copyright (c) 2025 rfprod

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# RAG application based on Ollama

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

## Requirments

In order to run own copy of the project one must fulfill the following requirements.

### Core dependencies

- [Python 3.12](https://www.python.org/downloads/release/python-3120/)
- [Git](https://git-scm.com/)

### Virtual environments

It is recommended to use a virtual environment to work on this project.

The following sequence of commands creates an environment, activates the environment, and installs project dependencies.

```bash
python3 -m venv ~/path-to-venv; \
source ~/path-to-venv/bin/activate; \
pip3 install -r ./requirements.txt
```

## Committing changes to the repo

Using [commitizen cli](https://pypi.org/project/commitizen/) is mandatory.
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
black
python-dotenv
langchain
langchain_community
langchain-ollama
langchain-neo4j
scikit-learn
BeautifulSoup4
Loading