unit tests #97
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: krknctl test | |
on: | |
pull_request: | |
jobs: | |
test: | |
name: krknctl test | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: create multi-node kind cluster | |
uses: redhat-chaos/actions/kind@main | |
- name: code checkout | |
uses: actions/checkout@v4 | |
- name: set up go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23.1' | |
- name: install podman | |
run: | | |
sudo apt-get update && sudo apt-get install podman libbtrfs-dev nodejs wamerican | |
- name: setup podman | |
run: | | |
echo "XDG_RUNTIME_DIR=/run/user/$UID" >> $GITHUB_ENV | |
echo "PODMAN_SOCKET=$XDG_RUNTIME_DIR/podman/podman.sock" >> $GITHUB_ENV | |
loginctl enable-linger $(whoami) | |
podman system service --time=0 $PODMAN_SOCKET & | |
- name: set up test formatters | |
run: | | |
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest | |
go install github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest | |
- name: run test suite | |
run: | | |
export USERID=$(id -u) | |
go test -tags containers_image_openpgp -race -json -v -coverprofile=coverage.out ./... 2>&1 | tee /tmp/gotest.log | gotestfmt | |
cat /tmp/gotest.log | go-ctrf-json-reporter -output ctrf-report.json | |
- name: generate test report | |
run: npx github-actions-ctrf ctrf-report.json | |
- name: generate coverage report | |
run: | | |
COVERAGE=$(go tool cover -func coverage.out | grep total | awk '{print $3}') | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "# TEST COVERAGE: $COVERAGE" >> $GITHUB_STEP_SUMMARY | |
echo "TOTAL_COVERAGE=$COVERAGE" >> $GITHUB_ENV | |
- name: check out doc repo | |
uses: actions/checkout@v4 | |
with: | |
repository: krkn-chaos/krkn-lib-docs | |
path: krkn-lib-docs | |
ssh-key: ${{ secrets.KRKN_LIB_DOCS_PRIV_KEY }} | |
- name: push updated coverage badge | |
env: | |
COLOR: yellow | |
run: | | |
[[ $TOTAL_COVERAGE > 40 ]] && COLOR=green | |
curl -s "https://img.shields.io/badge/coverage-${TOTAL_COVERAGE//\%/}%25-$COLOR" > ./krkn-lib-docs/coverage_badge_krknctl.svg | |
cd krkn-lib-docs | |
git add . | |
git config user.name "krkn-chaos" | |
git config user.email "<>" | |
git commit -m "[KRKN] Coverage Badge ${GITHUB_REF##*/}" || echo "no changes to commit" | |
git push | |