Mythic icon indicating copy to clipboard operation
Mythic copied to clipboard

Add test gh action

Open Edznux opened this issue 2 years ago • 2 comments

As more test may be added in the future, related to https://github.com/its-a-feature/Mythic/issues/286, I believe adding a small CI runner (free for small public repo like these) would be beneficial and help new developers onboard more confidently.

Adding other checks such as linter can be done as well later on :)

Edznux avatar Jun 25 '23 11:06 Edznux

For this go test -v ./... call, if one of the tests results in a FAIL case, would that be enough to cause the rest of the tests to still run but error out the whole runner?

its-a-feature avatar Dec 15 '23 17:12 its-a-feature

Hey @its-a-feature, sorry for the delay, but yep, it'll run all test and if one fail, go test will return a status code 1, and the github action will then error out.

I'm putting the -v so it's a bit more verbose, but that's something you can tweak to your need later.

Example (created a dummy fake test, that only fails, locally):

21:02:48 edznux@Trinity[~/dev/Mythic/mythic-docker/src] (add-test-gh-action)$ go test -v ./...
?       github.com/its-a-feature/Mythic [no test files]
?       github.com/its-a-feature/Mythic/crypto  [no test files]
?       github.com/its-a-feature/Mythic/database        [no test files]
?       github.com/its-a-feature/Mythic/database/structs        [no test files]
?       github.com/its-a-feature/Mythic/grpc    [no test files]
?       github.com/its-a-feature/Mythic/grpc/services   [no test files]
?       github.com/its-a-feature/Mythic/rabbitmq        [no test files]
?       github.com/its-a-feature/Mythic/logging [no test files]
?       github.com/its-a-feature/Mythic/webserver       [no test files]
?       github.com/its-a-feature/Mythic/utils/errors    [no test files]
?       github.com/its-a-feature/Mythic/utils/structs   [no test files]
?       github.com/its-a-feature/Mythic/utils   [no test files]
?       github.com/its-a-feature/Mythic/webserver/controllers   [no test files]
=== RUN   TestValidateLogin
    ValidateLogin_test.go:6: failed blabal
--- FAIL: TestValidateLogin (0.00s)
FAIL
FAIL    github.com/its-a-feature/Mythic/authentication  0.010s
FAIL
21:03:16 edznux@Trinity[~/dev/Mythic/mythic-docker/src] (add-test-gh-action)$ echo $?
1

Running the Github action locally via act returns:

[Go package/build]   ✅  Success - Main Build
[Go package/build] ⭐ Run Main Test
[Go package/build]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/3] user= workdir=mythic-docker/src
| ?   	github.com/its-a-feature/Mythic	[no test files]
| ?   	github.com/its-a-feature/Mythic/crypto	[no test files]
| ?   	github.com/its-a-feature/Mythic/database	[no test files]
| ?   	github.com/its-a-feature/Mythic/database/structs	[no test files]
| ?   	github.com/its-a-feature/Mythic/grpc	[no test files]
| ?   	github.com/its-a-feature/Mythic/grpc/services	[no test files]
| ?   	github.com/its-a-feature/Mythic/logging	[no test files]
| ?   	github.com/its-a-feature/Mythic/rabbitmq	[no test files]
| ?   	github.com/its-a-feature/Mythic/utils	[no test files]
| ?   	github.com/its-a-feature/Mythic/utils/errors	[no test files]
| ?   	github.com/its-a-feature/Mythic/utils/structs	[no test files]
| ?   	github.com/its-a-feature/Mythic/webserver	[no test files]
| ?   	github.com/its-a-feature/Mythic/webserver/controllers	[no test files]
| === RUN   TestValidateLogin
|     ValidateLogin_test.go:6: failed blabal
| --- FAIL: TestValidateLogin (0.00s)
| FAIL
| FAIL	github.com/its-a-feature/Mythic/authentication	0.009s
| FAIL
[Go package/build]   ❌  Failure - Main Test
[Go package/build] exitcode '1': failure
[Go package/build] 🏁  Job failed
Error: Job 'build' failed

Edznux avatar Jan 08 '24 20:01 Edznux