JuliaMathias / elixir-coverage-feedback-action

Action to run tests, check coverage, and send a feedback message to the pull request.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elixir coverage feedback comment

This action gets the output of mix test --cover, treats it, and creates a feedback message in the pull request of origin. It also checks if the coverage reaches the minimum configured in the action, and exits with an error if it doesn't.

By default, this action assumes that you are using Elixir's default coverage tool. However, it also supports ExCoveralls, and if you prefer it, simply add the coverage_tool configuration inside the with option that specifies it.

Additionally, this action supports setting a working_directory as an input if your Elixir project is not at the root of the repository.

image image

Example of a complete test workflow using the action

.github/workflows/test.yml

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  test:
    name: Tests & Checks
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    env:
      MIX_ENV: test

    services:
      db:
        image: postgres:15-alpine
        ports: ["5432:5432"]
        env:
          POSTGRES_DB: project_test
          POSTGRES_USER: project
          POSTGRES_PASSWORD: mycoolpassword

    steps:
      - uses: actions/checkout@v3

      - name: Setup Erlang and Elixir
        uses: erlef/setup-beam@v1.15.4
        with:
          elixir-version: "1.14.5-otp-26"
          otp-version: "26.0"

      - name: Mix and build cache
        uses: actions/cache@v3
        with:
          path: |
            deps
            _build
          key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
          restore-keys: ${{ runner.os }}-mix-

      - name: Get dependencies
        run: mix deps.get

      - name: Code analyzers
        run: |
          mix format --check-formatted
          mix compile --warnings-as-errors

      - name: Tests & Coverage
        uses: JuliaMathias/elixir-coverage-feedback-action@v0.5.4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          coverage_threshold: 80
          # working_directory: ./your_project_directory
          # coverage_tool: excoveralls

About

Action to run tests, check coverage, and send a feedback message to the pull request.

License:MIT License


Languages

Language:Elixir 52.3%Language:JavaScript 47.7%