Skip to content

Commit

Permalink
Merge branch 'main' into fix-web/asset-ref-icon
Browse files Browse the repository at this point in the history
  • Loading branch information
caichi-t authored Oct 24, 2024
2 parents 541e9c9 + 0f3f72a commit 0feba01
Show file tree
Hide file tree
Showing 28 changed files with 577 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
id: info
# The tag name should be retrieved lazily, as tagging may be delayed.
env:
BRANCH: ${{ github.event.workflow_run.head_branch }}
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
if [[ "$BRANCH" = "release" ]]; then
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: server/go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand All @@ -35,6 +36,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: server/go.mod
- name: check forgotten translations
working-directory: server
run: make i18n-ci
Expand All @@ -53,6 +55,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: server/go.mod
- name: test
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
working-directory: server
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: worker/go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand All @@ -36,6 +37,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: worker/go.mod
- name: test
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
working-directory: worker
Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/cron_ion_token_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ on:
- cron: "0 0 2 * *"
workflow_dispatch:
env:
GCS_DOMAIN: gs://cms.test.reearth.dev
REEARTH_CONFIG_FILENAME: reearth_config.json
CMS_WEB: reearth-cms-web
REGION: us-central1
jobs:
update_ion_token:
runs-on: ubuntu-latest
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Download reearth config
run: gsutil cp "${{ env.GCS_DOMAIN }}/${{ env.REEARTH_CONFIG_FILENAME }}" .
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER}}
- name: Get Cesium Ion token
id: ion_token
run: |
Expand All @@ -35,9 +36,9 @@ jobs:
" \
)
echo "token=${ION_TOKEN}" >> $GITHUB_OUTPUT
- name: Update Ion token in reearth config
- name: Update Cloud Run
run: |
echo $(cat ${{ env.REEARTH_CONFIG_FILENAME }} | jq -r '.cesiumIonAccessToken |= "${{ steps.ion_token.outputs.token }}"') > ${{ env.REEARTH_CONFIG_FILENAME }}
echo $(cat ${{ env.REEARTH_CONFIG_FILENAME }})
- name: Upload reearth config
run: gsutil -h "Cache-Control:no-store" cp reearth_config.json "${{ env.GCS_DOMAIN }}/${{ env.REEARTH_CONFIG_FILENAME }}"
gcloud run services update $CMS_WEB \
--update-env-vars REEARTH_CMS_CESIUM_ION_ACCESS_TOKEN=${{ steps.ion_token.outputs.token }} \
--region $REGION \
--platform managed
24 changes: 20 additions & 4 deletions .github/workflows/deploy_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
name: Deploy web to test env
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'ci-web' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
runs-on: ubuntu-latest
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/create-github-app-token@v1
id: app-token
Expand All @@ -55,7 +58,8 @@ jobs:
run: tar -xvf reearth-cms-web.tar.gz
- uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GCP_SA_KEY }}"
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Deploy
Expand All @@ -65,12 +69,16 @@ jobs:
name: Deploy server to test env
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'server-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4

- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
Expand All @@ -92,12 +100,16 @@ jobs:
name: Deploy web to test env
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'web-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4

- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
Expand All @@ -119,12 +131,16 @@ jobs:
name: Deploy worker to test env
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'worker-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4

- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
Expand Down
13 changes: 13 additions & 0 deletions server/e2e/gql_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type fIds struct {
boolFId string
selectFId string
integerFId string
numberFId string
urlFId string
dateFId string
tagFID string
Expand Down Expand Up @@ -192,6 +193,16 @@ func createFieldOfEachType(t *testing.T, e *httpexpect.Expect, mId string) fIds
},
})

numberFId, _ := createField(e, mId, "number", "number", "number",
false, false, false, false, "Number",
map[string]any{
"number": map[string]any{
"defaultValue": nil,
"min": nil,
"max": nil,
},
})

