Skip to content

Commit

Permalink
Add code format checks to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWeathers committed Jun 27, 2023
1 parent be98f75 commit a6059e4
Show file tree
Hide file tree
Showing 86 changed files with 10,030 additions and 9,216 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
uses: actions/checkout@v3

- run: npm ci --no-optional
- run: npm run prettier
# - run: npm test
- run: npm run build
env:
Expand All @@ -67,6 +68,17 @@ jobs:
- name: Generate swagger docs
run: swag init -g http/http.go -o swaggerdocs

- name: Check formatting
uses: Jerome1337/gofmt-action@v1.0.5
with:
gofmt-path: '.'
gofmt-flags: '-l -d'

- name: Goimports Check
uses: DarthBenro008/goimports-check-action@v0.1.0
with:
root-path: './'

- name: Test
run: go test `go list ./... | grep -v swaggerdocs`

Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SWAGGERGEN=swag init -g http/http.go -o swaggerdocs
SWAGGERDOCS=swaggerdocs
GOFMT=gofmt
GOIMPORTS=goimports
NPM_FORMAT=npm run format
BINARY_NAME=thunderdome-planning-poker
BINARY_UNIX=$(BINARY_NAME)_unix
BINARY_WINDOWS=thunderdome-planning-poker.exe
Expand All @@ -31,8 +32,9 @@ clean:
rm -rf $(SWAGGERDOCS)

format:
$(GOFMT) -s -w */*.go
$(GOIMPORTS) -w */*.go
$(GOFMT) -s -w .
$(GOIMPORTS) -w .
$(NPM_FORMAT)

