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

GitHub Actions and Workflows according to convention #621

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

xkazinx
Copy link
Member

@xkazinx xkazinx commented Feb 21, 2025

Closes #608

Description

Introduces changes in GitHub Actions and Workflows to follow the naming rules described in the issue, and to adjust the design based on the following tasks from the checklist:

  • Define Actions according to the specification:
    • Ensure the naming convention is followed (<major>_<prefix>_<target>).
    • Categorize Actions into the appropriate use cases (code analysis, linters, tests, builders).
    • Ensure that job steps only contain Actions with the same prefix and use matrices whenever possible.
  • Define Workflows according to the specification:
    • Use the correct workflow naming prefix based on its purpose.
    • Define appropriate triggers for each workflow (PR workflows or manual dispatch).
    • Ensure PR workflows do not exceed the 30-minute execution limit.

@xkazinx xkazinx self-assigned this Feb 21, 2025
@xkazinx
Copy link
Member Author

xkazinx commented Feb 21, 2025

The following questions were also submitted in Slack, where the follow-up will continue.

Question 1: Should the tier, and in some cases the OS, be included in the new naming convention for these integration tests?
Question 2: Should we keep these integration tests separated or should any of these merge into a single workflow?

Name File Proposed name
Integration tests for AWS - Tier 0 and 1 integration_tests_aws_tier_0_1.yml 4_testintegration_aws
Integration tests for Execd on Linux - Tier 0 and 1 integration_tests_execd_tier_0_1_lin.yml 4_testintegration_execd
Integration tests for Execd on Windows - Tier 0 and 1 integration_tests_execd_tier_0_1_win.yml 4_testintegration_execd
Integration tests for FIM on Linux - Tier 0 and 1 integration_tests_fim_tier_0_1_lin.yml 4_testintegration_fim
Integration tests for FIM on MacOS - Tier 0 and 1 integration_tests_fim_tier_0_1_macos.yml 4_testintegration_fim
Integration tests for FIM on Windows - Tier 0 and 1 integration_tests_fim_tier_0_1_win.yml 4_testintegration_fim
Integration tests for FIM on Linux - Tier 2 integration_tests_fim_tier_2_lin.yml 4_testintegration_fim
Integration tests for FIM on Windows - Tier 2 integration_tests_fim_tier_2_win.yml 4_testintegration_fim
Integration tests for GitHub on Linux - Tier 0 and 1 integration_tests_github_tier_0_1_lin.yml 4_testintegration_github
Integration tests for GitHub on Windows - Tier 0 and 1 integration_tests_github_tier_0_1_win.yml 4_testintegration_github
Integration tests for logcollector on Linux - Tier 0 and 1 integration_tests_logcollector_tier_0_1_lin.yml 4_testintegration_logcollector - 5_testintegration_logcollector
Integration tests for logcollector on MacOS - Tier 0 and 1 integration_tests_logcollector_tier_0_1_macos.yml 4_testintegration_logcollector - 5_testintegration_logcollector
Integration tests for logcollector on Windows - Tier 0 and 1 integration_tests_logcollector_tier_0_1_win.yml 4_testintegration_logcollector - 5_testintegration_logcollector
Integration tests for MsGraph on Linux - Tier 0 and 1 integration_tests_msgraph_tier_0_1_lin.yml 4_testintegration_msgraph
Integration tests for Office365 on Linux - Tier 0 and 1 integration_tests_office365_tier_0_1_lin.yml 4_testintegration_office365
Integration tests for Office365 on Windows - Tier 0 and 1 integration_tests_office365_tier_0_1_win.yml 4_testintegration_office365
Integration tests for SCA on Linux - Tier 0 and 1 integration_tests_sca_tier_0_1_lin.yml 4_testintegration_sca
Integration tests for SCA on Windows - Tier 0 and 1 integration_tests_sca_tier_0_1_win.yml 4_testintegration_sca

Question 3: Once the naming is decided for the different workflows, should these be changed simply by modifying the yml files inside .github/workflows?

Question 4: Once the naming is decided for the different actions, should these be changed by modifying the folder names inside .github/actions?

Question 5: Should we separate build-related workflows from execution ones? Examples: build_and_test_component.yml and compile_and_run_tests.yml

Questions were answered in Slack

@xkazinx
Copy link
Member Author

xkazinx commented Feb 21, 2025

These are the current proposed names for workflows and actions, note that these will change accordingly from reviews and as the task advances, until final names are met.

Workflow names

