Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate version generation #471

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

aol-nnov
Copy link
Contributor

@aol-nnov aol-nnov commented Sep 4, 2024

Version is now generated automatically based on git tags.
Both cases are handled: building from git tree and building tarball downloaded from github.

Works for qmake and cmake

/cc @fralx

P.S. current work is based on another PR (#470), so, if merged in order, rebase would not be required.

Ru: версия ПО теперь помещается в отдельный хедер. При сборке из склонированных исходников используется git describe, а если код получен тарболом через git archive или скачивание архива с гитхаба (тег или релиз), версия устанавливается в этот момент (благодаря магии в .gitattributes)

@aol-nnov
Copy link
Contributor Author

На что хотелось бы обратить внимание, чтобы облегчить ревью:

в генераторе версии для qmake используется sed (спрятан в $$QMAKE_STREAM_EDITOR). Совместимо ли это с Windows, я проверить не могу.

Такой "изящный ход" был предпринят ради использования одного version.h.in в обоих системах сборки, а плейсходлеры в нем симейковские - @@. В кумейке есть схожий механизм, но там надо $$. Отсюда дилемма.

Вообще, я делаю ставку на симейк и в дальнейшем хочу уйти от поддержки двух систем сборки.

CMakeLists.txt Outdated Show resolved Hide resolved
@aol-nnov
Copy link
Contributor Author

aol-nnov commented Sep 18, 2024

... и надо будет в пайплайн добавить установку гита в сборочную среду, иначе

CMake Warning at cmake/modules/GenerateVersionHeader.cmake:21 (message):
  Failed to determine version from Git tags.

но перед этим же есть

Run actions/checkout@v3
Syncing repository: fralx/LimeReport
Getting Git version info
  Working directory is '/home/runner/work/LimeReport/LimeReport'
  /usr/bin/git version
  git version 2.46.0

Видимо, это происходит в другом контейнере.

А, там fetch-tags: false в actions/checkout@v3. Надо true теперь..

И поломка в экшене - он не тянет теги, даже если попросишь... actions/checkout#1781 местная публика предлагает технологическую подпорки на выбор :) раз, два. (Мне первая понравилась, выбрал её)

@aol-nnov aol-nnov force-pushed the automate-version-generation branch 10 times, most recently from 8982be6 to 968e1b4 Compare September 19, 2024 06:37
Version is now generated automatically based on git tags.
Both cases are handled: building from git tree and building tarball downloaded from github.

Works for qmake and cmake
@aol-nnov
Copy link
Contributor Author

Готово, судя по всему.

Формат версии при сборке не с тега: 1.7.14-4-ga77f5a1-dirty - <значение наисвежайшего тега>-<количество коммитов после тега>-<хеш последнего коммита>-<"dirty" если есть незакоммиченные изменения>

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

После сборки кумейком у меня вот какая картина:

Updating '/code/translations/limereport_zh.qm'...
Removing translations equal to source text in '/code/translations/limereport_zh.qm'...
    Generated 728 translation(s) (714 finished and 14 unfinished)
    Ignored 104 untranslated source text(s)
/usr/lib/qt5/bin/lrelease -removeidentical "/code/translations/limereport_pl.ts" -qm "/code/translations/limereport_pl.qm"
Updating '/code/translations/limereport_pl.qm'...
Removing translations equal to source text in '/code/translations/limereport_pl.qm'...
    Generated 692 translation(s) (677 finished and 15 unfinished)
    Ignored 116 untranslated source text(s)
^Z
[1]+  Stopped                 make -j
root@30e1ce18a89e:/code# git describe --dirty
1.7.14-4-gc8e364d-dirty
root@30e1ce18a89e:/code# git status
On branch define-codestyle
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   translations/limereport_ar.ts
	modified:   translations/limereport_es.ts
	modified:   translations/limereport_fr.ts
	modified:   translations/limereport_pl.ts
	modified:   translations/limereport_ru.qm
	modified:   translations/limereport_ru.ts
	modified:   translations/limereport_zh.ts

Кстати, .qm-файлы не требуется версионировать, это артефакты сборки.

Переводы, судя по диффу, в заброшенном состоянии просто и это уже другая история. :)

diff --git a/translations/limereport_ar.ts b/translations/limereport_ar.ts
index 4f982d3..b0f373d 100644
--- a/translations/limereport_ar.ts
+++ b/translations/limereport_ar.ts
@@ -509,6 +509,109 @@ p, li { white-space: pre-wrap; }
         <translation type="unfinished"></translation>
     </message>
 </context>
+<context>
+    <name>LimeReport::BorderEditor</name>
+    <message>
+        <source>Edit border</source>
+        <translation type="unfinished"></translation>
+    </message>

@fralx
Copy link
Owner

fralx commented Sep 19, 2024

А может, нам убрать проверку на предмет того, был ли модифицирован проект? Для версии это не очень принципиально :) Можно, конечно, еще отпилить построение файлов ts и создавать их по мере надобности.

@aol-nnov
Copy link
Contributor Author

aol-nnov commented Sep 19, 2024

А может, нам убрать проверку на предмет того, был ли модифицирован проект?

в плане диагностики это очень помогает, например, вот в каких ситуациях:

- а я вот тут ваш проект собрал, и у меня всё падает/не так работает/прочие аномалии
- версия какая?
- 1.2.3-123-deadbeef-dirty
- вот когда без самодеятельности соберёте, тогда и приходите жаловаться

:)

А по поводу .ts моё мнение вот каково: их надо обновлять вместе с внесением изменений в исходники (то есть, ни в коем случае не отпиливать, а совсем наоборот), а дальше (spoiler alert!) применять continuous translation. :)

Так что, в части переводов предлагаю оставить, как есть и подождать следующих серий этого захватывающего сериала. То есть, на данный момент, можно просто разово обновить руками переводы и закоммитить, а дальше - видно будет. )

@fralx fralx merged commit c5b9ac2 into fralx:master Sep 19, 2024
29 checks passed
@aol-nnov aol-nnov deleted the automate-version-generation branch September 19, 2024 17:46
@fralx
Copy link
Owner

fralx commented Sep 19, 2024

Заметил странное :
image

Таким образом qmake у меня собирает всегда dirty

@aol-nnov
Copy link
Contributor Author

aol-nnov commented Sep 20, 2024

Ох... Смахивает на былинный провал... Постараюсь починить в ближайшее время!

Суть такова:

$ git --git-dir=./LimeReport/.git describe --tags --dirty
1.7.14-5-g0fca716-dirty

$ git --git-dir=./LimeReport/.git --work-tree=./LimeReport/ describe --tags --dirty
1.7.14-5-g0fca716

aol-nnov added a commit to aol-nnov/LimeReport that referenced this pull request Sep 20, 2024
cmake's `execute_process()` has `WORKING_DIRECTORY` parameter, but qmake's `$$system()` does not.

As a workaround for qmake, `git` command was called with `--git-dir` provided explicitly.
But for dirtyness detection we need `--work-tree`, too.

Follow-up for fralx#471 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants