Skip to content

Commit

Permalink
Merge pull request #88 from nixel2007/develop
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
nixel2007 authored Mar 19, 2024
2 parents 229bd51 + 5171503 commit 037bf7f
Show file tree
Hide file tree
Showing 9 changed files with 568 additions and 33 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
oscript_version: ['1.8.3', 'stable']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Onescript Action
uses: otymko/setup-onescript@v1.1
uses: otymko/setup-onescript@v1.4
with:
version: ${{ matrix.oscript_version }}

Expand All @@ -28,22 +28,26 @@ jobs:
opm install [email protected]
opm install -l --dev
- name: Prepare macOS env
if: matrix.os == 'macos-latest'
run: |
echo "SIGN_QEMU_BINARY=1" >> "$GITHUB_ENV"
- name: Install docker
if: matrix.os != 'windows-latest'
uses: crazy-max/ghaction-setup-docker@v1
uses: crazy-max/ghaction-setup-docker@v3
timeout-minutes: 12

- name: Setup PostgreSQL
if: matrix.os != 'windows-latest'
shell: bash
run: |
docker run --rm --name postgres -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USERNAME=postgres -e POSTGRES_DB=postgres -e POSTGRES_HOST_AUTH_METHOD=password --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 postgres
docker run --rm --name postgres -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USERNAME=postgres -e POSTGRES_DB=postgres -e POSTGRES_HOST_AUTH_METHOD=password --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 satrapu/postgresql
docker ps
while [ "`docker inspect -f {{.State.Health.Status}} postgres`" != "healthy" ]; do docker ps && sleep 2; done
docker ps
- name: Run tests
env:
TESTRUNNER_RUN_POSTGRES_TESTS: "${{ matrix.os != 'windows-latest' }}"
TESTRUNNER_RUN_POSTGRES_TESTS: true
TESTRUNNER_RUN_SQLITE_TESTS: "${{ matrix.os == 'windows-latest' }}"
run: |
oscript ./tasks/test.os
46 changes: 24 additions & 22 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- name: Setup Onescript Action
uses: otymko/setup-onescript@v1.1
uses: otymko/setup-onescript@v1.4
with:
version: "1.8.3"

Expand All @@ -25,7 +25,7 @@ jobs:
opm install -l --dev
- name: Install docker
uses: crazy-max/ghaction-setup-docker@v1
uses: crazy-max/ghaction-setup-docker@v3
timeout-minutes: 12

- name: Setup PostgreSQL
Expand All @@ -50,28 +50,30 @@ jobs:
run: |
oscript ./tasks/coverage.os
- name: SonarCloud Scan on push
if: github.repository == 'nixel2007/entity' && github.event_name == 'push'
uses: nixel2007/[email protected]
- name: Setup sonarqube
uses: warchant/setup-sonar-scanner@v8

# Анализ проекта в SonarQube (ветка)
- name: Анализ в SonarQube (branch)
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.host.url=https://sonar.openbsl.ru
-Dsonar.branch.name=${{ env.BRANCH_NAME }}
-Dsonar.projectVersion=${{ steps.extract_version.outputs.version }}
- name: SonarCloud Scan on PR
if: github.repository == 'nixel2007/entity' && github.event_name == 'pull_request'
uses: nixel2007/sonarcloud-github[email protected]
run: sonar-scanner
-Dsonar.host.url=https://sonar.openbsl.ru
-Dsonar.branch.name=${{ env.BRANCH_NAME }}
-Dsonar.projectVersion=${{ steps.extract_version.outputs.version }}

# Анализ проекта в SonarQube (PR)
# https://docs.sonarqube.org/latest/analysis/pull-request/
- name: Анализ в SonarQube (pull-request)
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.host.url=https://sonar.openbsl.ru
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }}
run: sonar-scanner
-Dsonar.host.url=https://sonar.openbsl.ru
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
steps:
# Загрузка проекта
- name: Актуализация
uses: actions/checkout@v3
uses: actions/checkout@v4

# Установка OneScript конкретной версии
- name: Установка OneScript
uses: otymko/setup-onescript@v1.1
uses: otymko/setup-onescript@v1.4
with:
version: ${{ matrix.oscript_version }}

Expand All @@ -41,7 +41,7 @@ jobs:
run: opm build .

- name: Заливка артефактов
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: package.zip
path: ./${{ env.PACKAGE_MASK }}
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* <a href="#library-structure-connector-sqlite">КоннекторSQLite</a>
* <a href="#library-structure-connector-postgresql">КоннекторPostgreSQL</a>
* <a href="#library-structure-connector-json">КоннекторJSON</a>
* <a href="#library-structure-connector-inmemory">КоннекторInMemory</a>
* <a href="#versioning-strategy">Версионирование и обратная совместимость</a>

<a id="entity-example" />
Expand Down Expand Up @@ -522,6 +523,16 @@

Все операциями по записи и удалению сущностей одного типа проводятся **синхронно**, блокируя файл таблицы целиком. Для контроля над синхронным доступом используется библиотека [semaphore](https://github.com/nixel2007/semaphore).

<a id="library-structure-connector-inmemory" />

### КоннекторInMemory

В состав библиотеки входит референсная реализация интерфейса коннектора в виде упрощенного коннектора к виртуальной базе данных в памяти. База данных состоит из соответствия, где ключ - имя таблицы модели данных, значение таблицы.

В качестве строки соединения произвольная строка, которая будет являться разделителем данных.

Коннектор поддерживает все CRUD-операции над сущностями, простой и сложный поиск, но не поддерживает работу с транзакциями. При вызове операций по работе с транзакциями будут выданы исключения.

<a id="versioning-strategy" />

## Версионирование и обратная совместимость
Expand Down
1 change: 1 addition & 0 deletions lib.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<class name="ОбъектМодели" file="src/Классы/ОбъектМодели.os"/>
<class name="ЭлементОтбора" file="src/Классы/ЭлементОтбора.os"/>
<class name="ХранилищеСущностей" file="src/Классы/ХранилищеСущностей.os"/>
<class name="КоннекторInMemory" file="src/Классы/КоннекторInMemory.os"/>
<module name="ТипыКолонок" file="src/Модули/ТипыКолонок.os"/>
<module name="ТипыПодчиненныхТаблиц" file="src/Модули/ТипыПодчиненныхТаблиц.os"/>
<module name="ВидСравнения" file="src/Модули/ВидСравнения.os"/>
Expand Down
2 changes: 1 addition & 1 deletion packagedef
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// BSLLS:CodeOutOfRegion-off
Описание.Имя("entity")
.Версия("2.3.5.0")
.Версия("2.3.6.0")
.Автор("Nikita Gryzlov")
.АдресАвтора("[email protected]")
.Описание("entity")
Expand Down
24 changes: 24 additions & 0 deletions src/internal/Модули/ХранилищеВПамяти.os
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Перем КешиТаблиц;

Функция КешТаблиц(СтрокаПодключения = "default") Экспорт
Результат = КешиТаблиц.Получить(СтрокаПодключения);

Если Результат = Неопределено Тогда
Результат = Новый Соответствие();
КешиТаблиц.Вставить(СтрокаПодключения, Результат);
КонецЕсли;

Возврат Результат;

КонецФункции

Процедура Очистить(СтрокаПодключения = "default") Экспорт
КешиТаблиц.Вставить(СтрокаПодключения, Новый Соответствие());
КонецПроцедуры

Процедура Инициализация()
КешиТаблиц = Новый Соответствие();
КонецПроцедуры

Инициализация();
Loading

0 comments on commit 037bf7f

Please sign in to comment.