Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ui-convert-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
KaWaite committed Sep 27, 2024
2 parents c1d8057 + 6114c06 commit 5fe7e3f
Show file tree
Hide file tree
Showing 536 changed files with 6,963 additions and 5,494 deletions.
4 changes: 2 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ websocket:
- changed-files:
- any-glob-to-any-file: websocket/**/*

worker:
engine:
- changed-files:
- any-glob-to-any-file: worker/**/*
- any-glob-to-any-file: engine/**/*
23 changes: 10 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
outputs:
ui: ${{ steps.ui.outputs.any_changed }}
api: ${{ steps.api.outputs.any_changed }}
worker: ${{ steps.worker.outputs.any_changed }}
engine: ${{ steps.engine.outputs.any_changed }}
websocket: ${{ steps.websocket.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -50,17 +50,14 @@ jobs:
.github/workflows/ci_websocket.yml
CHANGELOG.md
- name: changed files for worker
id: worker
- name: changed files for engine
id: engine
uses: tj-actions/changed-files@v41
with:
files: |
worker/crates/**
worker/tests/**
worker/Cargo.toml
worker/Cargo.lock
engine/**
.github/workflows/ci.yml
.github/workflows/ci_worker.yml
.github/workflows/ci_engine.yml
CHANGELOG.md
ci-api:
needs: prepare
Expand All @@ -74,17 +71,17 @@ jobs:
needs: prepare
if: needs.prepare.outputs.websocket == 'true'
uses: ./.github/workflows/ci_websocket.yml
ci-worker:
ci-engine:
needs: prepare
if: needs.prepare.outputs.worker == 'true'
uses: ./.github/workflows/ci_worker.yml
if: needs.prepare.outputs.engine == 'true'
uses: ./.github/workflows/ci_engine.yml
ci:
runs-on: ubuntu-latest
needs:
- ci-api
- ci-ui
- ci-websocket
- ci-worker
- ci-engine
if: '!failure()'
steps:
- run: echo OK
Expand Down Expand Up @@ -145,7 +142,7 @@ jobs:
new_tag_short: ${{ needs.ci-collect-info.outputs.new_tag_short }}
name: ${{ needs.ci-collect-info.outputs.name }}
sha: ${{ github.sha }}

build-ui:
needs:
- ci
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci-worker
name: ci-engine

on:
workflow_call:
Expand All @@ -17,7 +17,7 @@ env:

defaults:
run:
working-directory: worker
working-directory: engine

jobs:
ci:
Expand All @@ -30,8 +30,8 @@ jobs:
- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
workspaces: worker
shared-key: "worker-ci"
workspaces: engine
shared-key: "engine-ci"
- name: install required tools
uses: taiki-e/install-action@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release_quality_checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
node-version: lts/*

- name: get version
working-directory: ./worker/tools/plateau-gis-quality-checker
working-directory: ./workflow/plateau-gis-quality-checker
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: create release
Expand Down Expand Up @@ -100,17 +100,17 @@ jobs:
- name: enable corepack
run: |
corepack enable
working-directory: ./worker/tools/plateau-gis-quality-checker
working-directory: ./workflow/plateau-gis-quality-checker

- name: install frontend dependencies
run: yarn install
working-directory: ./worker/tools/plateau-gis-quality-checker
working-directory: ./workflow/plateau-gis-quality-checker

- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: ./worker/tools/plateau-gis-quality-checker
projectPath: ./workflow/plateau-gis-quality-checker
releaseId: ${{ needs.create-release.outputs.release_id }}
args: ${{ matrix.settings.args }}

Expand Down
9 changes: 5 additions & 4 deletions api/internal/adapter/gql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (

// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.

var ErrNotImplemented = errors.New("not implemented yet")
var ErrUnauthorized = errors.New("unauthorized")
var (
ErrNotImplemented = errors.New("not implemented yet")
ErrUnauthorized = errors.New("unauthorized")
)

type Resolver struct {
}
type Resolver struct{}

func NewResolver() ResolverRoot {
return &Resolver{}
Expand Down
1 change: 0 additions & 1 deletion api/internal/adapter/gql/resolver_mutation_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (r *mutationResolver) CreateProject(ctx context.Context, input gqlmodel.Cre
}

func (r *mutationResolver) UpdateProject(ctx context.Context, input gqlmodel.UpdateProjectInput) (*gqlmodel.ProjectPayload, error) {

pid, err := gqlmodel.ToID[id.Project](input.ProjectID)
if err != nil {
return nil, err
Expand Down
2 changes: 0 additions & 2 deletions api/internal/adapter/http/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (c *UserController) Signup(ctx context.Context, input SignupInput) (SignupO
Sub: *input.Sub,
Secret: input.Secret,
})

if err != nil {
return SignupOutput{}, err
}
Expand All @@ -91,7 +90,6 @@ func (c *UserController) Signup(ctx context.Context, input SignupInput) (SignupO
Lang: input.Lang,
Theme: input.Theme,
})

if err != nil {
return SignupOutput{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion api/internal/app/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func loadActionsData() error {
var err error
once.Do(func() {
// Hardcoded for now, Need to find more elegant way to deal with this @pyshx
resp, respErr := http.Get("https://raw.githubusercontent.com/reearth/reearth-flow/main/schema/actions.json")
resp, respErr := http.Get("https://raw.githubusercontent.com/reearth/reearth-flow/main/engine/schema/actions.json")
if respErr != nil {
err = respErr
return
Expand Down
11 changes: 2 additions & 9 deletions api/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ func errorMessage(err error, log func(string, ...interface{})) (int, string) {
code := http.StatusBadRequest
msg := err.Error()

if err2, ok := err.(*echo.HTTPError); ok {
var err2 *echo.HTTPError
if errors.As(err, &err2) {
code = err2.Code
if msg2, ok := err2.Message.(string); ok {
msg = msg2
Expand All @@ -163,14 +164,6 @@ func errorMessage(err error, log func(string, ...interface{})) (int, string) {
if err2.Internal != nil {
log("echo internal err: %+v", err2)
}
} else if errors.Is(err, rerror.ErrNotFound) {
code = http.StatusNotFound
msg = "not found"
} else {
if ierr := rerror.UnwrapErrInternal(err); ierr != nil {
code = http.StatusInternalServerError
msg = "internal server error"
}
}

return code, msg
Expand Down
3 changes: 2 additions & 1 deletion api/internal/app/auth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"context"
"errors"

"github.com/labstack/echo/v4"
"github.com/reearth/reearth-flow/api/internal/adapter"
Expand Down Expand Up @@ -50,7 +51,7 @@ func getUser(ctx context.Context, c echo.Context, multiUser accountinterfaces.Us
au := adapter.GetAuthInfo(ctx)
if au != nil {
u, err := multiUser.FetchBySub(ctx, au.Sub)
if err != nil && err != rerror.ErrNotFound {
if err != nil && !errors.Is(err, rerror.ErrNotFound) {
return nil, err
}
if u != nil {
Expand Down
98 changes: 50 additions & 48 deletions api/internal/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,56 @@ func init() {
pp.Default.SetColoringEnabled(false)
}

type Mailer mailer.Mailer
type Config struct {
mailer.Config
Port string `default:"8080" envconfig:"PORT"`
ServerHost string `pp:",omitempty"`
Host string `default:"http://localhost:8080"`
Host_Web string `pp:",omitempty"`
Dev bool `pp:",omitempty"`
DB string `default:"mongodb://localhost"`
DB_Account string `pp:",omitempty"`
DB_Users []appx.NamedURI `pp:",omitempty"`
GraphQL GraphQLConfig `pp:",omitempty"`
GCPProject string `envconfig:"GOOGLE_CLOUD_PROJECT" pp:",omitempty"`
GCPRegion string `envconfig:"GOOGLE_CLOUD_REGION" pp:",omitempty"`
Profiler string `pp:",omitempty"`
Tracer string `pp:",omitempty"`
TracerSample float64 `pp:",omitempty"`
AssetBaseURL string `default:"http://localhost:8080/assets"`
Origins []string `pp:",omitempty"`
Web_Disabled bool `pp:",omitempty"`
Web_App_Disabled bool `pp:",omitempty"`
Web map[string]string `pp:",omitempty"`
Web_Config JSON `pp:",omitempty"`
Web_Title string `pp:",omitempty"`
Web_FaviconURL string `pp:",omitempty"`
SignupSecret string `pp:",omitempty"`
SignupDisabled bool `pp:",omitempty"`
HTTPSREDIRECT bool `pp:",omitempty"`

// storage
GCS GCSConfig `pp:",omitempty"`
S3 S3Config `pp:",omitempty"`

// auth
Auth AuthConfigs `pp:",omitempty"`
Auth0 Auth0Config `pp:",omitempty"`
Cognito CognitoConfig `pp:",omitempty"`
AuthSrv AuthSrvConfig `pp:",omitempty"`
Auth_ISS string `pp:",omitempty"`
Auth_AUD string `pp:",omitempty"`
Auth_ALG *string `pp:",omitempty"`
Auth_TTL *int `pp:",omitempty"`
Auth_ClientID *string `pp:",omitempty"`
Auth_JWKSURI *string `pp:",omitempty"`

// worker
Worker_ImageURL string `pp:",omitempty"`
}
type (
Mailer mailer.Mailer
Config struct {
mailer.Config
Port string `default:"8080" envconfig:"PORT"`
ServerHost string `pp:",omitempty"`
Host string `default:"http://localhost:8080"`
Host_Web string `pp:",omitempty"`
Dev bool `pp:",omitempty"`
DB string `default:"mongodb://localhost"`
DB_Account string `pp:",omitempty"`
DB_Users []appx.NamedURI `pp:",omitempty"`
GraphQL GraphQLConfig `pp:",omitempty"`
GCPProject string `envconfig:"GOOGLE_CLOUD_PROJECT" pp:",omitempty"`
GCPRegion string `envconfig:"GOOGLE_CLOUD_REGION" pp:",omitempty"`
Profiler string `pp:",omitempty"`
Tracer string `pp:",omitempty"`
TracerSample float64 `pp:",omitempty"`
AssetBaseURL string `default:"http://localhost:8080/assets"`
Origins []string `pp:",omitempty"`
Web_Disabled bool `pp:",omitempty"`
Web_App_Disabled bool `pp:",omitempty"`
Web map[string]string `pp:",omitempty"`
Web_Config JSON `pp:",omitempty"`
Web_Title string `pp:",omitempty"`
Web_FaviconURL string `pp:",omitempty"`
SignupSecret string `pp:",omitempty"`
SignupDisabled bool `pp:",omitempty"`
HTTPSREDIRECT bool `pp:",omitempty"`

// storage
GCS GCSConfig `pp:",omitempty"`
S3 S3Config `pp:",omitempty"`

// auth
Auth AuthConfigs `pp:",omitempty"`
Auth0 Auth0Config `pp:",omitempty"`
Cognito CognitoConfig `pp:",omitempty"`
AuthSrv AuthSrvConfig `pp:",omitempty"`
Auth_ISS string `pp:",omitempty"`
Auth_AUD string `pp:",omitempty"`
Auth_ALG *string `pp:",omitempty"`
Auth_TTL *int `pp:",omitempty"`
Auth_ClientID *string `pp:",omitempty"`
Auth_JWKSURI *string `pp:",omitempty"`

// worker
Worker_ImageURL string `pp:",omitempty"`
}
)

func ReadConfig(debug bool) (*Config, error) {
// load .env
Expand Down
1 change: 0 additions & 1 deletion api/internal/app/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func initJaegerTracer(conf *config.Config) io.Closer {
jaegercfg.Logger(jLogger),
jaegercfg.Metrics(jMetricsFactory),
)

if err != nil {
log.Fatalf("Could not initialize jaeger tracer: %s\n", err.Error())
}
Expand Down
3 changes: 0 additions & 3 deletions api/internal/infrastructure/auth0/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ func New(domain, clientID, clientSecret string) *Auth0 {
}

func (a *Auth0) UpdateUser(ctx context.Context, p accountgateway.AuthenticatorUpdateUserParam) (data accountgateway.AuthenticatorUser, err error) {
if err != nil {
return
}

payload := map[string]string{}
if p.Name != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/internal/usecase/interactor/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type ContainerConfig struct {

func NewContainer(r *repo.Container, g *gateway.Container,
ar *accountrepo.Container, ag *accountgateway.Container,
config ContainerConfig) interfaces.Container {

config ContainerConfig,
) interfaces.Container {
return interfaces.Container{
Asset: NewAsset(r, g),
Project: NewProject(r, g),
Expand Down
10 changes: 7 additions & 3 deletions api/internal/usecase/interactor/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func TestUc_checkPermission(t *testing.T) {
readableWorkspaces: accountdomain.WorkspaceIDList{wid},
op: &usecase.Operator{
AcOperator: &accountusecase.Operator{
ReadableWorkspaces: accountdomain.WorkspaceIDList{wid}},
ReadableWorkspaces: accountdomain.WorkspaceIDList{wid},
},
},
wantErr: false,
},
Expand All @@ -47,7 +48,9 @@ func TestUc_checkPermission(t *testing.T) {
readableWorkspaces: accountdomain.WorkspaceIDList{accountdomain.NewWorkspaceID()},
op: &usecase.Operator{
AcOperator: &accountusecase.Operator{
ReadableWorkspaces: accountdomain.WorkspaceIDList{}}},
ReadableWorkspaces: accountdomain.WorkspaceIDList{},
},
},
wantErr: true,
},
{
Expand All @@ -66,7 +69,8 @@ func TestUc_checkPermission(t *testing.T) {
op: &usecase.Operator{
AcOperator: &accountusecase.Operator{
WritableWorkspaces: accountdomain.WorkspaceIDList{},
}},
},
},
wantErr: true,
},
}
Expand Down
4 changes: 1 addition & 3 deletions api/internal/usecase/interfaces/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ type CreateAssetParam struct {
File *file.File
}

var (
ErrCreateAssetFailed error = errors.New("failed to create asset")
)
var ErrCreateAssetFailed error = errors.New("failed to create asset")

type Asset interface {
Fetch(context.Context, []id.AssetID, *usecase.Operator) ([]*asset.Asset, error)
Expand Down
Loading

0 comments on commit 5fe7e3f

Please sign in to comment.