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

マルチモジュール化をrelease/v0.1.0-beta.10にマージ #196

Merged
merged 45 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d085680
update: マルチモジュール化: srcディレクトリをcore配下に移動
YuukiToriyama Feb 25, 2024
3ccd2ee
add: マルチモジュール化: ワークスペース全体を設定するCargo.tomlを追加
YuukiToriyama Feb 25, 2024
59ddad0
add: マルチモジュール化: 結合試験モジュールが認識されなくなったので`tests`にCargo.tomlを追加
YuukiToriyama Feb 25, 2024
93b9ce0
update: マルチモジュール化: testsクレートで必要な依存関係を記載
YuukiToriyama Feb 25, 2024
2a24f3d
update: マルチモジュール化: テストデータのファイルパスを修正
YuukiToriyama Feb 25, 2024
17b478e
update: マルチモジュール化: `package.version`,`package.edition`,`package.autho…
YuukiToriyama Feb 25, 2024
9bbd17c
update: マルチモジュール化: `core/Cargo.toml`におけるexcludeの設定が不要になったため削除
YuukiToriyama Feb 25, 2024
5f0821e
update: マルチモジュール化: workspace.resolverに`2`を設定
YuukiToriyama Feb 25, 2024
07b1ede
fix: ワークスペースの導入: `wasm-pack build` `wasm-pack test`の実行前に`core`に入るステップを追加
YuukiToriyama Feb 26, 2024
d7ad724
fix: ワークスペースの導入: `wasm-pack build`の実行前にcoreディレクトリに入るように変更
YuukiToriyama Feb 26, 2024
d2f74eb
fix: ワークスペースの導入: `wasm-pack test`の実行前にcoreディレクトリに入るように変更
YuukiToriyama Feb 26, 2024
2cc57d0
Merge pull request #177 from YuukiToriyama/feature/cargo-workspace/co…
YuukiToriyama Feb 26, 2024
dec0afe
update: ワークスペースの導入: `description`, `repository`, `license`, `keywords…
YuukiToriyama Feb 26, 2024
8da8431
add: ワークスペースの導入: `wasm`モジュールを作成
YuukiToriyama Feb 28, 2024
352a16e
update: ワークスペースの導入: `wasm-bindgen*`クレートのバージョン管理をルートのCargo.tomlでするように変更
YuukiToriyama Feb 26, 2024
421957e
update: ワークスペースの導入: testモジュールでの`japanese_address_parser::Parser`の使用箇所…
YuukiToriyama Feb 28, 2024
5650ba9
update: ワークスペースの導入: coreモジュールでの`japanese_address_parser::Parser`の使用箇所を削除
YuukiToriyama Feb 28, 2024
ae82bc4
Merge pull request #179 from YuukiToriyama/feature/cargo-workspace/re…
YuukiToriyama Feb 28, 2024
e99a1ec
Merge branch 'main' into feature/cargo-workspace/merge/main_f145995
YuukiToriyama Mar 2, 2024
78edd92
Merge pull request #189 from YuukiToriyama/feature/cargo-workspace/me…
YuukiToriyama Mar 2, 2024
fd17b74
update: ワークスペースの導入: `update-cratesio.yaml`のジョブのworking-directoryを`cor…
YuukiToriyama Mar 5, 2024
d3ce437
update: ワークスペースの導入: `wasm-pack-test.yaml`のジョブに`working-directory`の設定を追加
YuukiToriyama Mar 5, 2024
83e3a2d
update: ワークスペースの導入: `ghpages.yaml`のジョブに`working-directory`の設定を追加
YuukiToriyama Mar 5, 2024
c9c9b6d
update: ワークスペースの導入: `upload-npmjs.yaml`のジョブに`working-directory`の設定を追加
YuukiToriyama Mar 5, 2024
00f375b
update: ワークスペースの導入: coreモジュールに定義していた`Parser`をwasmモジュールに移動
YuukiToriyama Mar 6, 2024
eea1d0b
update: ワークスペースの導入: `wasm-pack`ジョブのworking-directoryを変更
YuukiToriyama Mar 6, 2024
bcb3ff3
update: ワークスペースの導入: LICENSEファイルを`wasm`にコピー
YuukiToriyama Mar 6, 2024
4d0d3c1
update: ワークスペースの導入: `ghpages.yaml`を修正
YuukiToriyama Mar 6, 2024
b404037
update: ワークスペースの導入: `free-test.yaml`の修正
YuukiToriyama Mar 6, 2024
024d071
Merge pull request #190 from YuukiToriyama/feature/cargo-workspace/fi…
YuukiToriyama Mar 6, 2024
e6bf091
update: ワークスペースの導入: `core`にLICENSEファイルを追加
YuukiToriyama Mar 6, 2024
2d97696
update: ワークスペースの導入: `core`のCargo.tomlに`package.readme`の設定を追加
YuukiToriyama Mar 6, 2024
a7d9a62
Merge pull request #191 from YuukiToriyama/feature/cargo-workspace/co…
YuukiToriyama Mar 6, 2024
82b4a10
update: ワークスペースの導入: `wasm`のCargo.tomlに`package.readme`の設定を追加
YuukiToriyama Mar 6, 2024
f6ad773
update: ワークスペースの導入: `upload-npmjs.yaml`が正しく動作するように修正
YuukiToriyama Mar 22, 2024
2755897
survey: ワークスペースの導入: `upload-npmjs.yaml`の動作確認用コミット
YuukiToriyama Mar 22, 2024
a4eace3
Revert "survey: ワークスペースの導入: `upload-npmjs.yaml`の動作確認用コミット"
YuukiToriyama Mar 22, 2024
3750dec
update: ワークスペースの導入: `ghpages.yaml`が適切に動くように修正
YuukiToriyama Mar 22, 2024
0fa5b23
survey: ワークスペースの導入: `ghpages.yaml`の動作確認用コミット
YuukiToriyama Mar 22, 2024
1eaab9b
Revert "survey: ワークスペースの導入: `ghpages.yaml`の動作確認用コミット"
YuukiToriyama Mar 22, 2024
fa9d836
update: ワークスペースの導入: `core/Cargo.toml`から`wasm-bindgen`及び`wasm-bindgen-…
YuukiToriyama Mar 22, 2024
5f5b18c
Merge pull request #194 from YuukiToriyama/feature/cargo-workspace/wa…
YuukiToriyama Mar 22, 2024
ba275ab
Merge branch 'main' into feature/cargo-workspace/merge/main_005bbc2
YuukiToriyama Mar 22, 2024
18006b2
Merge pull request #195 from YuukiToriyama/feature/cargo-workspace/me…
YuukiToriyama Mar 22, 2024
82a81b7
Merge branch 'release/v0.1.0-beta.10' into feature/cargo-workspace/ma…
YuukiToriyama Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/free_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {Parser} = require("../../pkg");
const {Parser} = require("../../wasm/pkg");
const readline = require("readline");
const fs = require("fs");

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/free-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ jobs:
return commit.data.object.sha

