Commit graph

123 commits

Author SHA1 Message Date
justusbunsi b632381c90
Write tests for Gitea client
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/36
2022-07-12 18:31:25 +02:00
justusbunsi f808a58177
Refactor internal name to url-like one
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-12 16:57:12 +02:00
justusbunsi b6b9087651
Initialize SonarQube SDK with its settings
Instead of using global settings. This is important for validated
configuration reloads.

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-12 12:26:10 +02:00
justusbunsi 54beca9c25
Introduce better test case structure
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-12 11:20:08 +02:00
justusbunsi 51211d77cd
Change internal name
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-11 17:39:22 +02:00
justusbunsi d943a7f420
Add tests for GetRevision
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-11 15:53:28 +02:00
justusbunsi 525fa03065
Centralize API response handling
Currently, all API handler functions take care of response code and
message on their own. This leads to a huge injection chain for HTTP
related objects.

This refactors the API to consistently return response code and message
to the API main entrypoint where the response is created and sent.

Now, SonarQube and Gitea will get a response at the very end of any bot
action for one request. SonarQube has a timeout of 10 seconds, which may
be reached due to network latency. We'll see.

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-11 15:24:43 +02:00
justusbunsi 99fe6800b0
Remove all possible binaries on "make clean"
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-08 14:06:29 +02:00
justusbunsi 477564bbab
Bump dependencies
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-08 14:05:25 +02:00
justusbunsi 81a7251081
Update base Docker images
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-08 13:49:05 +02:00
justusbunsi 576fc94517
Require go 1.18 for builds
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-08 13:38:53 +02:00
justusbunsi 1b02303a4a
Use buffered channel as per docs
https://pkg.go.dev/os/signal#Notify

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-07 20:11:55 +02:00
justusbunsi 089523c56e
Update changelog with pending (unreleased) changes
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-07 19:59:58 +02:00
justusbunsi 7e008773b0
Remove fvbock/endless as dependency
Fixes: #31

Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/32
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-07 19:56:26 +02:00
justusbunsi c6d62861a6
Switch to original readme-generator-for-helm
The NPM package is a outdated fork from the Bitnami repository.

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-07 15:11:46 +02:00
justusbunsi 385252cd72
Prepare v0.2.1 release
With PR #17 the Helm Chart parameters for webhook secrets were missing
in the README parameters. This is now fixed.

A checksum for bot configuration secret resource ensures replacement of
the pod when there is a configuration change.

Additional:

