Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
reearth-app[bot] committed Jan 20, 2025
2 parents 1fc67f9 + 6b53ac4 commit e8da02e
Show file tree
Hide file tree
Showing 38 changed files with 2,016 additions and 567 deletions.
1 change: 0 additions & 1 deletion .github/reviewer-lottery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ groups:
usernames:
- airslice
- mkumbobeaty
- pyshx
- m-abe-dev
5 changes: 1 addition & 4 deletions .github/workflows/deploy_server_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
env:
GCP_REGION: asia-northeast1
IMAGE: reearth/reearth-visualizer-api:nightly
IMAGE_GCP: us-central1-docker.pkg.dev/reearth-oss/reearth/reearth-visualizer-api:nightly
GCP_REGION: asia-northeast1
jobs:
deploy_test:
name: Deploy app to test env
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-visualizer'
steps:
- uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- name: Configure docker
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- name: docker push
Expand Down
29 changes: 3 additions & 26 deletions .github/workflows/deploy_web_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,21 @@ name: deploy-web-nightly
on:
workflow_dispatch:
workflow_call:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
env:
REEARTH_URL: visualizer.test.reearth.dev
GCP_REGION: us-central1
GCS_DEST: gs://reearth-visualizer-oss-static-bucket/

IMAGE: reearth/reearth-visualizer-web:nightly
IMAGE_GCP: us-central1-docker.pkg.dev/reearth-oss/reearth/reearth-visualizer-web:nightly

jobs:
# TODO: Remove later after migrating to Cloud Run
deploy_test_old:
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-visualizer'
steps:
- uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- uses: dsaltares/fetch-gh-release-asset@master
with:
version: tags/nightly
file: reearth-web_nightly.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
- run: tar -xvf reearth-web_nightly.tar.gz
- name: rsync
run: gsutil -m -h "Cache-Control:no-store" rsync -x "^reearth_config\\.json$|^cesium_ion_token\\.txt$" -dr reearth-web/ $GCS_DEST

deploy_test:
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-visualizer'
steps:
- uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- name: Configure docker
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- name: docker push
Expand Down
52 changes: 38 additions & 14 deletions server/e2e/common.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package e2e

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net"
"net/http"
"regexp"
Expand Down Expand Up @@ -244,25 +247,46 @@ func RequestWithMultipart(e *httpexpect.Expect, user string, requestBody map[str
JSON()
}

func JSONEqRegexp(t *testing.T, rx string, str string) bool {
func JSONEqRegexp(t *testing.T, actual string, expected string) bool {
return assert.Regexp(
t,
regexp.MustCompile(strings.ReplaceAll(aligningJSON(t, expected), "[", "\\[")),
aligningJSON(t, actual),
)
}

var rx1 map[string]interface{}
err := json.Unmarshal([]byte(rx), &rx1)
assert.Nil(t, err)
func RegexpJSONEReadCloser(t *testing.T, actual io.ReadCloser, expected string) bool {
defer func() {
if err := actual.Close(); err != nil {
t.Errorf("failed to close reader: %v", err)
}
}()
actualBuf := new(bytes.Buffer)
_, err := actualBuf.ReadFrom(actual)
assert.NoError(t, err)
return JSONEqRegexp(t, actualBuf.String(), expected)
}

rx2, err := json.Marshal(rx1)
func JSONEqRegexpInterface(t *testing.T, actual interface{}, expected string) bool {
actualBytes, err := json.Marshal(actual)
assert.Nil(t, err)
return JSONEqRegexp(t, string(actualBytes), expected)
}

var str1 map[string]interface{}
err = json.Unmarshal([]byte(str), &str1)
func aligningJSON(t *testing.T, str string) string {
// Unmarshal and Marshal to make the JSON format consistent
var obj interface{}
err := json.Unmarshal([]byte(str), &obj)
assert.Nil(t, err)

str2, err := json.Marshal(str1)
strBytes, err := json.Marshal(obj)
assert.Nil(t, err)
return string(strBytes)
}

return assert.Regexp(
t,
regexp.MustCompile(strings.ReplaceAll(string(rx2), "[", "\\[")),
string(str2),
)
func toJSONString(v interface{}) (string, error) {
jsonData, err := json.Marshal(v)
if err != nil {
return "", fmt.Errorf("failed to marshal JSON: %w", err)
}
return string(jsonData), nil
}
4 changes: 3 additions & 1 deletion server/e2e/gql_asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ func createAsset(t *testing.T, e *httpexpect.Expect, filePath string, coreSuppor
},
"query": CreateAssetMutation,
}
operations, err := toJSONString(requestBody)
assert.Nil(t, err)
return e.POST("/api/graphql").
WithHeader("Origin", "https://example.com").
WithHeader("authorization", "Bearer test").
WithHeader("X-Reearth-Debug-User", uID.String()).
WithMultipart().
WithFormField("operations", toJSONString(requestBody)).
WithFormField("operations", operations).
WithFormField("map", `{"0": ["variables.file"]}`).
WithFile("0", filePath).
Expect().
Expand Down
Loading

0 comments on commit e8da02e

Please sign in to comment.