エリクシール・フェニックス



導入
こんにちは、私はエリクサーとフェニックスで新しいです.私はdevops側面とバックエンドの側面に興味があります.だから、私はカバレッジレポートと自動テストについての詳細を探る理由です.私はカバレッジレポートについて大きな選択肢を見つけました.
ExCoveralls
既存のフェニックスプロジェクトへのセットアップ
あなたはexcoverallsの設定セクションをチェックすることができます .それらの最新の設定を参照してください、この設定は後で古いかもしれません.
  • ミックスでプロジェクトに追加します.電通大
  • def project do
      [
        ..., # existing settings
        deps: deps(),
        test_coverage: [tool: ExCoveralls],
        preferred_cli_env: [
          coveralls: :test,
          "coveralls.detail": :test,
          "coveralls.post": :test,
          "coveralls.html": :test
        ]
        # if you want to use espec,
        # test_coverage: [tool: ExCoveralls, test_task: "espec"]
      ]
    end
    
  • ミックスでdepsにこれを追加します.exs
  • defp deps do
      [
        ..., # existing dependencies
        {:excoveralls, "~> 0.10", only: :test},
      ]
    end
    
  • 新しい名前ファイルを作成します.JSONプロジェクトにおけるJSONテストとDEPSフォルダを無視するこの設定はカバレッジエリアになります.
  • {
      "skip_files": [
        "test",
        "deps"
      ]
    }
    
    それが既にインストールされて、働くならば、
  • をテストするために.このコマンドを実行できます.
  • MIX_ENV=test mix coveralls
    
    here
    セットアップgithubアクション
    私は私のメインのCI/CDプラットフォームとしてgithubアクションを使用します.現在、この設定を使用します.
    name: Elixir CI
    on:
      push:
        branches: [ main ]
      pull_request:
        branches: [ main ]
    jobs:
      build:
        name: Build and test
        runs-on: ubuntu-20.04
        services:
          # Label used to access the service container
          postgres:
            # Docker Hub image
            image: postgres:13-alpine
            # Provide the password for postgres
            env:
              POSTGRES_PASSWORD: postgres
            # Set health checks to wait until postgres has started
            options: >-
              --health-cmd pg_isready
              --health-interval 10s
              --health-timeout 5s
              --health-retries 5
            ports:
              # Maps tcp port 5432 on service container to the host
              - 5432:5432
        steps:
        - uses: actions/checkout@v2
        - uses: erlef/setup-beam@v1
          with:
            otp-version: '22.2'
            elixir-version: '1.10'
        - name: Restore dependencies cache
          uses: actions/cache@v2
          with:
            path: deps
            key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
            restore-keys: ${{ runner.os }}-mix-
        - name: Install dependencies
          run: mix deps.get
        - name: Check Format
          run: mix format --check-formatted
        - name: Run tests
          run: mix coveralls.json
          env:
            MIX_ENV: test
        - name: Upload to Codecov
          run: |
            curl -Os https://uploader.codecov.io/latest/linux/codecov
            chmod +x codecov
            ./codecov
    
    この構成は、自動的にカバレッジ結果を に加えるでしょう.結果はこのようになります.
    Codecov
    注意:構成はパブリックリポジトリに対して動作します.プライベートリポジトリを使用する場合は、設定を変更してください.あなたは./codecovになる./codecov -t ${CODECOV_TOKEN}のラインを変更する必要があります.
    ここに私の例のアプリです.

    / berviantoleo
    エリキシルについてより探検してください
    理化学研究所
    elixir-exploration
    フェニックスサーバを起動するには
  • mix deps.getとの依存関係をインストールする
  • あなたのデータベースをmix ecto.setupで作成して、移行させます
  • でフェニックス終点を開始してください
  • 今すぐあなたのブラウザからを訪問することができます.
    生産で実行する準備ができました? mix phx.server .
    もっと学ぶ
  • の公式ウェブサイト:check our deployment guides
  • のガイド:https://www.phoenixframework.org/
  • の医者:https://hexdocs.pm/phoenix/overview.html
  • フォーラム:https://hexdocs.pm/phoenix
  • のソース:https://elixirforum.com/c/phoenix-forum
  • https://github.com/phoenixframework/phoenix
    View on GitHub
    ありがとう
    この記事を読んでくれてありがとう.この記事を改善するためのコメントがあれば、ここでコメントしてください.

    からのイメージ