From 07b2cbaafa39271f565e3a156595d9fb35c9c8fe Mon Sep 17 00:00:00 2001 From: harehare Date: Fri, 13 Oct 2023 22:14:17 +0900 Subject: [PATCH 1/5] :fire: Remove fmt --- backend/internal/infra/firebase/storage.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/internal/infra/firebase/storage.go b/backend/internal/infra/firebase/storage.go index 57b50bc19..656a5849f 100644 --- a/backend/internal/infra/firebase/storage.go +++ b/backend/internal/infra/firebase/storage.go @@ -4,7 +4,6 @@ import ( "bytes" "compress/gzip" "context" - "fmt" "io" "strings" @@ -102,8 +101,6 @@ func (s *CloudStorage) Delete(ctx context.Context, prefix, uid, itemID string) m return mo.Err[bool](err) } - fmt.Println(getObjectName(prefix, uid, itemID)) - if err = bucket.Object(getObjectName(prefix, uid, itemID)).Delete(ctx); err != nil { return mo.Err[bool](err) } From 9db10f95f5fb412c41fced188da0b3abfb11f314 Mon Sep 17 00:00:00 2001 From: harehare Date: Sat, 14 Oct 2023 00:08:45 +0900 Subject: [PATCH 2/5] :bug: Fix deleting objects from cloud storage --- backend/.air.toml | 2 +- backend/internal/infra/firebase/storage.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/.air.toml b/backend/.air.toml index acc616e93..4eb541ee7 100644 --- a/backend/.air.toml +++ b/backend/.air.toml @@ -5,7 +5,7 @@ tmp_dir = "tmp" [build] args_bin = [] bin = "./tmp/main" -cmd = "go build -o ./tmp/main cmd/main.go" +cmd = "go build -o ./tmp/main cmd/api-server/main.go" delay = 0 exclude_dir = ["assets", "tmp", "vendor", "testdata"] exclude_file = [] diff --git a/backend/internal/infra/firebase/storage.go b/backend/internal/infra/firebase/storage.go index 656a5849f..912e5a3f6 100644 --- a/backend/internal/infra/firebase/storage.go +++ b/backend/internal/infra/firebase/storage.go @@ -4,9 +4,11 @@ import ( "bytes" "compress/gzip" "context" + "errors" "io" "strings" + "cloud.google.com/go/storage" firebaseStorage "firebase.google.com/go/v4/storage" "github.com/samber/mo" ) @@ -102,6 +104,10 @@ func (s *CloudStorage) Delete(ctx context.Context, prefix, uid, itemID string) m } if err = bucket.Object(getObjectName(prefix, uid, itemID)).Delete(ctx); err != nil { + if ok := errors.Is(err, storage.ErrObjectNotExist); ok { + return mo.Ok(true) + } + return mo.Err[bool](err) } From 8d02cadf33e1bbe4e14a94bc22a9e36f9c4ba387 Mon Sep 17 00:00:00 2001 From: harehare Date: Sat, 14 Oct 2023 11:02:16 +0900 Subject: [PATCH 3/5] :bug: Fix bug that prevented returning to the edit screen after deleting a diagram --- frontend/src/elm/Api/Request.elm | 8 ++++---- frontend/src/elm/Main.elm | 10 ++++++++++ frontend/src/elm/Page/List.elm | 6 +++--- frontend/src/elm/Ports.elm | 5 ++++- frontend/src/ts/db.ts | 2 +- frontend/src/ts/elm.ts | 1 + 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/frontend/src/elm/Api/Request.elm b/frontend/src/elm/Api/Request.elm index 2f34b7d4e..716c1472c 100644 --- a/frontend/src/elm/Api/Request.elm +++ b/frontend/src/elm/Api/Request.elm @@ -71,17 +71,17 @@ bookmark idToken itemID isBookmark = |> Task.mapError toError -delete : Maybe IdToken -> DiagramId -> Bool -> Task RequestError String +delete : Maybe IdToken -> DiagramId -> Bool -> Task RequestError DiagramId delete idToken itemID isPublic = Mutation.delete (DiagramId.toString itemID) isPublic |> Http.mutationRequest graphQLUrl |> authHeaders idToken |> Http.toTask - |> Task.map (\(Graphql.Scalar.Id id) -> id) + |> Task.map (\(Graphql.Scalar.Id id) -> DiagramId.fromString id) |> Task.mapError toError -deleteGist : Maybe IdToken -> AccessToken -> DiagramId -> Task RequestError String +deleteGist : Maybe IdToken -> AccessToken -> DiagramId -> Task RequestError DiagramId deleteGist idToken accessToken gistId = GithubRequest.deleteGist accessToken gistId |> Task.mapError RequestError.fromHttpError @@ -91,7 +91,7 @@ deleteGist idToken accessToken gistId = |> Http.mutationRequest graphQLUrl |> authHeaders idToken |> Http.toTask - |> Task.map (\(Graphql.Scalar.Id id) -> id) + |> Task.map (\(Graphql.Scalar.Id id) -> DiagramId.fromString id) |> Task.mapError toError ) diff --git a/frontend/src/elm/Main.elm b/frontend/src/elm/Main.elm index f16dd62ee..431e6ee68 100644 --- a/frontend/src/elm/Main.elm +++ b/frontend/src/elm/Main.elm @@ -753,6 +753,7 @@ subscriptions model = , Ports.loadSettingsFromLocalCompleted M.LoadSettingsFromLocal , Ports.startDownload M.StartDownload , Ports.gotLocalDiagramsJson (\json -> M.UpdateDiagramList (DiagramList.GotLocalDiagramsJson json)) + , Ports.removedLocalDiagram (\idString -> (Ok <| DiagramId.fromString idString) |> DiagramList.Removed |> M.UpdateDiagramList) , Ports.reload (\_ -> M.UpdateDiagramList DiagramList.Reload) , onVisibilityChange M.HandleVisibilityChange , onResize (\width height -> M.UpdateDiagram (DiagramModel.Resize width height)) @@ -1391,6 +1392,15 @@ processDiagramListMsg msg = DiagramList.GotExportDiagrams (Err e) -> showErrorMessage <| RequestError.toMessage e + DiagramList.Removed (Ok diagramId) -> + Return.map <| + \m -> + if (m.currentDiagram.id |> Maybe.withDefault (DiagramId.fromString "")) == diagramId then + { m | currentDiagram = DiagramItem.new DiagramType.UserStoryMap } + + else + m + DiagramList.Removed (Err _) -> showErrorMessage Message.messagEerrorOccurred diff --git a/frontend/src/elm/Page/List.elm b/frontend/src/elm/Page/List.elm index ac52544bb..efee2b226 100644 --- a/frontend/src/elm/Page/List.elm +++ b/frontend/src/elm/Page/List.elm @@ -93,7 +93,7 @@ import Json.Encode as E import List.Extra as ListEx import Message exposing (Lang) import Models.Color as Color -import Models.Diagram.Id as DiagramId +import Models.Diagram.Id as DiagramId exposing (DiagramId) import Models.Diagram.Item as DiagramItem exposing (DiagramItem) import Models.Diagram.Location as DiagramLocation import Models.Dialog as Dialog @@ -128,7 +128,7 @@ type Msg | Reload | Remove DiagramItem | RemoveRemote D.Value - | Removed (Result RequestError String) + | Removed (Result RequestError DiagramId) | Bookmarked (Result RequestError ()) | GotTimeZone Zone | GetDiagrams @@ -213,7 +213,7 @@ load : { session : Session, isOnline : Bool } -> Return.ReturnF Msg Model load { session, isOnline } = Return.andThen <| \m -> - Return.singleton { m | session = session, isOnline = isOnline } + Return.singleton { m | session = session, isOnline = isOnline, diagramList = DiagramList.notAsked } |> Return.command (getDiagrams ()) diff --git a/frontend/src/elm/Ports.elm b/frontend/src/elm/Ports.elm index 62ea491cc..d647d29ae 100644 --- a/frontend/src/elm/Ports.elm +++ b/frontend/src/elm/Ports.elm @@ -5,6 +5,7 @@ port module Ports exposing , closeLocalFile , copyText , downloadCompleted + , reload , focusEditor , fullscreen , getDiagram @@ -27,7 +28,7 @@ port module Ports exposing , openedLocalFile , progress , refreshToken - , reload + , removedLocalDiagram , removeRemoteDiagram , saveDiagram , saveLocalFile @@ -128,6 +129,8 @@ port progress : (Bool -> msg) -> Sub msg port refreshToken : () -> Cmd msg +port removedLocalDiagram : (String -> msg) -> Sub msg + port reload : (String -> msg) -> Sub msg diff --git a/frontend/src/ts/db.ts b/frontend/src/ts/db.ts index c143e80b9..73005088f 100644 --- a/frontend/src/ts/db.ts +++ b/frontend/src/ts/db.ts @@ -125,7 +125,7 @@ export const initDB = (app: ElmApp): void => { app.ports.removeRemoteDiagram.send(diagram); } else { await db.diagrams.delete(id); - app.ports.reload.send(''); + app.ports.removedLocalDiagram.send(id); } }); diff --git a/frontend/src/ts/elm.ts b/frontend/src/ts/elm.ts index dc7e1bedd..46937f561 100644 --- a/frontend/src/ts/elm.ts +++ b/frontend/src/ts/elm.ts @@ -61,6 +61,7 @@ export type ElmApp = { saveToLocalCompleted: Send; removeRemoteDiagram: Send; reload: Send; + removedLocalDiagram: Send; gotLocalDiagramJson: Send; gotLocalDiagramJsonForCopy: Send; gotLocalDiagramsJson: Send; From 1ec489656f06e5538ea67e2aa84f801b0117a6da Mon Sep 17 00:00:00 2001 From: harehare Date: Sat, 14 Oct 2023 21:14:54 +0900 Subject: [PATCH 4/5] :green_heart: Execute create-tag workflow when pull requests are merged --- .github/workflows/build_and_deploy.yml | 40 ---------------------- .github/workflows/create_tag.yml | 46 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/create_tag.yml diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 1c2f4306d..1f11e4578 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -97,43 +97,3 @@ jobs: run: curl --silent --show-error --fail $RENDER_DEPLOY_HOOK_URL > /dev/null env: RENDER_DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }} - - create-git-tag: - runs-on: ubuntu-latest - needs: [deploy-frontend, deploy-backend] - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - - name: get-npm-version - id: package-version - uses: martinbeentjes/npm-get-version-action@main - with: - path: frontend - - name: tag is already existing to GITHUB_ENV - run: | - tag_is_existing=$( - git fetch origin v${{ steps.package-version.outputs.current-version }} && - echo true || - echo false - ) - echo "TAG_IS_EXISTING=${tag_is_existing}" >> $GITHUB_ENV - - if: env.TAG_IS_EXISTING == 'false' - run: | - git tag v${{ steps.package-version.outputs.current-version }} - git push origin v${{ steps.package-version.outputs.current-version }} - - name: Build Changelog - if: env.TAG_IS_EXISTING == 'false' - id: github_release - uses: mikepenz/release-changelog-builder-action@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Release - if: env.TAG_IS_EXISTING == 'false' - uses: actions/create-release@v1 - with: - tag_name: v${{ steps.package-version.outputs.current-version }} - release_name: v${{ steps.package-version.outputs.current-version }} - body: ${{steps.github_release.outputs.changelog}} - allowUpdates: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/create_tag.yml b/.github/workflows/create_tag.yml new file mode 100644 index 000000000..e176d3411 --- /dev/null +++ b/.github/workflows/create_tag.yml @@ -0,0 +1,46 @@ +on: + pull_request: + branches: + - master + types: [closed] + +jobs: + create-tag: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: get-npm-version + id: package-version + uses: martinbeentjes/npm-get-version-action@main + with: + path: frontend + - name: tag is already existing to GITHUB_ENV + run: | + tag_is_existing=$( + git fetch origin v${{ steps.package-version.outputs.current-version }} && + echo true || + echo false + ) + echo "TAG_IS_EXISTING=${tag_is_existing}" >> $GITHUB_ENV + - if: env.TAG_IS_EXISTING == 'false' + run: | + git tag v${{ steps.package-version.outputs.current-version }} + git push origin v${{ steps.package-version.outputs.current-version }} + - name: Build Changelog + if: env.TAG_IS_EXISTING == 'false' + id: github_release + uses: mikepenz/release-changelog-builder-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Release + if: env.TAG_IS_EXISTING == 'false' + uses: actions/create-release@v1 + with: + tag_name: v${{ steps.package-version.outputs.current-version }} + release_name: v${{ steps.package-version.outputs.current-version }} + body: ${{steps.github_release.outputs.changelog}} + allowUpdates: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0a43d066d251e6d5b6c655baae66ba1ab0b9d28e Mon Sep 17 00:00:00 2001 From: harehare Date: Sat, 14 Oct 2023 21:27:10 +0900 Subject: [PATCH 5/5] :green_heart: Add noop deploy trigger --- .github/workflows/branch_deploy.yml | 2 ++ .github/workflows/build_and_deploy.yml | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/branch_deploy.yml b/.github/workflows/branch_deploy.yml index a0a2baeb1..89ae74715 100644 --- a/.github/workflows/branch_deploy.yml +++ b/.github/workflows/branch_deploy.yml @@ -17,6 +17,7 @@ jobs: outputs: continue: ${{ steps.branch-deploy.outputs.continue }} ref: ${{ steps.branch-deploy.outputs.ref }} + noop: ${{ steps.branch-deploy.outputs.noop }} steps: - uses: github/branch-deploy@v7.3.0 id: branch-deploy @@ -28,3 +29,4 @@ jobs: secrets: inherit with: ref: ${{ needs.branch-deploy.outputs.ref }} + noop: ${{ needs.branch-deploy.outputs.noop }} diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 1f11e4578..e2eaaebb2 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -6,6 +6,10 @@ on: ref: required: true type: string + noop: + default: "false" + required: false + type: string jobs: build: @@ -81,6 +85,7 @@ jobs: name: dist path: frontend/dist - uses: FirebaseExtended/action-hosting-deploy@v0 + if: ${{ inputs.noop != 'true' }} with: repoToken: "${{ secrets.GITHUB_TOKEN }}" firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_TEXTUSM }}" @@ -94,6 +99,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Deploy backend to render.com + if: ${{ inputs.noop != 'true' }} run: curl --silent --show-error --fail $RENDER_DEPLOY_HOOK_URL > /dev/null env: RENDER_DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}