Skip to content

Commit

Permalink
Merge branch 'main' into renovate/gomod
Browse files Browse the repository at this point in the history
  • Loading branch information
soneda-yuya authored Jan 31, 2025
2 parents 3ed1954 + 9268c10 commit 0ced75e
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 65 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
ARTIFACTS: server/dist/reearth_*.*
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.5"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v6
# TODO: fix error=archive named dist/reearth_0.0.0-SNAPSHOT-xxxxxxxx.tar.gz already exists. Check your archive name template
with:
distribution: goreleaser
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ jobs:
working-directory: server
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Extract reearth/web
run: tar -xvf reearth-web.tar.gz; mv reearth-web web; ls
- name: Build and push docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@6
with:
context: server
platforms: ${{ steps.options.outputs.platforms }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
echo "::set-output name=version::$VERSION"
echo "::set-output name=tags::$TAGS"
- name: Build and push docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: web
platforms: ${{ steps.options.outputs.platforms }}
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
- name: Rename artifact
run: mv reearth-web_rc.tar.gz $ARTIFACT
- name: Download latest changelog
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v8
with:
workflow: release.yml
name: changelog-${{ inputs.new_tag }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
web: ${{ steps.web.outputs.any_modified }}
server: ${{ steps.server.outputs.any_modified }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: changed files for web
id: web
uses: tj-actions/changed-files@v36
uses: tj-actions/changed-files@v45
with:
files: |
web
Expand All @@ -27,7 +27,7 @@ jobs:
- name: changed files for server
id: server
uses: tj-actions/changed-files@v36
uses: tj-actions/changed-files@v45
with:
files: |
server
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'v')
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: set up
uses: actions/setup-go@v5
with:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
fsouza/fake-gcs-server:1.52.1 \
-scheme http
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: set up
uses: actions/setup-go@v5
with:
Expand All @@ -58,7 +58,7 @@ jobs:
REEARTH_DB: mongodb://localhost
working-directory: server
- name: Send coverage report
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: server
4 changes: 2 additions & 2 deletions .github/workflows/ci_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -36,7 +36,7 @@ jobs:
- name: Check
run: yarn run coverage
- name: Send coverage report
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: web,web-beta,web-classic,web-utils
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/deploy_server_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
env:
GCP_REGION: asia-northeast1
GCP_REGION: us-central1
IMAGE: reearth/reearth-visualizer-api:nightly
IMAGE_GCP: us-central1-docker.pkg.dev/reearth-oss/reearth/reearth-visualizer-api:nightly
jobs:
deploy_test:
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-visualizer'
steps:
- uses: google-github-actions/auth@v0
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Configure docker
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy_web_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-visualizer'
steps:
- uses: google-github-actions/auth@v0
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Configure docker
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
REEARTH_WEB_E2E_USERNAME: ${{ secrets.REEARTH_WEB_E2E_USERNAME }}
REEARTH_WEB_E2E_PASSWORD: ${{ secrets.REEARTH_WEB_E2E_PASSWORD }}
REEARTH_WEB_E2E_SIGNUP_SECRET: ${{ secrets.REEARTH_WEB_E2E_SIGNUP_SECRET }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
repo: ${{ github.repository }}
latest: CHANGELOG_latest.md
- name: Upload latest CHANGELOG
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: changelog-${{ steps.changelog.outputs.version }}
path: CHANGELOG_latest.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: fix
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/reviewer_lottery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: uesteibar/reviewer-lottery@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- uses: uesteibar/reviewer-lottery@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
97 changes: 80 additions & 17 deletions server/e2e/gql_custom_property_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,49 @@ func TestUpdateCustomProperties(t *testing.T) {

func TestChangeCustomPropertyTitle(t *testing.T) {
e := Server(t, baseSeeder)
sId, lId, _, _ := setupTestData(e)

pId := createProject(e, "test")
_, _, sId := createScene(e, pId)
lId := addTestNLSLayerSimple(e, sId)

// change XXX -> ZZZ
requestBody := GraphQLRequest{
OperationName: "ChangeCustomPropertyTitle",
Query: `
mutation ChangeCustomPropertyTitle($input: ChangeCustomPropertyTitleInput!) {
changeCustomPropertyTitle(input: $input) {
layer {
id
}
}
}
`,
Variables: map[string]any{
"input": map[string]interface{}{
"layerId": lId,
"schema": map[string]any{
"AAA": "Text_1",
"BBB": "Int_2",
"CCC": "URL_3", // XXX -> CCC
"YYY": "Boolean_4",
},
"oldTitle": "CCC", // XXX -> CCC
"newTitle": "ZZZ", // XXX -> ZZZ
},
},
}
Request(e, uID.String(), requestBody)

proId1 := RandomString(10)
fId1 := addTestGeoJSONFeature(e, lId, proId1)
updateTestGeoJSONFeature(e, lId, fId1, proId1)

proId2 := RandomString(10)
fId2 := addTestGeoJSONFeature(e, lId, proId2)
updateTestGeoJSONFeature(e, lId, fId2, proId2)

// change XXX -> ZZZ
requestBody = GraphQLRequest{
OperationName: "ChangeCustomPropertyTitle",
Query: `
mutation ChangeCustomPropertyTitle($input: ChangeCustomPropertyTitleInput!) {
Expand Down Expand Up @@ -182,9 +222,47 @@ func TestChangeCustomPropertyTitle(t *testing.T) {

func TestRemoveCustomProperty(t *testing.T) {
e := Server(t, baseSeeder)
sId, lId, _, _ := setupTestData(e)
pId := createProject(e, "test")
_, _, sId := createScene(e, pId)
lId := addTestNLSLayerSimple(e, sId)

// remove XXX
requestBody := GraphQLRequest{
OperationName: "RemoveCustomProperty",
Query: `
mutation RemoveCustomProperty($input: RemoveCustomPropertyInput!) {
removeCustomProperty(input: $input) {
layer {
id
}
}
}
`,
Variables: map[string]any{
"input": map[string]interface{}{
"layerId": lId,
"schema": map[string]any{
"AAA": "Text_1",
"BBB": "Int_2",
// "XXX": "URL_3", remove
"YYY": "Boolean_3",
},
"removedTitle": "CCC",
},
},
}
Request(e, uID.String(), requestBody)

proId1 := RandomString(10)
fId1 := addTestGeoJSONFeature(e, lId, proId1)
updateTestGeoJSONFeature(e, lId, fId1, proId1)

proId2 := RandomString(10)
fId2 := addTestGeoJSONFeature(e, lId, proId2)
updateTestGeoJSONFeature(e, lId, fId2, proId2)

// remove XXX
requestBody = GraphQLRequest{
OperationName: "RemoveCustomProperty",
Query: `
mutation RemoveCustomProperty($input: RemoveCustomPropertyInput!) {
Expand Down Expand Up @@ -263,21 +341,6 @@ func TestRemoveCustomProperty(t *testing.T) {

// below Common functions -----------------------------------------------------

func setupTestData(e *httpexpect.Expect) (sId string, lId string, fId1 string, fId2 string) {
pId := createProject(e, "test")
_, _, sId = createScene(e, pId)
lId = addTestNLSLayerSimple(e, sId)

proId1 := RandomString(10)
fId1 = addTestGeoJSONFeature(e, lId, proId1)
updateTestGeoJSONFeature(e, lId, fId1, proId1)

proId2 := RandomString(10)
fId2 = addTestGeoJSONFeature(e, lId, proId2)
updateTestGeoJSONFeature(e, lId, fId2, proId2)
return
}

func getNewLayersOfScene(e *httpexpect.Expect, sId string) *httpexpect.Object {
requestBody := GraphQLRequest{
OperationName: "GetScene",
Expand Down
39 changes: 17 additions & 22 deletions server/internal/usecase/interactor/nlslayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,9 @@ func (i *NLSLayer) ChangeCustomPropertyTitle(ctx context.Context, inp interfaces
return nil, interfaces.ErrOperationDenied
}

// Check if oldTitle exists and newTitle doesn't conflict
titleExists := false
for _, feature := range layer.Sketch().FeatureCollection().Features() {
if props := feature.Properties(); props != nil {
if props := feature.Properties(); props != nil && *props != nil {
if _, ok := (*props)[oldTitle]; ok {
titleExists = true
}
Expand All @@ -744,17 +743,15 @@ func (i *NLSLayer) ChangeCustomPropertyTitle(ctx context.Context, inp interfaces
}
}

if !titleExists {
return nil, fmt.Errorf("property with title %s not found", oldTitle)
}

for _, feature := range layer.Sketch().FeatureCollection().Features() {
if props := feature.Properties(); props != nil {
for k, v := range *props {
if k == oldTitle {
value := v
delete(*props, k)
(*props)[newTitle] = value
if titleExists {
for _, feature := range layer.Sketch().FeatureCollection().Features() {
if props := feature.Properties(); props != nil {
for k, v := range *props {
if k == oldTitle {
value := v
delete(*props, k)
(*props)[newTitle] = value
}
}
}
}
Expand Down Expand Up @@ -808,15 +805,13 @@ func (i *NLSLayer) RemoveCustomProperty(ctx context.Context, inp interfaces.AddO
}
}

if !titleExists {
return nil, fmt.Errorf("property with title %s not found", removedTitle)
}

for _, feature := range layer.Sketch().FeatureCollection().Features() {
if props := feature.Properties(); props != nil {
for k := range *props {
if k == removedTitle {
delete(*props, k)
if titleExists {
for _, feature := range layer.Sketch().FeatureCollection().Features() {
if props := feature.Properties(); props != nil && *props != nil {
for k := range *props {
if k == removedTitle {
delete(*props, k)
}
}
}
}
Expand Down

0 comments on commit 0ced75e

Please sign in to comment.