Skip to content

Commit

Permalink
[workflows] add coverage and add badge
Browse files Browse the repository at this point in the history
  • Loading branch information
shizunge committed Feb 1, 2024
1 parent 549f3f1 commit 13cecb0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: On push
name: Build

on:
push:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Coverage

on:
push:
branches:
- main
paths:
- '.shellspec'
- 'src/*'
- 'tests/*'
workflow_dispatch:

jobs:
coverage:
name: Run tests coverage
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Install shellspec
run: |
mkdir -p ~/shellspec
cd ~/shellspec
git clone https://github.com/shellspec/shellspec.git
ln -s ~/shellspec/shellspec/shellspec /usr/local/bin/shellspec
echo -n "shellspec version: "
shellspec --version
- name: Install kcov
run: |
sudo apt install -y kcov
echo -n "kcov version: "
kcov --version
- name: Checkout Code
uses: actions/checkout@v4
- name: Generate tests coverage reports
run: |
bash shellspec --kcov
- name: Upload reports
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[![Release](https://img.shields.io/github/release/shizunge/gantry.svg)](https://github.com/shizunge/gantry/releases/latest)
[![Docker Pulls](https://img.shields.io/docker/pulls/shizunge/gantry.svg)](https://hub.docker.com/r/shizunge/gantry)
[![Docker Image Size](https://img.shields.io/docker/image-size/shizunge/gantry/latest.svg)](https://hub.docker.com/r/shizunge/gantry)
[![Build](https://github.com/shizunge/gantry/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/shizunge/gantry/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/shizunge/gantry/graph/badge.svg?token=47MWUJOH4Q)](https://codecov.io/gh/shizunge/gantry)

# Gantry - Docker service updater

[*Gantry*](https://github.com/shizunge/gantry) updates docker swarm services to newer images.
Expand Down Expand Up @@ -130,7 +136,7 @@ To run `shellcheck` locally:
shellcheck src/*.sh tests/*.sh
```

Majority of the configuration options are covered by end-to-end tests. See [tests](./tests/README.md) folder about how to run tests.
[The tests folder](./tests) contains end-to-end tests, which cover the majority of the configuration options.

## Contacts

Expand Down
2 changes: 2 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Test *Gantry* Docker service updater

[![codecov](https://codecov.io/gh/shizunge/gantry/graph/badge.svg?token=47MWUJOH4Q)](https://codecov.io/gh/shizunge/gantry)

Majority of the configuration options are covered by end-to-end tests. The tests are utilizing [shellspec](https://github.com/shellspec/shellspec) framework. A quick installation of `shellspec` can be done by `curl -fsSL https://git.io/shellspec | sh`. See their website for more installation options.

The tests will create a local registry, testing images, and services. Testing images are pushed to the local registry, therefore no external registry is needed. Then the tests will run *Gantry* to update these services.
Expand Down

0 comments on commit 13cecb0

Please sign in to comment.