Commit graph

135 commits

Author SHA1 Message Date
Gabriel Adrian Samfira
0ff2fd2e06
Make owners and repos case insensitive
Github treats owners (users and orgs) and repos as case insensitive. To
github, https://github.com/cloudbase/garm is equivalent to
https://github.com/CloudBase/GaRm. This commit makes the sql store
backend, case insensitive when querying repos and orgs.

Fixes: #25

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-05 18:14:07 +03:00
Gabriel
8ca9a82529
Merge pull request #24 from mihaelabalutoiu/add-db-organizations-unit-tests
Add `organizations.go` unit tests
2022-10-05 16:17:14 +03:00
Mihaela Balutoiu
5692439dda Add organizations.go unit tests 2022-10-03 17:55:35 +03:00
Gabriel
e9aba82ec1
Merge pull request #23 from mihaelabalutoiu/add-db-instances-unit-tests
Add `instances.go` database unit tests
2022-09-28 18:01:39 +03:00
Mihaela Balutoiu
723c9c3d60 Add instances.go database unit tests
Add more test cases regarding the SQL database interactions.
Moreover, add `go-sqlmock` dependency used to mock SQL DB instructions.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-09-28 17:29:40 +03:00
Gabriel
3c49df5144
Merge pull request #22 from mihaelabalutoiu/add-db-instances-unit-tests
Add more `instances.go` unit tests
2022-09-21 20:37:29 +03:00
Mihaela Balutoiu
898e098ff8 Add more instances.go unit tests
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-09-21 20:34:14 +03:00
Gabriel
d9332f21ae
Merge pull request #21 from ionutbalutoiu/add-badge-link
Add link to `Go Tests` README badge
2022-09-21 18:40:16 +03:00
Ionut Balutoiu
b8e6d56428 Add link to Go Tests README badge
Make sure that the README `Go Test` badge has a link to the GitHub
page with latest workflow results.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-21 18:26:43 +03:00
Gabriel
93619b8d4e
Merge pull request #19 from gabriel-samfira/fetch-runner-name-from-api
Attempt to fetch runner name from API
2022-09-20 16:50:13 +03:00
Gabriel Adrian Samfira
e8fa6dba6e
Attempt to fetch runner name from API
In some cases, runner information is not sent via webhook by Github when
a workflow job transitions to in_progress. We need to know the runner
name in order to update the state in the database. Attempt to fetch the
runner from the API using the workflow ID.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-20 14:46:44 +03:00
Gabriel
8cec645b10
Merge pull request #18 from mihaelabalutoiu/cleanup-unused-struct-field
Cleanup unused struct field and Fix typo
2022-09-16 15:02:39 +03:00
mihaelabalutoiu
6039a97d5a Fix typo 2022-09-15 19:18:28 +03:00
mihaelabalutoiu
e2ada6d1e3 Cleanup unused struct field
Remove `Pool` field from `CreateInstanceParams` struct, because
this is given as a separate parameter to the `CreateInstance` function.
2022-09-15 19:11:37 +03:00
Gabriel
775dd51782
Merge pull request #16 from mihaelabalutoiu/add-db-instances-unit-tests
Add `instances.go` unit tests
2022-09-15 19:01:13 +03:00
mihaelabalutoiu
797ec21dd9 Add instances.go unit tests 2022-09-15 18:59:16 +03:00
Gabriel
476c3b814f
Merge pull request #17 from gabriel-samfira/create-testing-package
Create a testing package for common utilities
2022-09-15 18:03:06 +03:00
Gabriel Adrian Samfira
b4ac128673
Create a testing package for common utilities
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-15 17:48:09 +03:00
Gabriel
a2cd015533
Merge pull request #15 from mihaelabalutoiu/cleanup-duplicate-code
Cleanup duplicate code
2022-09-14 15:55:23 +03:00
mihaelabalutoiu
8c910d904f Cleanup duplicate code 2022-09-14 12:55:26 +03:00
Gabriel
777c41e411
Merge pull request #14 from mihaelabalutoiu/add-db-ctrl-unit-tests
Add `controller.go` unit tests
2022-09-13 15:23:50 +03:00
mihaelabalutoiu
6fe6680e52 Fix database.go typo 2022-09-13 15:01:17 +03:00
mihaelabalutoiu
bdb087578a Add controller.go unit tests 2022-09-13 14:21:21 +03:00
Gabriel
5759b74e0d
Merge pull request #12 from mihaelabalutoiu/add-repositories-unit-tests
Add `repositories.go` unit tests
2022-09-09 17:51:11 +03:00
Gabriel
8b1c8860a0
Merge pull request #13 from mihaelabalutoiu/update-organizations-unit-tests
Update `organizations.go` unit tests
2022-09-09 17:50:05 +03:00
mihaelabalutoiu
8215edfe26 Update organization.go unit tests 2022-09-09 16:38:52 +03:00
mihaelabalutoiu
54f2dd6154 Add repositories.go unit tests 2022-09-09 15:57:18 +03:00
Gabriel
8e3b1e508c
Merge pull request #11 from mihaelabalutoiu/add-repositories-unit-tests
Add more `repositories.go` unit testing
2022-09-09 11:33:20 +03:00
mihaelabalutoiu
c5158fbf5c Add more repositories.go unit testing 2022-09-09 10:47:36 +03:00
Gabriel
16a81cfd1b
Merge pull request #10 from mihaelabalutoiu/add-repositories-unit-tests
Add `repositories.go` unit tests
2022-09-07 18:25:27 +03:00
mihaelabalutoiu
505489eddf Add repositories.go unit tests 2022-09-07 16:49:42 +03:00
Gabriel
2ccfbc480b
Merge pull request #9 from ionutbalutoiu/add-go-tests-github-workflow
Add go tests GitHub workflow
2022-09-07 16:36:28 +03:00
Ionut Balutoiu
30c1510967 Add Go Tests GitHub workflow
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-07 16:33:13 +03:00
Ionut Balutoiu
8f29f90488 Add 'go test' Makefile target
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-07 16:32:29 +03:00
Gabriel Adrian Samfira
3949912678
Update gitignore
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:36:35 +03:00
Gabriel Adrian Samfira
d4b7fca9f6
Fix test config_dir
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:35:42 +03:00
Gabriel Adrian Samfira
99856af4de
Silence gorm default logger
Disable the default logger for gorm when debug is not set on the sql
store backend. By default gorm will print error level log messages,
which includes queries which find no results, which is not really an
error.