testgo:
go test `go list ./... | grep -v swaggerdocs`
Expand Down
160 changes: 80 additions & 80 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func InitConfig(logger *otelzap.Logger) {
viper.SetDefault("config.allow_guests", true)
viper.SetDefault("config.allow_registration", true)
viper.SetDefault("config.allow_jira_import", true)
viper.SetDefault("config.allow_csv_import",true)
viper.SetDefault("config.allow_csv_import", true)
viper.SetDefault("config.default_locale", "en")
viper.SetDefault("config.friendly_ui_verbs", false)
viper.SetDefault("config.allow_external_api", true)
Expand Down Expand Up @@ -95,85 +95,85 @@ func InitConfig(logger *otelzap.Logger) {
viper.SetDefault("auth.header.usernameHeader", "Remote-User")
viper.SetDefault("auth.header.emailHeader", "Remote-Email")

viper.BindEnv("http.cookie_hashkey", "COOKIE_HASHKEY")
viper.BindEnv("http.port", "PORT")
viper.BindEnv("http.secure_cookie", "COOKIE_SECURE")
viper.BindEnv("http.backend_cookie_name", "SECURE_COOKIE_NAME")
viper.BindEnv("http.session_cookie_name", "SESSION_COOKIE_NAME")
viper.BindEnv("http.frontend_cookie_name", "FRONTEND_COOKIE_NAME")
viper.BindEnv("http.domain", "APP_DOMAIN")
viper.BindEnv("http.path_prefix", "PATH_PREFIX")
viper.BindEnv("http.write_timeout", "HTTP_WRITE_TIMEOUT")
viper.BindEnv("http.read_timeout", "HTTP_READ_TIMEOUT")
viper.BindEnv("http.idle_timeout", "HTTP_IDLE_TIMEOUT")
viper.BindEnv("http.read_header_timeout", "HTTP_READ_HEADER_TIMEOUT")

viper.BindEnv("analytics.enabled", "ANALYTICS_ENABLED")
viper.BindEnv("analytics.id", "ANALYTICS_ID")
viper.BindEnv("admin.email", "ADMIN_EMAIL")

viper.BindEnv("otel.enabled", "OTEL_ENABLED")
viper.BindEnv("otel.service_name", "OTEL_SERVICE_NAME")
viper.BindEnv("otel.collector_url", "OTEL_COLLECTOR_URL")
viper.BindEnv("otel.insecure_mode", "OTEL_INSECURE_MODE")

viper.BindEnv("db.host", "DB_HOST")
viper.BindEnv("db.port", "DB_PORT")
viper.BindEnv("db.user", "DB_USER")
viper.BindEnv("db.pass", "DB_PASS")
viper.BindEnv("db.name", "DB_NAME")
viper.BindEnv("db.sslmode", "DB_SSLMODE")
viper.BindEnv("db.max_open_conns", "DB_MAX_OPEN_CONNS")
viper.BindEnv("db.max_idle_conns", "DB_MAX_IDLE_CONNS")
viper.BindEnv("db.conn_max_lifetime", "DB_CONN_MAX_LIFETIME")

viper.BindEnv("smtp.enabled", "SMTP_ENABLED")
viper.BindEnv("smtp.host", "SMTP_HOST")
viper.BindEnv("smtp.port", "SMTP_PORT")
viper.BindEnv("smtp.secure", "SMTP_SECURE")
viper.BindEnv("smtp.identity", "SMTP_IDENTITY")
viper.BindEnv("smtp.user", "SMTP_USER")
viper.BindEnv("smtp.pass", "SMTP_PASS")
viper.BindEnv("smtp.sender", "SMTP_SENDER")

viper.BindEnv("config.aes_hashkey", "CONFIG_AES_HASHKEY")
viper.BindEnv("config.allowedPointValues", "CONFIG_POINTS_ALLOWED")
viper.BindEnv("config.defaultPointValues", "CONFIG_POINTS_DEFAULT")
viper.BindEnv("config.show_warrior_rank", "CONFIG_SHOW_RANK")
viper.BindEnv("config.avatar_service", "CONFIG_AVATAR_SERVICE")
viper.BindEnv("config.toast_timeout", "CONFIG_TOAST_TIMEOUT")
viper.BindEnv("config.allow_guests", "CONFIG_ALLOW_GUESTS")
viper.BindEnv("config.allow_registration", "CONFIG_ALLOW_REGISTRATION")
viper.BindEnv("config.allow_jira_import", "CONFIG_ALLOW_JIRA_IMPORT")
viper.BindEnv("config.allow_CSV_import", "CONFIG_ALLOW_CSV_IMPORT")
viper.BindEnv("config.default_locale", "CONFIG_DEFAULT_LOCALE")
viper.BindEnv("config.friendly_ui_verbs", "CONFIG_FRIENDLY_UI_VERBS")
viper.BindEnv("config.allow_external_api", "CONFIG_ALLOW_EXTERNAL_API")
viper.BindEnv("config.external_api_verify_required", "CONFIG_EXTERNAL_API_VERIFY_REQUIRED")
viper.BindEnv("config.user_apikey_limit", "CONFIG_USER_APIKEY_LIMIT")
viper.BindEnv("config.show_active_countries", "CONFIG_SHOW_ACTIVE_COUNTRIES")
viper.BindEnv("config.cleanup_battles_days_old", "CONFIG_CLEANUP_BATTLES_DAYS_OLD")
viper.BindEnv("config.cleanup_guests_days_old", "CONFIG_CLEANUP_GUESTS_DAYS_OLD")
viper.BindEnv("config.cleanup_retros_days_old", "CONFIG_CLEANUP_RETROS_DAYS_OLD")
viper.BindEnv("config.cleanup_storyboards_days_old", "CONFIG_CLEANUP_STORYBOARDS_DAYS_OLD")
viper.BindEnv("config.organizations_enabled", "CONFIG_ORGANIZATIONS_ENABLED")
viper.BindEnv("config.require_teams", "CONFIG_REQUIRE_TEAMS")

viper.BindEnv("feature.poker", "FEATURE_POKER")
viper.BindEnv("feature.retro", "FEATURE_RETRO")
viper.BindEnv("feature.storyboard", "FEATURE_STORYBOARD")

viper.BindEnv("auth.method", "AUTH_METHOD")
viper.BindEnv("auth.ldap.url", "AUTH_LDAP_URL")
viper.BindEnv("auth.ldap.use_tls", "AUTH_LDAP_USE_TLS")
viper.BindEnv("auth.ldap.bindname", "AUTH_LDAP_BINDNAME")
viper.BindEnv("auth.ldap.bindpass", "AUTH_LDAP_BINDPASS")
viper.BindEnv("auth.ldap.basedn", "AUTH_LDAP_BASEDN")
viper.BindEnv("auth.ldap.filter", "AUTH_LDAP_FILTER")
viper.BindEnv("auth.ldap.mail_attr", "AUTH_LDAP_MAIL_ATTR")
viper.BindEnv("auth.ldap.cn_attr", "AUTH_LDAP_CN_ATTR")
viper.BindEnv("auth.header.usernameHeader", "AUTH_HEADER_USERNAME_HEADER")
viper.BindEnv("auth.header.emailHeader", "AUTH_HEADER_EMAIL_HEADER")
_ = viper.BindEnv("http.cookie_hashkey", "COOKIE_HASHKEY")
_ = viper.BindEnv("http.port", "PORT")
_ = viper.BindEnv("http.secure_cookie", "COOKIE_SECURE")
_ = viper.BindEnv("http.backend_cookie_name", "SECURE_COOKIE_NAME")
_ = viper.BindEnv("http.session_cookie_name", "SESSION_COOKIE_NAME")
_ = viper.BindEnv("http.frontend_cookie_name", "FRONTEND_COOKIE_NAME")
_ = viper.BindEnv("http.domain", "APP_DOMAIN")
_ = viper.BindEnv("http.path_prefix", "PATH_PREFIX")
_ = viper.BindEnv("http.write_timeout", "HTTP_WRITE_TIMEOUT")
_ = viper.BindEnv("http.read_timeout", "HTTP_READ_TIMEOUT")
_ = viper.BindEnv("http.idle_timeout", "HTTP_IDLE_TIMEOUT")
_ = viper.BindEnv("http.read_header_timeout", "HTTP_READ_HEADER_TIMEOUT")

_ = viper.BindEnv("analytics.enabled", "ANALYTICS_ENABLED")
_ = viper.BindEnv("analytics.id", "ANALYTICS_ID")
_ = viper.BindEnv("admin.email", "ADMIN_EMAIL")

_ = viper.BindEnv("otel.enabled", "OTEL_ENABLED")
_ = viper.BindEnv("otel.service_name", "OTEL_SERVICE_NAME")
_ = viper.BindEnv("otel.collector_url", "OTEL_COLLECTOR_URL")
_ = viper.BindEnv("otel.insecure_mode", "OTEL_INSECURE_MODE")

_ = viper.BindEnv("db.host", "DB_HOST")
_ = viper.BindEnv("db.port", "DB_PORT")
_ = viper.BindEnv("db.user", "DB_USER")
_ = viper.BindEnv("db.pass", "DB_PASS")
_ = viper.BindEnv("db.name", "DB_NAME")
_ = viper.BindEnv("db.sslmode", "DB_SSLMODE")
_ = viper.BindEnv("db.max_open_conns", "DB_MAX_OPEN_CONNS")
_ = viper.BindEnv("db.max_idle_conns", "DB_MAX_IDLE_CONNS")
_ = viper.BindEnv("db.conn_max_lifetime", "DB_CONN_MAX_LIFETIME")

_ = viper.BindEnv("smtp.enabled", "SMTP_ENABLED")
_ = viper.BindEnv("smtp.host", "SMTP_HOST")
_ = viper.BindEnv("smtp.port", "SMTP_PORT")
_ = viper.BindEnv("smtp.secure", "SMTP_SECURE")
_ = viper.BindEnv("smtp.identity", "SMTP_IDENTITY")
_ = viper.BindEnv("smtp.user", "SMTP_USER")
_ = viper.BindEnv("smtp.pass", "SMTP_PASS")
_ = viper.BindEnv("smtp.sender", "SMTP_SENDER")

_ = viper.BindEnv("config.aes_hashkey", "CONFIG_AES_HASHKEY")
_ = viper.BindEnv("config.allowedPointValues", "CONFIG_POINTS_ALLOWED")
_ = viper.BindEnv("config.defaultPointValues", "CONFIG_POINTS_DEFAULT")
_ = viper.BindEnv("config.show_warrior_rank", "CONFIG_SHOW_RANK")
_ = viper.BindEnv("config.avatar_service", "CONFIG_AVATAR_SERVICE")
_ = viper.BindEnv("config.toast_timeout", "CONFIG_TOAST_TIMEOUT")
_ = viper.BindEnv("config.allow_guests", "CONFIG_ALLOW_GUESTS")
_ = viper.BindEnv("config.allow_registration", "CONFIG_ALLOW_REGISTRATION")
_ = viper.BindEnv("config.allow_jira_import", "CONFIG_ALLOW_JIRA_IMPORT")
_ = viper.BindEnv("config.allow_CSV_import", "CONFIG_ALLOW_CSV_IMPORT")
_ = viper.BindEnv("config.default_locale", "CONFIG_DEFAULT_LOCALE")
_ = viper.BindEnv("config.friendly_ui_verbs", "CONFIG_FRIENDLY_UI_VERBS")
_ = viper.BindEnv("config.allow_external_api", "CONFIG_ALLOW_EXTERNAL_API")
_ = viper.BindEnv("config.external_api_verify_required", "CONFIG_EXTERNAL_API_VERIFY_REQUIRED")
_ = viper.BindEnv("config.user_apikey_limit", "CONFIG_USER_APIKEY_LIMIT")
_ = viper.BindEnv("config.show_active_countries", "CONFIG_SHOW_ACTIVE_COUNTRIES")
_ = viper.BindEnv("config.cleanup_battles_days_old", "CONFIG_CLEANUP_BATTLES_DAYS_OLD")
_ = viper.BindEnv("config.cleanup_guests_days_old", "CONFIG_CLEANUP_GUESTS_DAYS_OLD")
_ = viper.BindEnv("config.cleanup_retros_days_old", "CONFIG_CLEANUP_RETROS_DAYS_OLD")
_ = viper.BindEnv("config.cleanup_storyboards_days_old", "CONFIG_CLEANUP_STORYBOARDS_DAYS_OLD")
_ = viper.BindEnv("config.organizations_enabled", "CONFIG_ORGANIZATIONS_ENABLED")
_ = viper.BindEnv("config.require_teams", "CONFIG_REQUIRE_TEAMS")

_ = viper.BindEnv("feature.poker", "FEATURE_POKER")
_ = viper.BindEnv("feature.retro", "FEATURE_RETRO")
_ = viper.BindEnv("feature.storyboard", "FEATURE_STORYBOARD")

_ = viper.BindEnv("auth.method", "AUTH_METHOD")
_ = viper.BindEnv("auth.ldap.url", "AUTH_LDAP_URL")
_ = viper.BindEnv("auth.ldap.use_tls", "AUTH_LDAP_USE_TLS")
_ = viper.BindEnv("auth.ldap.bindname", "AUTH_LDAP_BINDNAME")
_ = viper.BindEnv("auth.ldap.bindpass", "AUTH_LDAP_BINDPASS")
_ = viper.BindEnv("auth.ldap.basedn", "AUTH_LDAP_BASEDN")
_ = viper.BindEnv("auth.ldap.filter", "AUTH_LDAP_FILTER")
_ = viper.BindEnv("auth.ldap.mail_attr", "AUTH_LDAP_MAIL_ATTR")
_ = viper.BindEnv("auth.ldap.cn_attr", "AUTH_LDAP_CN_ATTR")
_ = viper.BindEnv("auth.header.usernameHeader", "AUTH_HEADER_USERNAME_HEADER")
_ = viper.BindEnv("auth.header.emailHeader", "AUTH_HEADER_EMAIL_HEADER")

err := viper.ReadInConfig()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions db/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package db
import (
"context"
"database/sql"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"
"go.uber.org/zap"
Expand Down
1 change: 1 addition & 0 deletions db/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"

Expand Down
5 changes: 3 additions & 2 deletions db/apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"database/sql"
"errors"
"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"
"strings"
"time"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"

"go.uber.org/zap"
)

Expand Down
3 changes: 2 additions & 1 deletion db/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"encoding/base64"
"errors"
"fmt"
"image/png"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"
"image/png"

"github.com/pquerna/otp/totp"
"go.uber.org/zap"
Expand Down
7 changes: 4 additions & 3 deletions db/battles.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"database/sql"
"encoding/json"
"errors"
"strings"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/microcosm-cc/bluemonday"
"github.com/uptrace/opentelemetry-go-extra/otelzap"
"strings"

"go.uber.org/zap"
)
Expand All @@ -21,7 +22,7 @@ type BattleService struct {
HTMLSanitizerPolicy *bluemonday.Policy
}

//CreateBattle creates a new story pointing session (battle)
// CreateBattle creates a new story pointing session (battle)
func (d *BattleService) CreateBattle(ctx context.Context, LeaderID string, BattleName string, PointValuesAllowed []string, Plans []*thunderdome.Plan, AutoFinishVoting bool, PointAverageRounding string, JoinCode string, LeaderCode string, HideVoterIdentity bool) (*thunderdome.Battle, error) {
var pointValuesJSON, _ = json.Marshal(PointValuesAllowed)
var encryptedJoinCode string
Expand Down Expand Up @@ -97,7 +98,7 @@ func (d *BattleService) CreateBattle(ctx context.Context, LeaderID string, Battl
return b, nil
}

//TeamCreateBattle creates a new story pointing session (battle) associated to a team
// TeamCreateBattle creates a new story pointing session (battle) associated to a team
func (d *BattleService) TeamCreateBattle(ctx context.Context, TeamID string, LeaderID string, BattleName string, PointValuesAllowed []string, Plans []*thunderdome.Plan, AutoFinishVoting bool, PointAverageRounding string, JoinCode string, LeaderCode string, HideVoterIdentity bool) (*thunderdome.Battle, error) {
var pointValuesJSON, _ = json.Marshal(PointValuesAllowed)
var encryptedJoinCode string
Expand Down
1 change: 1 addition & 0 deletions db/checkin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/microcosm-cc/bluemonday"
"github.com/uptrace/opentelemetry-go-extra/otelzap"
Expand Down
1 change: 1 addition & 0 deletions db/departments.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package db
import (
"context"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"

"go.uber.org/zap"
Expand Down
1 change: 1 addition & 0 deletions db/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"

Expand Down
1 change: 1 addition & 0 deletions db/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package db
import (
"database/sql"
"encoding/json"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"

"go.uber.org/zap"
Expand Down
1 change: 1 addition & 0 deletions db/retro.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"

Expand Down
1 change: 1 addition & 0 deletions db/retro_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package db
import (
"database/sql"
"encoding/json"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"

"go.uber.org/zap"
Expand Down
1 change: 1 addition & 0 deletions db/retro_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"go.uber.org/zap"
)
Expand Down
1 change: 1 addition & 0 deletions db/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"

"go.uber.org/zap"
Expand Down
1 change: 1 addition & 0 deletions db/storyboard_goals.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"encoding/json"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"

"go.uber.org/zap"
Expand Down
5 changes: 3 additions & 2 deletions db/storyboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"

Expand All @@ -18,7 +19,7 @@ type StoryboardService struct {
AESHashKey string
}

//CreateStoryboard adds a new storyboard
// CreateStoryboard adds a new storyboard
func (d *StoryboardService) CreateStoryboard(ctx context.Context, OwnerID string, StoryboardName string, JoinCode string, FacilitatorCode string) (*thunderdome.Storyboard, error) {
var encryptedJoinCode string
var encryptedFacilitatorCode string
Expand Down Expand Up @@ -61,7 +62,7 @@ func (d *StoryboardService) CreateStoryboard(ctx context.Context, OwnerID string
return b, nil
}

//TeamCreateStoryboard adds a new storyboard associated to a team
// TeamCreateStoryboard adds a new storyboard associated to a team
func (d *StoryboardService) TeamCreateStoryboard(ctx context.Context, TeamID string, OwnerID string, StoryboardName string, JoinCode string, FacilitatorCode string) (*thunderdome.Storyboard, error) {
var encryptedJoinCode string
var encryptedFacilitatorCode string
Expand Down
1 change: 1 addition & 0 deletions db/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"errors"

"github.com/StevenWeathers/thunderdome-planning-poker/thunderdome"
"github.com/uptrace/opentelemetry-go-extra/otelzap"

Expand Down
Loading

0 comments on commit a6059e4

Please sign in to comment.