Repository navigation
51 lines (48 loc) · 2.32 KB
/
Copy pathshellspec.yaml
File metadata and controls
51 lines (48 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Shell/Bash Script Unit Tests
on: pull_request
# Cancel a superseded run when a new commit is pushed to the same PR, so its (now stale)
# results never race the newer push's publisher for the coverage comment - see
# shellspec-publish.yml for the belt-and-braces check on the publishing side too.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
shellspec:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27'
- run: |
make shellspec-ci
name: Run shell/bash script unit tests with shellspec
- run: echo "Shell/Bash script unit tests failed. Please check the logs for details. To run the shellspec unit tests locally, please refer to ./spec/README.md"
if: failure()
name: Print failure message
- run: echo "Shell/Bash script unit tests completed successfully!"
name: Print completion message
- name: Fix up kcov's Cobertura output for CodeCoverageSummary
# kcov's Cobertura report omits the `branches-valid` attribute (it doesn't track
# branch coverage, only lines), which crashes irongut/CodeCoverageSummary v1.3.0 with
# "Sequence contains no elements" (https://github.com/irongut/CodeCoverageSummary/pull/162,
# never merged/released upstream). Add the missing attribute so parsing doesn't blow up.
# Written to a new file rather than edited in place: coverage/ is root-owned (created by
# the shellspec container), so this (non-root) step can't write into it directly.
run: |
set -ex
sed -E 's/(<coverage [^>]*branches-rate="[^"]*")/\1 branches-valid="0"/' coverage/cobertura.xml > shellspec-cobertura.xml
if: (!cancelled())
- name: Upload coverage report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: (!cancelled())
with:
name: shellspec-coverage
path: shellspec-cobertura.xml
retention-days: 5
# Coverage is published by shellspec-publish.yml, a separate workflow_run-triggered workflow -
# see that file for why this can't just be a second job here.