These messages will show up if debug is enabled on the sql store
backend.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:35:01 +03:00
Gabriel
c0df364bb0
Merge pull request #8 from mihaelabalutoiu/add-organizations-unit-tests
Add `organizations.go` unit tests and `PoolManagerController` mocks
2022-09-06 20:12:46 +03:00
mihaelabalutoiu
1a7c31c8ea Add more organizations.go unit testing
Also, update vendor with the `github.com/stretchr/testify/suite`.
2022-09-06 18:04:51 +03:00
mihaelabalutoiu
3094ad09be Add PoolManagerController mocks 2022-09-01 16:08:56 +03:00
Gabriel
b74b829ce6
Merge pull request #7 from mihaelabalutoiu/refactor-code
Refactor code to allow more unit testing
2022-08-19 13:07:12 +03:00
Ionut Balutoiu
7b6c2e6106 Refactor code to allow more unit testing
In order to allow mocking for some of the `runner` functions, we created a
separate interface (called `PoolManagerController`) with `Create`, `Get`,
`Delete` operations for the `organization` / `repository` pool managers.

Furthermore, a new runner struct (`poolManagerCtrl`) implements this new
interface. The existing code is refactored to use the `poolManagerCtrl`
whenever the pool managers for `org` / `repo` are handled.

This allows more unit testing for the runner functions since `poolManagerCtrl`
field can be mocked now.

Besides this, there are some typos fixed as well.
2022-08-18 17:47:05 +03:00
Gabriel
ad97baac70
Merge pull request #6 from mihaelabalutoiu/add-unit-tests
Add unit tests
2022-08-01 18:08:52 +03:00
mihaelabalutoiu
a869b5d743 Add unit tests 2022-08-01 12:34:59 +03:00
Gabriel
cd4e4fb985
Merge pull request #5 from mihaelabalutoiu/dev
Fix `NewConfig` func & and add more unit tests
2022-07-26 14:24:53 +03:00
mihaelabalutoiu
229946a4c0 Add unit tests for full coverage to the NewConfig function 2022-07-26 13:43:56 +03:00
mihaelabalutoiu
795b7ebb56 Add missing assertion 2022-07-26 13:43:35 +03:00
mihaelabalutoiu
c523032c86 Fix NewConfig function
Move the default setting before validating the config, otherwise the code will
never run. This happens because the `Validate()` function will always fail when
`config.Default.ConfigDir` is empty.
2022-07-21 11:51:52 +03:00
Gabriel Adrian Samfira
067197c1b5 Fix instance JWT token expiration
The instance JWT token expiration time was set at 15 minutes, regardless
of bootstrap timeout. This meant that instances that take longer than 15
minutes, would not be able to send their status updates and github agent
ID back to garm.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-17 07:24:19 +00:00
Gabriel Adrian Samfira
5d02de92d3 Clarify external provider docs 2022-07-17 06:34:50 +00:00