Skip to content

[SKIP-HCK-CI] [build] Extend ANSI colour palette to stdout #1284

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benyamin-codez
Copy link
Contributor

@benyamin-codez benyamin-codez commented Feb 3, 2025

1. Extended ANSI colour palette to stdout
2. Update echo prints to use ANSI colour palette
3. Includes self-deleting scheduled task to clean build_log.txt of colour palette artefacts

  1. Extended ANSI colour palette to stdout
  2. Introduce log functions (credit to @kostyanf14) with colour output
  3. Update echo prints to use log functions
  4. Introduces environment variable AUTOCLRCLEAN_VIRTIO_WIN_BLD_LOG, which corresponds to a log file you want cleaned of colour artefacts
  5. Includes self-deleting scheduled task to clean log file per (4) of colour palette artefacts. Runs in SYSTEM user context for use with Docker and container images. Only runs if the variable AUTOCLRCLEAN_VIRTIO_WIN_BLD_LOG is defined and the file exists. Requires external mechanism to create log file from stdout.

Split from PR #1212.

@benyamin-codez
Copy link
Contributor Author

Rebase done...

@benyamin-codez benyamin-codez marked this pull request as ready for review February 10, 2025 12:01
@benyamin-codez
Copy link
Contributor Author

@kostyanf14

Hope you're well.

Did you have anything further for me to consider wrt this one?

Best regards,
Ben

@kostyanf14 kostyanf14 changed the title [CI-NO-BUILD] [build] Extend ANSI colour palette to stdout [SKIP-HCK-CI] [build] Extend ANSI colour palette to stdout Feb 12, 2025
@kostyanf14
Copy link
Member

rerun tests

buildAll.bat Outdated
Comment on lines 123 to 140
call schtasks /create /tn build_log_cleanup /tr "%comspec% /c %~dp0build\clean_build_log.bat" /sc ONCE /sd 01/01/1910 /st 00:00 1> nul 2>&1
call schtasks /run /tn build_log_cleanup 1> nul 2>&1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of triggering schtasks. This will work when the building is running on a clean Windows PC but what about docker or Windows containers?

I think we don't need to cleanup files at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we will run with the SYSTEM user. This hides the clean_build_log.bat so it will execute without GUI, this should be sufficient for most Docker and container configurations. It also avoids the need to instead use powershell to achieve the same outcome, as this requires the XML configuration to be properly escaped for it to work as expected.

It seems prudent to give a bit more time (+2s = 5s) for handles to close in the powershell context and remove some for the visual check for debugging purposes (-3s = 2s).

NOTE: Some containers might need to be started with the -enableTaskScheduler parameter, but most setups should just work.

I think we don't need to cleanup files at all.

It is very ugly otherwise, like morning after too many 🍻 ... 8^D Per:

�[40;92mBuild for Q35 succeeded.�[�[�[�[0m

�[40;96mProcessing DVL files to create Windows 10, version 1607, WIN10_RS1 COMPAT version...�[�[�[�[0m
�[40;93mWARNING : No DVL files were found.�[�[�[�[0m

�[40;92mBUILD COMPLETED SUCCESSFULLY.�[�[�[�[0m

Vs:

Build for Q35 succeeded.

Processing DVL files to create Windows 10, version 1607, WIN10_RS1 COMPAT version...
WARNING : No DVL files were found.

BUILD COMPLETED SUCCESSFULLY.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any further thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this.

  1. You specified the build_log.txt file which is definitely not part of the build. This file can be generated by Jenkins in our case.
  2. Jenkins doesn't know anything about schtasks, so it can start collecting artifacts after buildAll.bat exits.

You should create build/clean_log.bat which receives the log file name for cleanup and cleanup of this file. If someone writes a log to a file, he should also run clean_log.bat for the file that he created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the further feedback, Kostiantyn.

Re:
(1) Yes, I only catered for your Jenkins-based automation. My thoughts were that others can mimic the naming; &
(2) I previously discussed how the clean should complete before signing is finished. Alternatively, you could issue a sleeper to be sure, e.g.: powershell Start-Sleep -Seconds 7 after building or signing and before the artefact collection occurs.

I can certainly make build\clean_log.bat accept a parameter for filename so it can act in a manual and universal manner. Are you sure you don't want this automated? Is schtasks too sneaky? Are you considering that you will just call build\clean_log.bat build_log.txt before artefact collection (via Jenkins)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start with a fully stable variant with the manual solution and then think about an automated variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔
... 💡
... ... 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've introduced a new environment variable AUTOCLRCLEAN_VIRTIO_WIN_BLD_LOG, which corresponds to a log file you want cleaned of colour artefacts. If the variable is defined and the file exists then the clean operation is scheduled.

Also updated build\clean_build_log.bat with more comments, debug prints and the filename parameter, plus added check for SYSTEM user where we now skip flashing the stdout cleaning log output for 5 seconds (for debug purposes). Also made sure that AUTOCLRCLEAN_VIRTIO_WIN_BLD_LOG is both relative and absolute path safe and also file name (white)space safe.

So, this means that unless you pop AUTOCLRCLEAN_VIRTIO_WIN_BLD_LOG with a valid file (path and) name and create that file by some external mechanism, e.g. via Jenkins, then the task will not be created or run (the current behaviour).

I also checked manual operation, per, e.g. build\clean_build_log.bat .\build_log.txt

I trust that is acceptable. If so, enjoy..!!

@benyamin-codez
Copy link
Contributor Author

@kostyanf14

Many thanks for your feedback.
I will push a new cut with [SKIP-HCK-CI]...

Best regards,
Ben

@benyamin-codez
Copy link
Contributor Author

Apologies for prior lack of rebase... 8^d

1. Extended ANSI colour palette to stdout
2. Introduce log functions (credit to @kostyanf14) with colour output
3. Update echo prints to use log functions
4. Introduces environment variable AUTOCLRCLEAN_VIRTIO_WIN_BLD_LOG,
   which corresponds to a log file you want cleaned of colour artefacts
5. Includes self-deleting scheduled task to clean log file per (4)
   of colour palette artefacts. Runs in SYSTEM user context for use
   with Docker and container images. Only runs if the variable
   AUTOCLRCLEAN_VIRTIO_WIN_BLD_LOG is defined and the file exists.
   Requires external mechanism to create log file from stdout.

Split from PR virtio-win#1212.

Signed-off-by: benyamin-codez <[email protected]>
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.

2 participants