<style> .reveal, .reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 { font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, "Microsoft JhengHei", Meiryo, sans-serif; } h1, h2, h3, h4, h5, h6 { text-transform: none !important; } .color-yellow{ color: yellow; } .alert { padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px; text-align: left; padding: 10px 0; } .alert-info { color: #31708f; background-color: #d9edf7; border-color: #bce8f1; } .alert-success { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6; } .alert-danger { color: #a94442; background-color: #f2dede; border-color: #ebccd1; } .reveal .slides span { text-align: left; display: inline-block; } p, li { font-size: 0.88em !important; } li>p { font-size: 1em !important; } </style> # julia-formatを<br>整えた話と質問 [堀川 由人, ほりたみゅ, @Hyrodium](https://hyrodium.github.io/ja) ---- ### おしながき * 自己紹介 * JuliaFormatter.jl * julia-format * まとめ --- ### 自己紹介 * [GitHub](https://github.com/hyrodium) * [Bluesky](https://bsky.app/profile/hyrodium.bsky.social) Julia言語が好き --- ### JuliaFormatter.jl Juliaのソースコードを整形してくれるパッケージ ```julia for i = [1,2,3] i+.5 end ``` を ```julia for i in [1,2,3] i + 0.5 end ``` に置き換えてくれる ---- #### 4つの実行方法 * Juliaパッケージとして直接実行 * `using JuliaFormatter; format(".")` * エディタの機能として実行 * vscodeでは拡張機能に特定のJuliaFormatterのバージョンが紐づく * JuliaFormatter.jlのバージョンを自由に変更できない * pre-commitで実行 * commit前にフォーマットチェック * GitHub Actionsで実行 * PRがformatを満たしているかチェック * 定期的にformatするPRを自動発行 ところで、[公式ドキュメント](https://domluna.github.io/JuliaFormatter.jl/dev/)分かりにくくないですか? ---- #### 4つの実行方法 * Juliaパッケージとして直接実行 * `using JuliaFormatter; format(".")` * エディタの機能として実行 * vscodeでは拡張機能に特定のJuliaFormatterのバージョンが紐づく * JuliaFormatter.jlのバージョンを自由に変更できない * pre-commitで実行 * commit前にフォーマットチェック * GitHub Actionsで実行 * **PRがformatを満たしているかチェック** * 定期的にformatするPRを自動発行 今回の話題が**これ** --- ### julia-format [julia-format](https://github.com/julia-actions/julia-format): PRがフォーマットを満たしているかチェックするaction ```yaml name: Format suggestions on: pull_request: jobs: code-style: runs-on: ubuntu-latest steps: - uses: julia-actions/julia-format@v2 ``` を`.github/workflows/Format.yml`として保存するだけでOK ---- #### actionとは? `.github/workflows/*.yml`のファイルで ```yaml # (略) steps: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.julia-version }} arch: ${{ matrix.julia-arch }} - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 ``` のように`uses`で指定しているやつ * `username/reponame@ver`の形式 * Marketplaceにもリリースされる ([例](https://github.com/marketplace/actions/format-suggestion-with-juliaformatter-jl)) ---- #### 何を整えたのか? **全部!** * 以前のjulia-formatはactionを提供していなかった * 以下がごちゃまぜ状態 * julia-formatを使わない設定例 * PRのフォーマットをチェック * PRを定期的に作成してフォーマット * julia-formatを使う例 * 昔はあった * 非推奨になり * ドキュメントからも削除 * [複合アクション](https://docs.github.com/ja/actions/creating-actions/creating-a-composite-action)として`action.yml`を整備しました ---- #### How it works [AsteroidThermoPhysicalModels.jlでの動作例](https://github.com/Astroshaper/AsteroidThermoPhysicalModels.jl/pull/87) ---- #### 質問 * バージョニングって手動でするの? * [julia-actions/setup-juliaの例](https://github.com/julia-actions/setup-julia/tags) * [actions/checkoutの例](https://github.com/actions/checkout/tags) * [関連slackスレッド](https://julialang.slack.com/archives/CPWJ5DGG1/p1701186870853279) * reviewdogがforkからのPRで動作しない件 * 関連issue: [reviewdog/action-suggester/issues#19](https://github.com/reviewdog/action-suggester/issues/19) * action自体のテストって何を書けば良い? * (他のactionを参考にするべき、まだ見れてない) --- ### まとめ * actionを自分で作るのは意外と簡単! * action整備したので使ってください!
{"title":"JuliaTokai #17 (2023/12/10)","breaks":true,"lang":"ja","dir":"ltr","robots":"noindex, nofollow","slideOptions":"{\"theme\":\"white\",\"transition\":\"slide\"}","description":"堀川 由人, ほりたみゅ, @Hyrodium","contributors":"[{\"id\":\"41421433-16a1-4a57-ac11-6f7b7becb765\",\"add\":4205,\"del\":127}]"}
    371 views