Skip to content

Commit

Permalink
Work on test coverage reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
christhekeele committed Apr 14, 2024
1 parent 279c44a commit 96a22b5
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 4 deletions.
47 changes: 45 additions & 2 deletions .github/workflows/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: Test ❯ Matrix
# Runs tests and typechecking against the full battalion
# of supported OS, Erlang/OTP, and Elixir versions.

on:
# Allow running from GitHub UI.
workflow_dispatch: {}

# Run on all pull requests to important branches.
pull_request:
branches:
- latest
- release

# Run on all pushes to important branches.
push:
branches:
- release
- latest
- release

env:
MIX_ENV: test
Expand Down Expand Up @@ -418,8 +423,46 @@ jobs:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Restore mix dependency installation cache
id: mix-deps-get-cache
uses: actions/cache@v4
with:
path: |
deps
mix.lock
key: cache-${{ vars.CACHE_VERSION }}-os-${{ runner.os }}-${{ steps.beam-versions.outputs.otp-version }}-${{ steps.beam-versions.outputs.elixir-version }}-mix-deps-get-mix-exs-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.exs')) }}

- name: Install mix dependencies
if: steps.mix-deps-get-cache.outputs.cache-hit != 'true'
run: mix deps.get

- name: Restore mix dependency compilation cache
id: mix-deps-compile-cache
uses: actions/cache@v4
with:
path: _build
key: cache-${{ vars.CACHE_VERSION }}-os-${{ runner.os }}-${{ steps.beam-versions.outputs.otp-version }}-${{ steps.beam-versions.outputs.elixir-version }}-mix-deps-compile-mix-lock-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}

- name: Compile mix dependencies
if: steps.mix-deps-compile-cache.outputs.cache-hit != 'true'
run: mix deps.compile

- name: Restore mix typecheck cache
id: mix-typecheck-cache
uses: actions/cache@v4
with:
path: priv/plts
key: cache-${{ vars.CACHE_VERSION }}-os-${{ runner.os }}-${{ steps.beam-versions.outputs.otp-version }}-${{ steps.beam-versions.outputs.elixir-version }}-mix-typecheck

- name: Setup typechecking
if: steps.mix-typecheck-cache.outputs.cache-hit != 'true'
run: mix typecheck.build-cache

- name: Run typecheck tasks
run: mix typecheck

results:
name: Test Matrix Action Results
name: Test Matrix Results
runs-on: ubuntu-22.04

if: ${{ always() }}
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/test-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Test ❯ Status
# Runs tests with coverage and updates related systems.

on:
# Allow running from GitHub UI.
workflow_dispatch: {}

# Update status on all pull requests to important branches.
push:
branches:
- latest
- release

# Update status on all pushes to important branches.
pull_request:
branches:
- latest
- release

env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

concurrency:
group: test-status-${{ github.ref }}
cancel-in-progress: true

jobs:
status:
# if: github.event_name == 'push' || github.event.pull_request_target.merged == true
name: Reporting Test Suite Status
runs-on: ${{ vars.PREFERRED_OS }}

steps:
- uses: actions/checkout@v4

- name: Install Erlang & Elixir
id: beam-versions
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ vars.PREFERRED_ELIXIR }}
otp-version: ${{ vars.PREFERRED_OTP }}

- name: Restore mix dependency installation cache
id: mix-deps-get-cache
uses: actions/cache@v4
with:
path: |
deps
mix.lock
key: cache-${{ vars.CACHE_VERSION }}-os-${{ runner.os }}-${{ steps.beam-versions.outputs.otp-version }}-${{ steps.beam-versions.outputs.elixir-version }}-mix-deps-get-mix-exs-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.exs')) }}

- name: Install mix dependencies
if: steps.mix-deps-get-cache.outputs.cache-hit != 'true'
run: mix deps.get

- name: Restore mix dependency compilation cache
id: mix-deps-compile-cache
uses: actions/cache@v4
with:
path: _build
key: cache-${{ vars.CACHE_VERSION }}-os-${{ runner.os }}-${{ steps.beam-versions.outputs.otp-version }}-${{ steps.beam-versions.outputs.elixir-version }}-mix-deps-compile-mix-lock-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}

- name: Compile mix dependencies
if: steps.mix-deps-compile-cache.outputs.cache-hit != 'true'
run: mix deps.compile

- name: Report test suite coverage
run: mix test.coverage.report

results:
name: Test Status Results
runs-on: ${{ vars.PREFERRED_OS }}

if: ${{ always() }}
needs:
- status

steps:
- name: Test Status Succeeded
if: ${{ needs.status.result == 'success' }}
run: exit 0

- name: Test Status Failed
if: ${{ needs.status.result == 'failure' }}
run: exit 1
5 changes: 4 additions & 1 deletion .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Test ❯ Suite
# Runs tests, typechecking, and linting.

on:
# Allow running from GitHub UI.
- workflow_dispatch
# Run on all pushes.
- push

env:
Expand Down Expand Up @@ -146,7 +149,7 @@ jobs:
continue-on-error: true

results:
name: Test Suites Action Results
name: Test Suite Results
runs-on: ubuntu-20.04

if: ${{ always() }}
Expand Down
7 changes: 6 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ defmodule Erlex.MixProject do
"typecheck.build-cache": "dialyzer --plt --format dialyxir",
"typecheck.clean": "dialyzer.clean",
"typecheck.explain": "dialyzer.explain --format dialyxir",
"typecheck.run": "dialyzer --format dialyxir"
"typecheck.run": "dialyzer --format dialyxir",

# Test tasks
"test.coverage": "coveralls",
"test.coverage.report": "coveralls.github"
]
end

Expand All @@ -153,6 +157,7 @@ defmodule Erlex.MixProject do
defp deps() do
[
# {:dialyxir, "~> 1.4", only: @dev_envs, runtime: false, override: true}, # Transative dependency on ErlEx
{:excoveralls, "~> 0.18", only: :test},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
] ++ deps(:credo)
end
Expand Down

0 comments on commit 96a22b5

Please sign in to comment.