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

Add test gh action #306

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Edznux
Copy link
Contributor

@Edznux Edznux commented Jun 25, 2023

As more test may be added in the future, related to #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 :)

@its-a-feature
Copy link
Owner

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?

@Edznux
Copy link
Contributor Author

Edznux commented Jan 8, 2024

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

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