- name: Install wasm-pack
working-directory: wasm
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build wasm module
working-directory: wasm
run: wasm-pack build --target nodejs --scope toriyama

- name: Setup Node.js
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/ghpages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ jobs:
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Unit Testing for Wasm module
working-directory: wasm
run: wasm-pack test --firefox --headless
- name: Build wasm module
run: wasm-pack build --target web --scope toriyama --features debug
working-directory: wasm
run: wasm-pack build --target web --scope toriyama --out-name japanese_address_parser --features debug
- name: Move files
run: |
mkdir ./publish
rm ./pkg/.gitignore
mv ./pkg ./publish
rm ./wasm/pkg/.gitignore
mv ./wasm/pkg ./publish
mv ./public ./publish
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/upload-cratesio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: core
steps:
- uses: actions/checkout@v4

Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/upload-npmjs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: wasm
steps:
- uses: actions/checkout@v4

Expand All @@ -22,7 +25,24 @@ jobs:
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm module
run: wasm-pack build --release --target web --scope toriyama
run: wasm-pack build --release --target web --scope toriyama --out-name japanese_address_parser

# package.jsonの`name`が`@toriyama/wasm`になっているため、`@toriyama/japanese-address-parser`に書き換える
- name: Check if jq command is available
run: |
which jq
jq --version