Name File Proposed name
Integration tests for AWS - Tier 0 and 1 integration_tests_aws_tier_0_1.yml 5_testintegration_aws-0-1.yml
Integration tests for Execd on Linux - Tier 0 and 1 integration_tests_execd_tier_0_1_lin.yml 5_testintegration_execd-0-1-linux.yml
Integration tests for Execd on Windows - Tier 0 and 1 integration_tests_execd_tier_0_1_win.yml 5_testintegration_execd-0-1-win.yml
Integration tests for FIM on Linux - Tier 0 and 1 integration_tests_fim_tier_0_1_lin.yml 5_testintegration_fim-0-1-linux.yml
Integration tests for FIM on MacOS - Tier 0 and 1 integration_tests_fim_tier_0_1_macos.yml 5_testintegration_fim-0-1-macos.yml
Integration tests for FIM on Windows - Tier 0 and 1 integration_tests_fim_tier_0_1_win.yml 5_testintegration_fim-0-1-win.yml
Integration tests for FIM on Linux - Tier 2 integration_tests_fim_tier_2_lin.yml 5_testintegration_fim-2-linux.yml
Integration tests for FIM on Windows - Tier 2 integration_tests_fim_tier_2_win.yml 5_testintegration_fim-2-win.ymlc
Integration tests for GitHub on Linux - Tier 0 and 1 integration_tests_github_tier_0_1_lin.yml 5_testintegration_github-0-1-linux.yml
Integration tests for GitHub on Windows - Tier 0 and 1 integration_tests_github_tier_0_1_win.yml 5_testintegration_github-0-1-win.yml
Integration tests for logcollector on Linux - Tier 0 and 1 integration_tests_logcollector_tier_0_1_lin.yml 5_testintegration_logcollector-0-1-linux.yml
Integration tests for logcollector on MacOS - Tier 0 and 1 integration_tests_logcollector_tier_0_1_macos.yml 5_testintegration_logcollector-0-1-macos.yml
Integration tests for logcollector on Windows - Tier 0 and 1 integration_tests_logcollector_tier_0_1_win.yml 5_testintegration_logcollector-0-1-win.yml
Integration tests for MsGraph on Linux - Tier 0 and 1 integration_tests_msgraph_tier_0_1_lin.yml 5_testintegration_msgraph-0-1-linux.yml
Integration tests for Office365 on Linux - Tier 0 and 1 integration_tests_office365_tier_0_1_lin.yml 5_testintegration_office365-0-1-linux.yml
Integration tests for Office365 on Windows - Tier 0 and 1 integration_tests_office365_tier_0_1_win.yml 5_testintegration_office365-0-1-win.yml
Integration tests for SCA on Linux - Tier 0 and 1 integration_tests_sca_tier_0_1_lin.yml 5_testintegration_sca-0-1-linux.yml
Integration tests for SCA on Windows - Tier 0 and 1 integration_tests_sca_tier_0_1_win.yml 5_testintegration_sca-0-1-win.ymlc
Package - Retag Docker images packages_retag_images.yml 5_builderpackage_docker-retag.yml
Package - Upload Docker package building images packages_upload_images.yml 5_builderpackage_docker-upload.yml
Clang Format Check clang-format-check.yml 4_codequality_clangformat.yml
Compile and Run Tests compile_and_run_tests.yml to split
Coverage Check coverage_check.yml 4_codequality_coverage.yml
deploy-gh-pages deploy-docs.yml 5_builderpackage_docs.yml
Build and Test Components build_and_test_component.yml removed
Deployment variable tests deployment_vars.yml 5_builderpackage_vars.yml
Build Wazuh agent Linux packages packages-build-linux-agent.yml 5_builderpackage_agent-linux.yml
Build Wazuh agent Mac OS packages packages-build-macos-agent.yml 5_builderpackage_agent-macos.yml
Build Wazuh agent Windows packages-build-windows-agent.yml 5_builderpackage_agent-win.yml

Action names

