Skip to content

feat: capture code coverage in tests #270

feat: capture code coverage in tests

feat: capture code coverage in tests #270

Workflow file for this run

name: Test
on:
pull_request:
paths:
- "**.sh"
- "test/**"
- "action.yml"
- ".github/workflows/test.yml"
jobs:
bash_unit:
name: Bash unit tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- name: Get Hadolint version
# yq is like jq for yaml
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#tools
# shellcheck disable=SC2034
run: echo version="$(yq .inputs.version.default action.yml)" >> "${GITHUB_ENV}"
- name: Install Hadolint
run: |
echo "::debug::Downloading Hadolint ${{ env.version }}"
curl -L -s -o hadolint "https://github.com/hadolint/hadolint/releases/download/v${{ env.version }}/hadolint-Linux-x86_64"
chmod +x hadolint
sudo mv hadolint /usr/local/bin/hadolint
- name: Install bash_unit
run: curl -Ls "https://github.com/pgrange/bash_unit/archive/refs/tags/v2.3.3.tar.gz" | tar -x -z --wildcards --strip-components=1 -C /usr/local/bin "*/bash_unit"
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- name: Install bashcov
run: gem install bashcov
- name: Run suite
run: bashcov bash_unit test/*.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/.resultset.json