cake icon indicating copy to clipboard operation
cake copied to clipboard

[P3] Set up CI workflows

Open iphydf opened this issue 1 year ago • 14 comments

At least to see if the code still compiles before pushing to master.

iphydf avatar Mar 02 '24 08:03 iphydf

I need some help on this. I even don´t known it it is possible. For instance windows and linux at same time?

thradams avatar Mar 03 '24 12:03 thradams

It should be possible, yes. I don't have much experience myself, either, but I've seen it being done.

imaami avatar Mar 03 '24 17:03 imaami

Is it easy to do a linux build? or run cake unit tests? cake unit tests could return the number of tests that failed.. then this is the target :D to avoid regression

thradams avatar Mar 06 '24 22:03 thradams

It's probably about an hour of work. I don't have time to do it this week but maybe I (or someone in our team) can make some time next week to look into it.

iphydf avatar Mar 06 '24 22:03 iphydf

Not sure how much work tracking the number of failing tests across different runs would be, but I set up some simple CI that at least checks that things build and the tests run. :P It isn't much, but it's a start.

robinlinden avatar Mar 06 '24 23:03 robinlinden

this is the code called on test..

#include "unit_test.c"

int main(int argc, char** argv)
{

    enable_vt_mode();

    test_main();
    printf("%d tests failed, %d tests passed\n", g_unit_test_error_count, g_unit_test_success_count);


}
#endif

it can be modified to

return g_unit_test_error_count != 9 ? EXIT_FAILURE : EXIT_SUCCESS;

where 9 is the number of current failing tests.

thradams avatar Mar 07 '24 00:03 thradams

I never used this. I don't know how it works! Does it blocks commits? Does it runs on each checkin? I will do some experiments like breaking a test.

thradams avatar Mar 07 '24 00:03 thradams

You can set the repository to forbid pushing straight to main and require people to open pull requests, then you can set up rules there on what checks must be "green" and which ones are allowed to break. :P

That kind of workflow would require you to open PRs for your changes too if you want the check to run before you put the code in main, though. :P

robinlinden avatar Mar 07 '24 00:03 robinlinden

Try pushing a branch and opening a PR with a broken test! :D

robinlinden avatar Mar 07 '24 00:03 robinlinden

I created a syntax error.. it green then a test failing it return fail on tests and still green. maybe it is not checking the results?

thradams avatar Mar 07 '24 01:03 thradams

this is the code I try to catch the gcc compilation error


    int system_like(const char* command)
    {
        int test_result = system(command);
        int stat = 0;
        wait(&stat);
        if (WIFEXITED(stat))
        {
            test_result = WEXITSTATUS(stat);
        }
        else if (WIFSIGNALED(stat))
        {
            test_result = WTERMSIG(stat);
        }
        return test_result;
    }

i think it returns always 0

thradams avatar Mar 07 '24 01:03 thradams

this is amazing!

thradams avatar Mar 07 '24 02:03 thradams

Is it possible to make commits on this integration? For instance, change the version number at version.h then commit.

thradams avatar Mar 07 '24 11:03 thradams

this is amazing!

It is very convenient compared to manual testing, yeah. :P

Is it possible to make commits on this integration? For instance, change the version number at version.h then commit.

The jobs get a GITHUB_TOKEN environment variable that you can use for e.g. creating issues or committing code or uploading releases and things.

See https://stackoverflow.com/questions/57921401/push-to-origin-from-github-action/58393457#58393457 for how you can use regular git commands in an action. :P

robinlinden avatar Mar 07 '24 19:03 robinlinden