エリクシール・フェニックス
導入
こんにちは、私はエリクサーとフェニックスで新しいです.私は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
defp deps do
[
..., # existing dependencies
{:excoveralls, "~> 0.10", only: :test},
]
end
{
"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
.もっと学ぶ
View on GitHub
ありがとう
この記事を読んでくれてありがとう.この記事を改善するためのコメントがあれば、ここでコメントしてください.
からのイメージ
Reference
この問題について(エリクシール・フェニックス), 我々は、より多くの情報をここで見つけました https://dev.to/berviantoleo/coverage-report-for-elixir-phoenix-92pテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol