### Drone CI Configuration for ExCoveralls Source: https://github.com/parroty/excoveralls/blob/master/README.md Example configuration for .drone.yml to integrate ExCoveralls for code coverage reporting. ```yaml kind: pipeline name: default steps: - name: build image: elixir:1.10 commands: - mix test --cover - mix coveralls.drone ``` -------------------------------- ### GitHub Actions Configuration for ExCoveralls Source: https://github.com/parroty/excoveralls/blob/master/README.md Example configuration for GitHub Actions workflow (.github/workflows/example.yml) to integrate ExCoveralls. ```yaml name: Elixir CI on: push: [main] pull_request: jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: erlef/setup-elixir@v1 with: version: '1.10.4' - name: Install Dependencies run: mix deps.get - name: Run Tests and Upload Coverage env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} run: | mix test --cover mix coveralls.github ``` -------------------------------- ### Travis CI Configuration for ExCoveralls Source: https://github.com/parroty/excoveralls/blob/master/README.md Example configuration for .travis.yml to integrate ExCoveralls for code coverage reporting. ```yaml language: elixir elixir: - 1.10.4 script: - mix test --cover - mix coveralls.travis ``` -------------------------------- ### Configure Travis CI for Coverage Source: https://github.com/parroty/excoveralls/blob/master/README.md Example configuration for a `.travis.yml` file to automatically run excoveralls and submit coverage reports when builds are executed on Travis CI. Ensures the correct environment variables and script commands are set. ```YAML language: elixir elixir: - 1.2.0 otp_release: - 18.0 env: - MIX_ENV=test script: mix coveralls.travis ``` -------------------------------- ### Configuring HTTP Options in ExCoveralls Source: https://github.com/parroty/excoveralls/blob/master/README.md Shows how to customize HTTP options for ExCoveralls when posting results. This Elixir configuration example sets a custom cacertfile for SSL verification, overriding default behavior. ```elixir config :excoveralls, http_options: [ timeout: 10_000, ssl: [ # Refer to the secure coding guide: # https://erlef.github.io/security-wg/secure_coding_and_deployment_hardening/inets verify: :verify_peer, depth: 2, customize_hostname_check: match_fun: :public_key.pkix_verify_hostname_match_fun(:https) , cacertfile: to_charlist(System.fetch_env!("TEST_COVERAGE_CACERTFILE")) ] ] ``` -------------------------------- ### Post Coverage from Any Host Source: https://github.com/parroty/excoveralls/blob/master/README.md Submits coverage reports to Coveralls.io from any host using the `mix coveralls.post` command. Supports specifying token, branch, committer, SHA, and message via options or environment variables. ```shell MIX_ENV=test mix coveralls.post --token "[YOUR_TOKEN]" --branch "master" --name "local host" --committer "committer name" --sha "fd80a4c" --message "commit message" ``` ```shell # Example output: # Successfully uploaded the report to 'https://coveralls.io'. ``` -------------------------------- ### Post Coverage to Coveralls via Semaphore Source: https://github.com/parroty/excoveralls/blob/master/README.md Instructions for using Excoveralls with Semaphore CI to post coverage reports. The COVERALLS_REPO_TOKEN environment variable must be configured. ```shell mix coveralls.semaphore ``` -------------------------------- ### Excoveralls Configuration (coveralls.json) Source: https://github.com/parroty/excoveralls/blob/master/README.md Configuration file for Excoveralls. Custom files can be placed in the project root, overriding default settings. Key options include 'output_dir' for report paths and 'template_path' for custom HTML templates. ```JSON { "output_dir": "custom/path/to/reports", "template_path": "path/to/custom/templates", "print_summary": false } ``` -------------------------------- ### Post Coverage to Coveralls via CircleCI Source: https://github.com/parroty/excoveralls/blob/master/README.md Sets up a CircleCI build to submit code coverage reports to Coveralls.io. Requires the COVERALLS_REPO_TOKEN environment variable to be set. ```yaml test: override: - mix coveralls.circle ``` -------------------------------- ### Merging Coverage Results with ExCoveralls Source: https://github.com/parroty/excoveralls/blob/master/README.md Demonstrates how to generate and merge coverage data using ExCoveralls. The `--export-coverage` flag saves data, and `--import-cover` includes it in subsequent reports, useful for partitioned or subprocess tests. ```shell $ mix test --only integration --cover --export-coverage integration-coverage Excluding tags: [:test] Including tags: [:integration] ... test run omitted ... # Coverage data written to cover/integration-coverage.coverdata # Report coverage, do not run integration tests $ mix coveralls --exclude integration Excluding tags: [:integration] ... test run omitted ... ---------------- COV FILE LINES RELEVANT MISSED ... [TOTAL] 80.2% # <-- This result does not include coverage from integration tests ---------------- # Report coverage, do not run integration tests, but include previously written coverdata $ mix coveralls --exclude integration --import-cover cover Excluding tags: [:integration] ... test run omitted ... ---------------- COV FILE LINES RELEVANT MISSED ... [TOTAL] 95.3% # <-- This result now includes coverage from integration tests ---------------- ``` -------------------------------- ### Generate XML Coverage Report (mix coveralls.xml) Source: https://github.com/parroty/excoveralls/blob/master/README.md Displays coverage information at the source-code level formatted as an XML document, compatible with services like SonarQube. Reports are written to cover/excoveralls.xml by default, with the path customizable via the 'output_dir' option in coveralls.json. ```Shell $ MIX_ENV=test mix coveralls.xml ``` -------------------------------- ### Configure ExCoveralls in mix.exs Source: https://github.com/parroty/excoveralls/blob/master/README.md Demonstrates how to configure ExCoveralls within the `mix.exs` file for an Elixir project. This includes setting the coverage tool, preferred CLI environments for tasks, and dependencies. It also shows optional settings for exporting coverage data and using alternative test tasks like Espec. ```elixir def project do [ app: :excoveralls, version: "1.0.0", elixir: "~> 1.0.0", deps: deps(), test_coverage: [tool: ExCoveralls], preferred_cli_env: [ coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test, "coveralls.cobertura": :test ] # if you want to use espec, # test_coverage: [tool: ExCoveralls, test_task: "espec"] ] end defp deps do [ {:excoveralls, "~> 0.18", only: :test}, ] end ``` -------------------------------- ### Coveralls.json Configuration Source: https://github.com/parroty/excoveralls/blob/master/README.md Configuration options for ExCoveralls, typically specified in a coveralls.json file. ```json { "stop_words": [ "_build", "deps" ], "exclude_files": [ "lib/my_app/repo.ex", "test/**/*.ex" ], "coverage_options": { "ignore_lines": [ "# LCOV_EXCL_LINE", "# LCOV_EXCL_START", "# LCOV_EXCL_STOP" ] } } ``` -------------------------------- ### Generate HTML Coverage Report (mix coveralls.html) Source: https://github.com/parroty/excoveralls/blob/master/README.md Displays coverage information at the source-code level formatted as an HTML page, inspired by HTMLCov. Output can be filtered using the --filter flag. Reports are written to cover/excoveralls.html by default, but the path can be customized via the 'output_dir' option in coveralls.json. Custom templates can be provided via 'template_path'. ```Shell $ MIX_ENV=test mix coveralls.html ``` -------------------------------- ### Generate Cobertura Coverage Report (mix coveralls.cobertura) Source: https://github.com/parroty/excoveralls/blob/master/README.md Displays coverage information at the source-code level formatted as a Cobertura document, compatible with Gitlab CI's code coverage visualization. Reports are written to cover/cobertura.xml by default, with the path customizable via the 'output_dir' option in coveralls.json. ```Shell $ MIX_ENV=test mix coveralls.cobertura ``` -------------------------------- ### Generate JSON Coverage Report (mix coveralls.json) Source: https://github.com/parroty/excoveralls/blob/master/README.md Displays coverage information at the source-code level formatted as a JSON document, compatible with services like Codecov and Code Climate. Reports are written to cover/excoveralls.json by default, with customizable paths via 'output_dir' and filenames via the 'export' option in mix.exs. ```Shell $ MIX_ENV=test mix coveralls.json ``` -------------------------------- ### Show Coverage with Detail Source: https://github.com/parroty/excoveralls/blob/master/README.md Displays detailed, source-code level coverage information with colored output (green for tested, red for missed lines). Can be piped to 'less -R' for pagination and filtered by file name. ```shell $ MIX_ENV=test mix coveralls.detail | less -R ``` ```shell # Example output snippet: # COV FILE LINES RELEVANT MISSED # 100.0% lib/excoveralls/general.ex 28 4 0 # [TOTAL] 94.4% ``` ```shell $ MIX_ENV=test mix coveralls.detail --filter general.ex ``` -------------------------------- ### Post Coverage to Coveralls via Drone Source: https://github.com/parroty/excoveralls/blob/master/README.md Configures a Drone CI pipeline to post coverage results to Coveralls.io. Requires the coveralls_repo_token secret to be added to the Drone project. ```yaml pipeline: build: secrets: [ coveralls_repo_token ] commands: - mix coveralls.drone ``` -------------------------------- ### Generate Lcov Coverage Report (mix coveralls.lcov) Source: https://github.com/parroty/excoveralls/blob/master/README.md Displays coverage information at the line level formatted as an lcov document, compatible with VSCode extensions like 'ryanluker.vscode-coverage-gutters'. Reports are written to cover/lcov.info by default, with the path customizable via the 'output_dir' option in coveralls.json. ```Shell $ MIX_ENV=test mix coveralls.lcov ``` -------------------------------- ### Post Coverage to Coveralls via GitHub Actions Source: https://github.com/parroty/excoveralls/blob/master/README.md Configures a GitHub Actions workflow to post code coverage results to Coveralls.io. It requires setting the MIX_ENV to 'test' and providing the GITHUB_TOKEN for authentication. ```yaml on: push jobs: test: runs-on: ubuntu-latest name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: matrix: otp: [21.3.8.10, 22.1.7] elixir: [1.8.2, 1.9.4] env: MIX_ENV: test GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v1.0.0 - uses: erlef/setup-beam@v1 with: otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} - run: mix deps.get - run: mix coveralls.github ``` -------------------------------- ### Configure Coverage Options and Stop Words (JavaScript) Source: https://github.com/parroty/excoveralls/blob/master/README.md Define various coverage behaviors and stop words in `coveralls.json`. Options include `treat_no_relevant_lines_as_covered`, `output_dir`, `minimum_coverage`, and `html_filter_full_covered`. `default_stop_words` allows regex patterns for exclusion. ```javascript { "default_stop_words": [ "defmodule", "defrecord", "defimpl", "def.+(.+\/\/.+).+do" ], "coverage_options": { "treat_no_relevant_lines_as_covered": true, "output_dir": "cover/", "template_path": "custom/path/to/template/", "minimum_coverage": 90, "xml_base_dir": "custom/path/for/xml/reports/", "html_filter_full_covered": true } } ``` -------------------------------- ### Show Local Coverage Report Source: https://github.com/parroty/excoveralls/blob/master/README.md Executes the excoveralls mix task to display code coverage information directly in the terminal. This command runs tests and generates a local report without submitting data to Coveralls.io. ```Shell $ MIX_ENV=test mix coveralls ... ---------------- COV FILE LINES RELEVANT MISSED 100.0% lib/excoveralls/general.ex 28 4 0 75.0% lib/excoveralls.ex 54 8 2 94.7% lib/excoveralls/stats.ex 70 19 1 100.0% lib/excoveralls/poster.ex 16 3 0 95.5% lib/excoveralls/local.ex 79 22 1 100.0% lib/excoveralls/travis.ex 23 3 0 100.0% lib/mix/tasks.ex 44 8 0 100.0% lib/excoveralls/cover.ex 32 5 0 [TOTAL] 94.4% ---------------- ``` -------------------------------- ### ExCoveralls Mix Tasks Source: https://github.com/parroty/excoveralls/blob/master/README.md ExCoveralls provides several mix tasks to manage code coverage reporting. These tasks allow users to show coverage, post reports to various CI/CD platforms, and generate reports in different formats. ```elixir mix coveralls # Shows coverage report in the terminal. mix coveralls.travis # Posts coverage report to Coveralls.io for Travis CI. mix coveralls.github # Posts coverage report to Coveralls.io for GitHub Actions. mix coveralls.circle # Posts coverage report to Coveralls.io for Circle CI. mix coveralls.semaphore # Posts coverage report to Coveralls.io for Semaphore CI. mix coveralls.drone # Posts coverage report to Coveralls.io for Drone CI. mix coveralls.post # Posts coverage report to Coveralls.io from any host. mix coveralls.detail # Shows coverage report with detailed information. mix coveralls.html # Generates coverage report as an HTML file. mix coveralls.json # Generates coverage report as a JSON file. mix coveralls.xml # Generates coverage report as an XML file. mix coveralls.cobertura # Generates coverage report in Cobertura XML format. mix coveralls.lcov # Generates coverage report in lcov format (Experimental). ``` -------------------------------- ### Configure File Exclusion in coveralls.json (JavaScript) Source: https://github.com/parroty/excoveralls/blob/master/README.md Specify files or directories to exclude from coverage calculations by adding the `skip_files` key to your `coveralls.json`. Paths should be strings compatible with Elixir's Regex.compile. This is useful for ignoring specific modules or test files. ```javascript { "skip_files": [ "folder_to_skip", "folder/file_to_skip.ex" ] } ``` -------------------------------- ### Silence OTP Cover Warnings (Erlang/Elixir) Source: https://github.com/parroty/excoveralls/blob/master/README.md To reduce noise from OTP's cover tool, you can modify the `cover.erl` file. Removing specific lines can suppress 'Module already imported' warnings, and replacing the `imported_info` function can hide imported module information. ```erlang % To remove 'Module already imported' warnings, remove these lines: % https://github.com/erlang/otp/blob/131398b54cca5f1ae95ed268274936d2efde8c39/lib/tools/src/cover.erl#L1553-L1554 % To hide imported info, replace the function: % https://github.com/erlang/otp/blob/131398b54cca5f1ae95ed268274936d2efde8c39/lib/tools/src/cover.erl#L1520-L1525 imported_info(_Text,_Module,_Imported) -> ok. ``` -------------------------------- ### Customize Terminal Report Output (JavaScript) Source: https://github.com/parroty/excoveralls/blob/master/README.md Adjust the terminal report's appearance by configuring `terminal_options` in `coveralls.json`. You can set `file_column_width` for file name display or `print_files` to `false` to show only the total coverage. ```javascript { "terminal_options": { "file_column_width": 40 } } { "terminal_options": { "print_files": false } } ``` -------------------------------- ### Ignore Lines in Elixir Code Coverage (Elixir) Source: https://github.com/parroty/excoveralls/blob/master/README.md Use special comments within Elixir code to exclude specific lines or blocks from coverage calculations. `coveralls-ignore-start` and `coveralls-ignore-stop` ignore a block, while `coveralls-ignore-next-line` ignores only the subsequent line. ```elixir defmodule MyModule do def covered do end # coveralls-ignore-start def ignored do end # coveralls-ignore-stop end defmodule AnotherModule do def covered do # coveralls-ignore-next-line "ignored" "covered" end end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.