- name: Edit package.name
run: |
cat pkg/package.json | jq '.name = "@toriyama/japanese-address-parser"' > tmp.json
mv tmp.json pkg/package.json

- name: Check if package.name was changed
run: |
# package.nameが正しく置換されているかを確認している。
# 正しく置換されていればJSONファイルを表示し、置換されていなければエラーを返しJobを中断させる。
cat pkg/package.json | jq 'if .name == "@toriyama/japanese-address-parser" then . else error("package.nameが正しく置換されていない") end'

- name: Upload wasm to npmjs.com
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/wasm-pack-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
jobs:
wasm-pack:
runs-on: ubuntu-latest
defaults:
run:
working-directory: wasm
steps:
- uses: actions/checkout@v4
- name: Install wasm-pack
Expand Down
39 changes: 11 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
[package]
name = "japanese-address-parser"
[workspace]
members = [
"core",
"wasm",
"tests"
]
resolver = "2"

[workspace.package]
version = "0.1.0-beta.10"
edition = "2021"
description = "A Rust Library to parse japanses addresses."
authors = ["Yuuki Toriyama <[email protected]>"]
repository = "https://github.com/YuukiToriyama/japanese-address-parser"
authors = ["Yuuki Toriyama <[email protected]>"]
license = "MIT"
keywords = ["parser", "geo", "wasm"]
categories = ["parser-implementations", "wasm"]
exclude = [
"public/*",
"tests/*",
".github/*",
]

[lib]
crate-type = ["rlib", "cdylib"]

[features]
debug = []

[dependencies]
console_error_panic_hook = "0.1.7"
itertools = "0.12.0"
js-sys = "0.3.67"
nom = "7.1.3"
regex = "1.10.2"
reqwest = { version = "0.11.23", default-features = false, features = ["json", "rustls-tls", "blocking"] }
serde = { version = "1.0.192", features = ["derive"] }
serde-wasm-bindgen = "0.6.1"
[workspace.dependencies]
wasm-bindgen = "0.2.89"
wasm-bindgen-futures = "0.4.39"

[dev-dependencies]
csv = "1.3.0"
test-case = "3.3.1"
tokio = { version = "1.35.1", features = ["rt", "macros"] }
wasm-bindgen-test = "0.3.38"
27 changes: 27 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "japanese-address-parser"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
authors.workspace = true
license.workspace = true
readme = "../README.md"
keywords.workspace = true
categories.workspace = true

[lib]
crate-type = ["rlib", "cdylib"]

[dependencies]
itertools = "0.12.0"
js-sys = "0.3.67"
nom = "7.1.3"
regex = "1.10.2"
reqwest = { version = "0.11.23", default-features = false, features = ["json", "rustls-tls", "blocking"] }
serde = { version = "1.0.192", features = ["derive"] }

[dev-dependencies]
test-case = "3.3.1"
tokio = { version = "1.35.1", features = ["rt", "macros"] }
wasm-bindgen-test = { workspace = true }
21 changes: 21 additions & 0 deletions core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 ToriChan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod api;
pub mod entity;
mod err;
pub mod parser;
mod util;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "tests"
version.workspace = true
edition.workspace = true
authors.workspace = true
publish = false

[[test]]
name = "integration_tests"
path = "integration_tests.rs"

