3
1

More than 3 years have passed since last update.

はじめに

  • Elixir 楽しんでいますか :bangbang::bangbang::bangbang:
  • José Valim1さんのこんな書き込みがありました

I am glad we took http://earthly.dev for a spin on @elixirphoenix! I can now easily reproduce our CI runs locally. The long and unproductive cycle of debugging, committing, and waiting for CI is gone! 🎉 To learn more, here is our Earthfile:

Earthly

Earthly is a syntax for defining your build. It works with your existing build system. Get repeatable and understandable builds today.

integration2.png
(https://earthly.dev/)

  • なんだかよくわかっていませんがインストールして使ってみます
  • Earthfileというものを書くらしいです

インストール

  • Installationに従います
  • 予めDockerとGitが必要なのだそうです
    • いつインストールしたのか忘れましたがインストール済でした
  • 私はmacOS 10.15.7 を使いました
$ brew install earthly
$ earthly github.com/earthly/hello-world:main+hello
           buildkitd | Starting buildkit daemon as a docker container (earthly-buildkitd)...
           buildkitd | ...Done
      busybox:1.32.0 | --> Load metadata linux/amd64
g/e/hello-world:main+base | --> FROM busybox:1.32.0
g/e/hello-world:main+base | [          ] resolve docker.io/library/busybox:1.32.0@sha256:bde48e1751173b709090c2539fdf12d6ba64e88ec7a4301591227ce925f3c678 [██████████] resolve docker.io/library/busybox:1.32.0@sha256:bde48e1751173b709090c2539fdf12d6ba64e88ec7a4301591227ce925f3c678 ... 100%
g/e/hello-world:main+base | [██████████] sha256:ea97eb0eb3ec0bbe00d90be500431050af63c31dc0706c2e8fb53e16cff7761f ... 100%
g/e/hello-world:main+base | [          ] extracting sha256:ea97eb0eb3ec0bbe00d90be500431050af63c31dc0706c2e8fb53e16cff7761f ... 0%                        [██████████] extracting sha256:ea97eb0eb3ec0bbe00d90be500431050af63c31dc0706c2e8fb53e16cff7761f ... 100%
g/e/hello-world:main+hello | --> RUN echo 'Hello, world!'
g/e/hello-world:main+hello | Hello, world!
              output | --> exporting outputs
              output | [██████████] sending tarballs ... 100%
=========================== SUCCESS ===========================
FROM busybox:1.32.0

hello:
  RUN echo 'Hello, world!'

Phoenix

  • Elixirタグを付けたいので、Elixirに関係することをやってみます
  • Phoenixは、Webアプリケーションフレームワークです
$ earthly github.com/<アカウント or グループ>/<リポジトリ>:ブランチ+<target>

という並びだとおもったらばっちりそう2だったので、もう :rocket: EarthfileがあるPhoenixを指定してみます

$ earthly -P github.com/phoenixframework/phoenix:master+all  

g/p/phoenix:master+test *failed* |   1) test with 1.0.0 serializer Phoenix.Socket.V1.JSONSerializer sends phx_error if a channel server abnormally exits (Phoenix.Integration.LongPollChannelsTest)
g/p/phoenix:master+test *failed* |      test/phoenix/integration/long_poll_channels_test.exs:429
g/p/phoenix:master+test *failed* |      ** (MatchError) no match of right hand side value: []
g/p/phoenix:master+test *failed* |      code: [_phx_reply, _user_entered, _joined, chan_error] = resp.body["messages"]
g/p/phoenix:master+test *failed* |      stacktrace:
g/p/phoenix:master+test *failed* |        test/phoenix/integration/long_poll_channels_test.exs:446: (test)

g/p/phoenix:master+test *failed* |      The following output was logged:
g/p/phoenix:master+test *failed* |      
g/p/phoenix:master+test *failed* |      22:46:04.663 [info]  JOINED room:test with 1.0.0 serializer Phoenix.Socket.V1.JSONSerializer sends phx_error if a channel server abnormally exits in 44µs
g/p/phoenix:master+test *failed* |        Parameters: %{}
g/p/phoenix:master+test *failed* |      
g/p/phoenix:master+test *failed* |      22:46:04.815 [error] GenServer #PID<0.5361.0> terminating
g/p/phoenix:master+test *failed* |      ** (RuntimeError) boom
g/p/phoenix:master+test *failed* |          test/phoenix/integration/long_poll_channels_test.exs:46: Phoenix.Integration.LongPollChannelsTest.RoomChannel.handle_in/3
g/p/phoenix:master+test *failed* |          (phoenix 1.6.0-dev) lib/phoenix/channel/server.ex:315: Phoenix.Channel.Server.handle_info/2
g/p/phoenix:master+test *failed* |          (stdlib 3.8.2.4) gen_server.erl:637: :gen_server.try_dispatch/4
g/p/phoenix:master+test *failed* |          (stdlib 3.8.2.4) gen_server.erl:711: :gen_server.handle_msg/6
g/p/phoenix:master+test *failed* |          (stdlib 3.8.2.4) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
g/p/phoenix:master+test *failed* |      Last message: %Phoenix.Socket.Message{event: "boom", join_ref: nil, payload: %{}, ref: nil, topic: "room:test with 1.0.0 serializer Phoenix.Socket.V1.JSONSerializer sends phx_error if a channel server abnormally exits"}
g/p/phoenix:master+test *failed* |      State: %Phoenix.Socket{assigns: %{user_id: nil}, channel: Phoenix.Integration.LongPollChannelsTest.RoomChannel, channel_pid: #PID<0.5361.0>, endpoint: Phoenix.Integration.LongPollChannelsTest.Endpoint, handler: Phoenix.Integration.LongPollChannelsTest.UserSocket, id: nil, join_ref: "1", joined: true, private: %{log_handle_in: :info, log_join: :info}, pubsub_server: Phoenix.Integration.LongPollChannelsTest, ref: nil, serializer: Phoenix.Socket.V1.JSONSerializer, topic: "room:test with 1.0.0 serializer Phoenix.Socket.V1.JSONSerializer sends phx_error if a channel server abnormally exits", transport: :longpoll, transport_pid: #PID<0.5356.0>}
g/p/phoenix:master+test *failed* |      
g/p/phoenix:master+test *failed* | ....................................................................................................................

g/p/phoenix:master+test *failed* | Finished in 128.0 seconds
g/p/phoenix:master+test *failed* | 11 doctests, 737 tests, 1 failure

g/p/phoenix:master+test *failed* | Randomized with seed 43391
g/p/phoenix:master+test *failed* | Command /bin/sh -c 'mix test' failed with exit code 1
g/p/phoenix:master+test *failed* | g/p/phoenix:master+test *failed* | ERROR: Command exited with non-zero code: RUN mix test
  • failed... :sweat_smile:
  • -Pはつけないとエラーがでたのでつけました

--allow-privileged, -P Allow build to use the --privileged flag in RUN commands

Wrapping Up 🎍🎍🎍🎍🎍

  • 今回はインストールして、Earthfileがあるプロジェクトを指定して動かしてみました
  • また理解が進んだら記事を書きたいとおもいます
  • (Quick Tutorial: Build a Go App in EarthlyのElixir版を陽気に紹介したい)
  • Enjoy Elixir 🚀🚀🚀
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1