Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrating from the org.json Library to Gson #248

Merged
merged 15 commits into from
Jan 29, 2024

Conversation

sanao1006
Copy link
Contributor

  • Using the org.json library requires manual mapping for each class, which is time-consuming.
  • Vulnerabilities in the org.json library appear frequently, making it difficult to maintain.
  • Since AGP also utilizes Gson, consolidating to a single library helps avoid the introduction of numerous libraries.

Migrate org.json to Gson for the above reasons

note

  • Passed all CaptureResultTest tests

related issue

Fixed #236

@sanao1006 sanao1006 marked this pull request as ready for review January 22, 2024 05:36
@sanao1006
Copy link
Contributor Author

@takahirom
Sorry, I have no idea what caused the CI failure.
Do you have any ideas?

@sanao1006
Copy link
Contributor Author

It appears that gson related errors are also occurring in diff test.

...
Caused by: com.google.gson.JsonIOException: Interfaces can't be instantiated! Register an InstanceCreator or a TypeAdapter for this type. Interface name: com.github.takahirom.roborazzi.CaptureResult
...

I'll try to investigate.

@takahirom
Copy link
Owner

We might have to implement like this 👀
https://github.com/google/gson/blob/main/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java#L69

@sanao1006 sanao1006 marked this pull request as draft January 26, 2024 04:03
@takahirom
Copy link
Owner

@sanao1006 I have attempted to use Gson's automatic conversion, but it hasn't worked yet. Could you take a look at it?

@sanao1006 sanao1006 marked this pull request as ready for review January 27, 2024 12:22
@sanao1006
Copy link
Contributor Author

@takahirom
Are there any other tasks still left to be resolved in this PR?

@takahirom
Copy link
Owner

As you can see, the diff comments are not working. Maybe the branch name is the cause but I want to check if it works before marge.
I'm addressing this issue. But if you have any recommendations let me know.
#253