- Bump Chart default image version
- Add bug fix notes to changelog

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-06-18 14:46:33 +02:00
justusbunsi 685c834b61
Allow pull request naming pattern customization (#28)
Fixes: #3

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-06-18 14:03:56 +02:00
justusbunsi 4aad9c3e17
Improve docker setup instructions
- Be clear about where to run the commands
- Provide sample command for port change

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-06-17 20:46:51 +02:00
justusbunsi 02ad0c0bf0
Improve error handling of SonarQube client
Due to unhandled errors within the SonarQube client, users may be
presented with Go panics or just don't know what the root cause of a
non-working bot is.

Now it is possible to identify network errors, authentication issues or
an incorrect bot configuration regarding SonarQube.

Fixes: #20

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-06-17 20:19:59 +02:00
justusbunsi eb3cb301fc
Allow changing the port
This introduces a new application option `--port`/`-p` to switch the
listening port from 3000 (default) to another port.

Docker image can be configured using the corresponding environment
variable `GITEA_SQ_BOT_PORT`.

Helm Chart allows setting `.Values.app.listeningPort`

Resolves: #25

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-06-17 13:34:06 +02:00
justusbunsi 471b25e682
Remove debug logging
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-06-12 13:28:31 +02:00
justusbunsi 0cc1cdc6c8
Add NodeJS and NPM requirements
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-27 15:35:55 +02:00
justusbunsi ce13a040b8
Introduce changelog
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-22 14:25:03 +02:00
justusbunsi dc3969cd05
Improve configuration file flexibility
Instead of re-inventing the wheel regarding configuration location
handling and validation, this introduces a new command flag `--config`
allowing for full flexibility of configuration filename and location.
This flag can also be defined via environment variable which allows
an easy way of starting the bot from command line, inside a Docker
container or using the Helm Chart.

It makes the custom environment lookup unnecessary and reduces some
complexity during startup and for writing tests.

Resolves: #10

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-22 14:03:23 +02:00
justusbunsi 5cb3daab60
Add webhook secret validation
Resolves: #4

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-21 19:05:09 +02:00
justusbunsi e203034228 Rewrite API entrypoint to be testable (#22)
The current code base regarding API entrypoint is not testable as it
directly connects to Gitea when creating the API endpoints. This
prevented my from writing tests in the past for that part.

As the SonarQube quality gate broke due to changes in the API entrypoint
logic, tests are now required to satisfy the quality gate.

Therefore, the instantiation of the API handlers is now decoupled from
building the bot API endpoints and follows the same interface wrapper
strategy as used for the Gitea API client. This makes it testable.

Now, tests are written for the most parts of the API entrypoint. I've
also noticed that there was much overhead within the tests for a
non-implemented function `fetchDetails`. So I dropped that function for
now.

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>

Co-authored-by: justusbunsi <sk.bunsenbrenner@gmail.com>
Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/22
2022-05-21 18:21:05 +02:00
justusbunsi 7f5c3390c4
Add tests for Gitea API
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-21 13:50:58 +02:00
justusbunsi 4d28133b12
Extract test api test helpers
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-21 12:23:57 +02:00
justusbunsi 34e2783cb1
Skip logging non-api routes
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-15 16:03:19 +02:00
justusbunsi f59a6530b8
Improve Chart definition
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-15 15:31:05 +02:00
justusbunsi 7e32d5c5a0
Bump chart versions
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-14 02:27:54 +02:00
justusbunsi d2353dede3
Bump dependencies
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-14 02:22:00 +02:00
justusbunsi 1f6fe0d4bc
Bump golang to 1.18
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-14 01:42:42 +02:00
justusbunsi ffc2086b38
Add ArtifactHub badge
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-14 01:42:14 +02:00
justusbunsi 2fa3ec8197
Prepare Helm Chart release
- Auto-generate parameters documentation
  - Provide required `make` commands
  - Update contribution environment to match new requirements

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-14 01:10:07 +02:00
justusbunsi 9175bacefa
Improve Chart release specification
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-13 22:43:38 +02:00
justusbunsi 3c76c8d904
Fix Docker Hub link
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-13 20:51:51 +02:00
justusbunsi e4ff25a193
Add Docker image instructions
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-13 20:48:47 +02:00
justusbunsi 7f68b52076 Extend requirements for Community Edition (#16)
Fixes #15

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/16
Co-authored-by: justusbunsi <justusbunsi@noreply.codeberg.org>
Co-committed-by: justusbunsi <justusbunsi@noreply.codeberg.org>
2021-12-18 23:03:47 +01:00
justusbunsi f85bfb4bf5
Fix helm chart service account template
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-11-12 08:30:37 +01:00
tuongvi9911 afd523c9cd Fix permission denied (#14)
error handling at runtime
starting container process caused: exec: "/usr/local/bin/docker-entrypoint.sh": permission denied: unknown.

Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/14
Co-authored-by: tuongvi9911 <tuongvi9911@noreply.codeberg.org>
Co-committed-by: tuongvi9911 <tuongvi9911@noreply.codeberg.org>
2021-10-24 18:14:55 +02:00
justusbunsi 21837f9b25
Export webhook and token struct
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 16:01:15 +02:00
justusbunsi e01096a7fe
Eliminate viper references from token and webhook
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 15:57:45 +02:00
justusbunsi 021d01b5fb
Remove useless types
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 15:43:25 +02:00
justusbunsi 24e4249411
Add SonarQube analysis
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 12:16:42 +02:00
justusbunsi 8a7e9f83fa
Refactor action validation
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 11:12:50 +02:00
justusbunsi 826204b667
Allow for running dedicated tests
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 10:53:54 +02:00
justusbunsi 49087433fb
Introduce Makefile
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 10:07:39 +02:00
justusbunsi d2424a3888
Migrate TODOs to Repo issues
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 09:17:19 +02:00
justusbunsi 90581744ff
Set analysis status on PR creation
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-13 08:54:21 +02:00