[dev-dependencies]
csv = "1.3.0"
japanese-address-parser = { path = "../core"}
serde = { version = "1.0.197", features = ["derive"] }
tokio = { version = "1.35.1", features = ["rt", "macros"] }
4 changes: 2 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use csv::ReaderBuilder;
use japanese_address_parser::api::{Api, ApiImpl};
use japanese_address_parser::parser;
use japanese_address_parser::parser::parse;
use serde::Deserialize;
use std::fs::File;
use std::panic;
Expand Down Expand Up @@ -30,7 +30,7 @@ pub async fn run_data_driven_tests(file_path: &str) {
let mut success_count = 0;
for record in &records {
let api = ApiImpl::new();
let result = parser::parse(api, &record.address).await;
let result = parse(api, &record.address).await;

let test_result = panic::catch_unwind(|| {
assert_eq!(result.address.prefecture, record.prefecture);
Expand Down
16 changes: 7 additions & 9 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,31 @@ mod common;
#[tokio::test]
#[ignore]
async fn 県庁所在地のデータテスト() {
run_data_driven_tests("./tests/test_data/県庁所在地の住所データ.csv").await
run_data_driven_tests("./test_data/県庁所在地の住所データ.csv").await
}

#[tokio::test]
async fn 市区町村名レベルでの表記ゆれ() {
run_data_driven_tests("./tests/test_data/市区町村名レベルでの表記ゆれ.csv").await
run_data_driven_tests("./test_data/市区町村名レベルでの表記ゆれ.csv").await
}

#[tokio::test]
async fn 異字体旧字体への対応テスト() {
run_data_driven_tests("./tests/test_data/異字体旧字体への対応.csv").await
run_data_driven_tests("./test_data/異字体旧字体への対応.csv").await
}

#[tokio::test]
async fn 丁目が算用数字の場合への対応テスト() {
run_data_driven_tests("./tests/test_data/丁目が算用数字の場合への対応.csv").await
run_data_driven_tests("./test_data/丁目が算用数字の場合への対応.csv").await
}

#[tokio::test]
async fn 住居表示実施済みの住所において正式でない表記への対応テスト() {
run_data_driven_tests(
"./tests/test_data/住居表示実施済みの住所において正式でない表記への対応.csv",
)
.await
run_data_driven_tests("./test_data/住居表示実施済みの住所において正式でない表記への対応.csv")
.await
}

#[tokio::test]
async fn 大字表記省略への対応テスト() {
run_data_driven_tests("./tests/test_data/大字表記省略への対応.csv").await
run_data_driven_tests("./test_data/大字表記省略への対応.csv").await
}
24 changes: 24 additions & 0 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "wasm"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
authors.workspace = true
license.workspace = true
readme = "../README.md"
keywords.workspace = true
categories.workspace = true

[lib]
crate-type = ["cdylib"]

[features]
debug = []

[dependencies]
console_error_panic_hook = "0.1.7"
japanese-address-parser = { path = "../core" }
serde-wasm-bindgen = "0.6.1"
wasm-bindgen = { workspace = true }
wasm-bindgen-futures = { workspace = true }
21 changes: 21 additions & 0 deletions wasm/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 ToriChan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 2 additions & 7 deletions src/lib.rs → wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
use crate::api::{Api, ApiImpl};
use japanese_address_parser::api::{Api, ApiImpl};
use japanese_address_parser::parser;
use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::JsValue;

pub mod api;
pub mod entity;
mod err;
pub mod parser;
mod util;

#[wasm_bindgen(typescript_custom_section)]
const TYPESCRIPT_TYPE: &'static str = r#"
export interface ParseResult {
Expand Down Expand Up @@ -40,7 +35,7 @@
#[wasm_bindgen]
impl Parser {
#[wasm_bindgen(constructor)]
pub fn new() -> Self {

Check warning on line 38 in wasm/src/lib.rs

View workflow job for this annotation

GitHub Actions / build

[clippy] reported by reviewdog 🐶 <pre><code>warning: you should consider adding a `Default` implementation for `Parser` --> wasm/src/lib.rs:38:5 | 38 | / pub fn new() -> Self { 39 | | Parser {} 40 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default = note: `#[warn(clippy::new_without_default)]` on by default help: try adding this | 36 + impl Default for Parser { 37 + fn default() -> Self { 38 + Self::new() 39 + } 40 + } | </code></pre> Raw Output: wasm/src/lib.rs:38:5:w: <pre><code>warning: you should consider adding a `Default` implementation for `Parser` --> wasm/src/lib.rs:38:5 | 38 | / pub fn new() -> Self { 39 | | Parser {} 40 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default = note: `#[warn(clippy::new_without_default)]` on by default help: try adding this | 36 + impl Default for Parser { 37 + fn default() -> Self { 38 + Self::new() 39 + } 40 + } | </code></pre> __END__
Parser {}
}

Expand Down
Loading