Repository owner deleted a comment from github-actions bot Jan 29, 2024
@takahirom takahirom merged commit 215003e into takahirom:main Jan 29, 2024
5 checks passed
github-merge-queue bot referenced this pull request in slackhq/circuit Feb 18, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[io.github.takahirom.roborazzi](https://togithub.com/takahirom/roborazzi)
| plugin | minor | `1.9.0` -> `1.10.0` |
|
[io.github.takahirom.roborazzi:roborazzi-junit-rule](https://togithub.com/takahirom/roborazzi)
| dependencies | minor | `1.9.0` -> `1.10.0` |
|
[io.github.takahirom.roborazzi:roborazzi-compose](https://togithub.com/takahirom/roborazzi)
| dependencies | minor | `1.9.0` -> `1.10.0` |
|
[io.github.takahirom.roborazzi:roborazzi](https://togithub.com/takahirom/roborazzi)
| dependencies | minor | `1.9.0` -> `1.10.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>takahirom/roborazzi (io.github.takahirom.roborazzi)</summary>

###
[`v1.10.0`](https://togithub.com/takahirom/roborazzi/releases/tag/1.10.0)

[Compare
Source](https://togithub.com/takahirom/roborazzi/compare/1.9.0...1.10.0)

##### New experimental feature

##### Custom context data for images and reports

Custom context data enables the addition of information to images and
reports in Roborazzi's tests, which I believe is very important. For
example, it can include the test class name of a screenshot or whether
it is in dark mode.
You can now add custom context data using RoborazziOptions, and
Roborazzi will add the test class name metadata if you use
RoborazziRule. If you have any opinions about this feature, please let
me know at
[https://github.com/takahirom/roborazzi/issues/257](https://togithub.com/takahirom/roborazzi/issues/257).
Furthermore, this opens up possibilities with AI. Given that AI now
possesses multimodal capabilities, it has become feasible for AI to
process images.
This feature was made possible thanks to
[@&#8203;sanao1006](https://togithub.com/sanao1006) 's contribution of
migrating from org.json to gson.

```kotlin
    onView(ViewMatchers.isRoot())
      .captureRoboImage(
        roborazziOptions = RoborazziOptions(
          contextData = mapOf(
            "context_data_key" to "context_data_value"
          )
        )
      )
  }
```

<img width="1335" alt="image"
src="https://github.com/takahirom/roborazzi/assets/1386930/16341681-ab11-4f1c-b231-0c5a26e1a0e2">

##### Important bug fix

Gradle attempts to load the test cache whenever possible, but there was
an issue where Roborazzi couldn't restore images from the cache. This
release includes a fix for this problem. Thank you,
[@&#8203;francescocervone](https://togithub.com/francescocervone), for
reporting this issue.

##### What's Changed

- \[CI]Escape branch name by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/253](https://togithub.com/takahirom/roborazzi/pull/253)
- refactor: migrating from the `org.json` Library to `Gson` by
[@&#8203;sanao1006](https://togithub.com/sanao1006) in
[https://github.com/takahirom/roborazzi/pull/248](https://togithub.com/takahirom/roborazzi/pull/248)
- doc: Add build.gradle.kts examples by
[@&#8203;sanao1006](https://togithub.com/sanao1006) in
[https://github.com/takahirom/roborazzi/pull/256](https://togithub.com/takahirom/roborazzi/pull/256)
- Enable adding metadata to image by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/259](https://togithub.com/takahirom/roborazzi/pull/259)
- Add contextdata tabs to HTML report by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/260](https://togithub.com/takahirom/roborazzi/pull/260)
- Fix Roborazzi output cache by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/262](https://togithub.com/takahirom/roborazzi/pull/262)

##### New Contributors

- [@&#8203;sanao1006](https://togithub.com/sanao1006) made their first
contribution in
[https://github.com/takahirom/roborazzi/pull/248](https://togithub.com/takahirom/roborazzi/pull/248)

**Full Changelog**:
takahirom/roborazzi@1.9.0...1.10.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xOTQuMyIsInVwZGF0ZWRJblZlciI6IjM3LjE5NC4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
github-merge-queue bot referenced this pull request in slackhq/circuit Feb 19, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[io.github.takahirom.roborazzi](https://togithub.com/takahirom/roborazzi)
| plugin | patch | `1.10.0` -> `1.10.1` |
|
[io.github.takahirom.roborazzi:roborazzi-junit-rule](https://togithub.com/takahirom/roborazzi)
| dependencies | patch | `1.10.0` -> `1.10.1` |
|
[io.github.takahirom.roborazzi:roborazzi-compose](https://togithub.com/takahirom/roborazzi)
| dependencies | patch | `1.10.0` -> `1.10.1` |
|
[io.github.takahirom.roborazzi:roborazzi](https://togithub.com/takahirom/roborazzi)
| dependencies | patch | `1.10.0` -> `1.10.1` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>takahirom/roborazzi (io.github.takahirom.roborazzi)</summary>

###
[`v1.10.1`](https://togithub.com/takahirom/roborazzi/releases/tag/1.10.1)

[Compare
Source](https://togithub.com/takahirom/roborazzi/compare/1.10.0...1.10.1)

##### Changes from 1.10.0

This release includes a bug fix for a Javascript error that prevented
the HTML report from being displayed.

##### Changes from 1.9.0

##### New experimental feature

##### Custom context data for images and reports

Custom context data enables the addition of information to images and
reports in Roborazzi's tests, which I believe is very important. For
example, it can include the test class name of a screenshot or whether
it is in dark mode.
You can now add custom context data using RoborazziOptions, and
Roborazzi will add the test class name metadata if you use
RoborazziRule. If you have any opinions about this feature, please let
me know at
[https://github.com/takahirom/roborazzi/issues/257](https://togithub.com/takahirom/roborazzi/issues/257).
Furthermore, this opens up possibilities with AI. Given that AI now
possesses multimodal capabilities, it has become feasible for AI to
process images.
This feature was made possible thanks to
[@&#8203;sanao1006](https://togithub.com/sanao1006) 's contribution of
migrating from org.json to gson.

```kotlin
    onView(ViewMatchers.isRoot())
      .captureRoboImage(
        roborazziOptions = RoborazziOptions(
          contextData = mapOf(
            "context_data_key" to "context_data_value"
          )
        )
      )
  }
```

<img width="1335" alt="image"
src="https://github.com/takahirom/roborazzi/assets/1386930/16341681-ab11-4f1c-b231-0c5a26e1a0e2">

##### Important bug fix

Gradle attempts to load the test cache whenever possible, but there was
an issue where Roborazzi couldn't restore images from the cache. This
release includes a fix for this problem. Thank you,
[@&#8203;francescocervone](https://togithub.com/francescocervone), for
reporting this issue.

##### What's Changed

- \[CI]Escape branch name by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/253](https://togithub.com/takahirom/roborazzi/pull/253)
- refactor: migrating from the `org.json` Library to `Gson` by
[@&#8203;sanao1006](https://togithub.com/sanao1006) in
[https://github.com/takahirom/roborazzi/pull/248](https://togithub.com/takahirom/roborazzi/pull/248)
- doc: Add build.gradle.kts examples by
[@&#8203;sanao1006](https://togithub.com/sanao1006) in
[https://github.com/takahirom/roborazzi/pull/256](https://togithub.com/takahirom/roborazzi/pull/256)
- Enable adding metadata to image by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/259](https://togithub.com/takahirom/roborazzi/pull/259)
- Add contextdata tabs to HTML report by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/260](https://togithub.com/takahirom/roborazzi/pull/260)
- Fix Roborazzi output cache by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/262](https://togithub.com/takahirom/roborazzi/pull/262)

##### New Contributors

- [@&#8203;sanao1006](https://togithub.com/sanao1006) made their first
contribution in
[https://github.com/takahirom/roborazzi/pull/248](https://togithub.com/takahirom/roborazzi/pull/248)

**Full Changelog**:
takahirom/roborazzi@1.9.0...1.10.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xOTguMCIsInVwZGF0ZWRJblZlciI6IjM3LjE5OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrating from the org.json Library to Gson
2 participants