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

Draft
wants to merge 38 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.

To review

  • Ensure proper categorization of actions and workflows.

In Progress

  • Running the workflows and updating the table accordingly with the result. (Failed ones of testintegration are due to running them against 5.x instead of 4.x.

@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.

The observation field contains the run time, and/or whether it failed in the test run, made to determine if any is taking more than 30 minutes.

Workflow names

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

Action names

Name Folder Proposed name Observation
Coding style check clang_format 5_codelinter_clangformat 🟢
Compile and Run Tests compile_and_run_tests 4_testintegration_compile 🟢
Compile and Run Tests compile_and_run_tests 4_testintegration_ctest 🟢
Build and push image to ghcr docker_build_and_push_image 4_builderpackage_docker_onpush Pending
Run Docker exec command docker_exec_command 4_builderpackage_docker_exec Pending
Pull image from ghcr docker_pull_image 4_builderpackage_docker_pull Pending
Retag images from ghcr docker_retag_image 4_builderpackage_docker_retag Pending
Run Docker run command docker_run_command 4_builderpackage_docker_run Pending
Set Docker architecture, tag and image name docker_set_arch_tag_and_image_name 4_builderpackage_docker_resolvable Pending
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 Pending
Test Linux Package linux_test_package 4_testintegration_binary_linux Pending
Compile Mac OS Repository macos_compile_repository 4_builderpackage_agent_macos Disabled
Package Mac OS Binaries macos_package_binaries 4_builderpackage_binary_macos Pending
Test Mac OS Package macos_test_package 4_testintegration_binary_macos Pending
Test install Wazuh agent package test-install-components 4_testintegration_package_linux Pending
Upload file to S3c upload_file_to_s3 4_builderpackage_s3_upload Pending
Cover vcpkg dependencies vcpkg_vcpkg_dependencies 4_builderpackage_vcpkg Pending
Build windows package windows_package_build 4_builderpackage_binary_win Pending

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.

@xkazinx
Copy link
Member Author

xkazinx commented Mar 6, 2025

05/03/2025

  • Used and pushing directly to the the forked repository for testing, given that workflow_run only works in the default branch.
  • Fixed paths being wrong for certain files after the fork, hence not working.
  • Fixed uploading artifacts from .github/actions/4_testintegration_compile/action.yml, named based on the OS target.
  • Still couldn't trigger .github/workflows/5_testintegration_ctest.yml automatically after the Compile action, where the workflow would run right away without waiting.
  • Artifacts seems to be uploaded correctly, but not downloaded correctly, still investigating why this happens.
  • Started to adapt .github/workflows/5_builderpackage_agent-linux.yml so that it uses this workflow instead of .github/workflows/5_testintegration_compile.yml to compile, where certain steps are skipped or allowed whether the workflow is being ran with workflow_dispatch or with the pull_request event.
  • Testing these workflows are taking a long time, specially when testing for workflow_run, where dummy files will be used to accelerate testing times.

@xkazinx
Copy link
Member Author

xkazinx commented Mar 10, 2025

A commentary was left in the issue which addresses the additional requests that emerged from this issue.

@xkazinx xkazinx force-pushed the enhancement/608-actions-and-workflows-according-to-convention branch from 3de5558 to 9578ebe Compare March 11, 2025 18:48
@xkazinx
Copy link
Member Author

xkazinx commented Mar 12, 2025

Tested all the workflows from the Actions tab and updated the names table with the result. It will be asked tomorrow how to proceed with the failing testintegration ones.

@xkazinx xkazinx marked this pull request as draft March 12, 2025 15:08
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