Name Folder Proposed name
Coding style check clang_format 5_codelinter_clangformat
Compile compile 5_builderpackage_agent
Compile and test compile_and_test 4_testintegration_compile_and_analyze
Build and push image to ghcr docker_build_and_push_image 4_docker_build_and_push
Run Docker exec command docker_exec_command 4_docker_exec
Pull image from ghcr docker_pull_imagec 4_docker_pull
Retag images from ghcr docker_retag_image 4_docker_retag
Run Docker run command docker_run_command 4_docker_run
Set Docker architecture, tag and image name docker_set_arch_tag_and_image_name 4_docker_resolvable
Doxygen documentation generartion doxygenc 5_codelinter_doxygen
Compile Linux Repository linux_compile_repository 4_builderpackage_agent_linux
Package Linux Binaries linux_package_binaries 4_builderpackage_binary_linux
Test Linux Package linux_test_package 4_testintegration_binary_linux
Compile Mac OS Repository macos_compile_repository 4_builderpackage_agent_macos
Package Mac OS Binaries macos_package_binaries 4_builderpackage_binary_macos
Test Mac OS Package macos_test_package 4_testintegration_binary_macos
Test install Wazuh agent package test-install-components 4_testintegration_package_linux
Upload file to S3c upload_file_to_s3 4_s3_upload
Cover vcpkg dependencies vcpkg_vcpkg_dependencies 4_builderpackage_vcpkg
Build windows package windows_package_build 4_builderpackage_binary_win

Tasks 21/02/2025

  • Investigated about implementing PR workflows and manual dispatch.
  • Found related examples to set a 30 min. timeout where applicable.
  • Investigated about implementing matrices.

@xkazinx
Copy link
Member Author

xkazinx commented Feb 24, 2025

  • Installed Docker and GitHub act in Agent's VM to run ./.github/workflow/compile_and_run_tests.yml to ensure the same output after splitting that specific workflow into two.
  • Couldn't finish running tests locally because the VM ran out of storage, and it's failing to boot the iso file to extend it, by not entering to bios nor boot menu.
  • Installed a new VM with enough resources.
  • Ported the work in progress to continue.

@xkazinx
Copy link
Member Author

xkazinx commented Feb 25, 2025

  • Investigated about splitting compile_and_run_tests.yml into various workflows, initially by searching about artifacts, and concluded that it requires to upload files from a workflow, and to download them from another.
    • This particular task has been postponed for further work, prioritizing the specific tasks mentioned in the ticket.
  • Updated action file names in a commit.
    • Originally did it with mv, made a rollback, and used git mv instead.
    • ./.github/actions/x/action.yml files were renamed as suggested here, but GitHub doesn't seem to be processing them accordingly, where it's suggesting that the filename has to be action.yml or actions.yml. If this is the case, folder names will be renamed instead.

@xkazinx
Copy link
Member Author

xkazinx commented Feb 26, 2025

  • Updated action folder names and their references, including the table above.
  • Updated references in the wazuh-agent-packages repository through this PR.
  • References to these actions were not found:
    • docker_build_and_push_image
    • compile_and_test
    • doxygen
  • upload_file_to_s3 seems to be duplicated in both repositories, it will be manually determined if pointing to the wazuh-agent one with the new name works, as wazuh-agent-packages doesn't seem to have Checks.

@xkazinx
Copy link
Member Author

xkazinx commented Feb 28, 2025

  • Splitted workflows/compile_and_run_tests into two workflows and actions.
    • Couldn't test locally due to the use of aws credentials, hence pushed to github.
    • GitHub shows that there's a merge conflict, but merging locally doesn't show the conflict to solve it.
  • Ported packages-upload-agent-images-amd.yml into 4_docker_build_and_push.yml by using a workflow instead of an action, to test the functionality first.
    • Throws: Error: Could not find any stages to run.

These, other questions and commentaries were published in the slack thread.

@xkazinx xkazinx force-pushed the enhancement/608-actions-and-workflows-according-to-convention branch from 8d74742 to 768de19 Compare February 28, 2025 13:32
@xkazinx
Copy link
Member Author

xkazinx commented Feb 28, 2025

  • Port of compile_and_run_tests.yml into multiple workflows and/or actions:
    • Initially tried to share files between workflows using aws, where the new workflow (..._ctest) wasn't able to access the secret input.
    • Then, I found that this was actually possible with artifacts.
    • Once artifacts were set, used the workflow_run feature to run a workflow only after another one has completed.
    • The ..._ctest workflow would run right away, where based on the documentation, it is only possible to use this instruction with the default branch.
    • Made a fork of the repository to test in the main branch of my account, but path related errors would appear.
    • Hence, moved into having a single workflow, with an action for compile and another for ctest, by sharing the artifact of each respective OS build.
    • Left the multiple workflows commented in case there's a workaround and it's requested.
    • Related questions and comments were left in the slack thread.

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.

Define GitHub Actions and Workflows according to the convention
1 participant