urlFId, _ := createField(e, mId, "url", "url", "url",
false, false, false, false, "URL",
map[string]any{
Expand Down Expand Up @@ -260,6 +271,7 @@ func createFieldOfEachType(t *testing.T, e *httpexpect.Expect, mId string) fIds
boolFId,
selectFId,
integerFId,
numberFId,
urlFId,
dateFId,
tagFId,
Expand All @@ -276,6 +288,7 @@ func createFieldOfEachType(t *testing.T, e *httpexpect.Expect, mId string) fIds
boolFId: boolFId,
selectFId: selectFId,
integerFId: integerFId,
numberFId: numberFId,
urlFId: urlFId,
dateFId: dateFId,
tagFID: tagFId,
Expand Down
6 changes: 3 additions & 3 deletions server/e2e/gql_item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func TestClearItemValues(t *testing.T) {
})
fields := r1.Path("$.data.createItem.item.fields[:].value").Raw().([]any)
assert.Equal(t, []any{
"Text", "TextArea", "MarkdownText", aid.String(), true, "s1", float64(1), "https://www.1s.com", "2023-01-01T00:00:00Z", tagIds[0], true, "{\n\t\"type\": \"Point\",\n\t\"coordinates\": [102.0, 0.5]\n}", "{\n\t\"type\": \"Point\",\n\t\"coordinates\": [102.0, 0.5]\n}",
"Text", "TextArea", "MarkdownText", aid.String(), true, "s1", float64(1), nil, "https://www.1s.com", "2023-01-01T00:00:00Z", tagIds[0], true, "{\n\t\"type\": \"Point\",\n\t\"coordinates\": [102.0, 0.5]\n}", "{\n\t\"type\": \"Point\",\n\t\"coordinates\": [102.0, 0.5]\n}",
}, fields)
i1ver, _ := getItem(e, iid)
_, r2 := updateItem(e, iid, i1ver, []map[string]any{
Expand All @@ -432,7 +432,7 @@ func TestClearItemValues(t *testing.T) {
})
fields = r2.Path("$.data.updateItem.item.fields[:].value").Raw().([]any)
assert.Equal(t, []any{
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
}, fields)

iid2, _ := createItem(e, mId, sId, nil, []map[string]any{
Expand All @@ -453,7 +453,7 @@ func TestClearItemValues(t *testing.T) {
_, r3 := getItem(e, iid2)
fields2 := r3.Path("$.data.node.fields[:].value").Raw().([]any)
assert.Equal(t, []any{
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
}, fields2)

}
Expand Down
6 changes: 3 additions & 3 deletions server/e2e/integration_item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ func TestIntegrationModelImportJSONWithJsonInput(t *testing.T) {
mId, _ := createModel(e, pId, "test", "test", "test-1")
createFieldOfEachType(t, e, mId)

jsonContent := `[{"text": "test1", "bool": true, "integer": 1},{"text": "test2", "bool": false, "integer": 2},{"text": "test3", "bool": null, "integer": null}]`
jsonContent := `[{"text": "test1", "bool": true, "number": 1.1},{"text": "test2", "bool": false, "number": 2},{"text": "test3", "bool": null, "number": null}]`
aId := UploadAsset(e, pId, "./test1.json", jsonContent).Object().Value("id").String().Raw()
res := IntegrationModelImportJSON(e, mId, aId, "json", "insert", false, nil)
res.Object().IsEqual(map[string]any{
Expand Down Expand Up @@ -1573,7 +1573,7 @@ func TestIntegrationItemsAsCSV(t *testing.T) {
})

res := IntegrationItemsAsCSV(e, mId, 1, 10, i1Id, "", "", nil)
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,,,,,\n", i1Id)
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,number,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,,,,,,\n", i1Id)
res.IsEqual(expected)
}

Expand All @@ -1593,7 +1593,7 @@ func TestIntegrationItemsWithProjectAsCSV(t *testing.T) {
})

res := IntegrationItemsWithProjectAsCSV(e, pId, mId, 1, 10, i1Id, "", "", nil)
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,30,,,,\n", i1Id)
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,number,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,30,,,,,\n", i1Id)
res.IsEqual(expected)
}

Expand Down
72 changes: 66 additions & 6 deletions server/e2e/integration_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,52 @@ func TestIntegrationFieldCreateAPI(t *testing.T) {

res.ContainsKey("id")

res = e.GET("/api/models/{modelId}", mId1).
WithHeader("authorization", "Bearer "+secret).
Expect().
Status(http.StatusOK).
JSON().
Object()

res.ContainsSubset(map[string]any{
"name": "m1",
"id": mId1.String(),
"description": "m1 desc",
"public": true,
"key": ikey1.String(),
"projectId": pid,
"schemaId": sid1,
})

res.Value("createdAt").NotNull()
res.Value("updatedAt").NotNull()
res.Value("lastModified").NotNull()
resf := res.Value("schema").Object().Value("fields").Array()
resf.Length().IsEqual(3)
resf.Value(2).Object().ContainsSubset(map[string]any{
// "id": "", // generated
"key": "テスト",
"type": "text",
"required": false,
})
// endregion

//region bool
res = e.POST(endpoint, sid1).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"key": "fKey1",
"type": "bool",
"multiple": false,
"required": false,
}).
Expect().
Status(http.StatusOK).
JSON().
Object()

res.ContainsKey("id")

res = e.GET("/api/models/{modelId}", mId1).
WithHeader("authorization", "Bearer "+secret).
Expect().
Expand All @@ -192,18 +238,25 @@ func TestIntegrationFieldCreateAPI(t *testing.T) {
HasValue("projectId", pid).
HasValue("schemaId", sid1)

res.Value("schema").Object().Value("fields").Array().Length().IsEqual(3)
res.Value("createdAt").NotNull()
res.Value("updatedAt").NotNull()
res.Value("lastModified").NotNull()
resf = res.Value("schema").Object().Value("fields").Array()
resf.Length().IsEqual(4)
resf.Value(3).Object().ContainsSubset(map[string]any{
// "id": "", // generated
"key": "fKey1",
"type": "bool",
"required": false,
})
// endregion

//region bool
//region number
res = e.POST(endpoint, sid1).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"key": "fKey1",
"type": "bool",
"key": "fKey2",
"type": "number",
"multiple": false,
"required": false,
}).
Expand All @@ -229,17 +282,24 @@ func TestIntegrationFieldCreateAPI(t *testing.T) {
HasValue("projectId", pid).
HasValue("schemaId", sid1)

res.Value("schema").Object().Value("fields").Array().Length().IsEqual(4)
res.Value("createdAt").NotNull()
res.Value("updatedAt").NotNull()
res.Value("lastModified").NotNull()
resf = res.Value("schema").Object().Value("fields").Array()
resf.Length().IsEqual(5)
resf.Value(4).Object().ContainsSubset(map[string]any{
// "id": "", // generated
"key": "fKey2",
"type": "number",
"required": false,
})
// endregion

// region GeoObject
res = e.POST(endpoint, sid1).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"key": "fKey2",
"key": "fKey3",
"type": "geometryObject",
"multiple": false,
"required": false,
Expand Down
Loading

0 comments on commit 0feba01

Please sign in to comment.