maxep 6 år sedan
förälder
incheckning
d9c245360a

+ 10 - 0
.github/actions/spm-lcov-action/README.md

@@ -2,6 +2,16 @@
 
 Swift Package Manager Code Coverage Report.
 
+## Inputs
+
+### `output-file`
+
+**Optional** Specify a file path to write coverage reports into. By default, the coverage will be reported to `.build/debug/codecov/lcov.info`.
+
+### `file-format`
+
+**Optional** Use the specified output format. The supported formats are: “text” (JSON), “lcov” (Default).
+
 ## Example usage
 
 uses: maxep/spm-lcov-action@0.2.0

+ 9 - 0
.github/actions/spm-lcov-action/action.yml

@@ -1,6 +1,15 @@
 name: 'SPM lcov report'
 description: 'Swift Package Manager Code Coverage Report'
 author: 'Maxime Epain'
+inputs:
+    output-file:
+        description: 'The output file path'
+        required: false
+        default: '.build/debug/codecov/lcov.info'
+    file-format:
+        description: 'The output file format'
+        required: false
+        default: 'lcov'
 runs:
     using: 'node12'
     main: 'index.js'

+ 15 - 1
.github/actions/spm-lcov-action/cov.sh

@@ -8,6 +8,20 @@ COV_BIN=$XCTEST_PATH
 INSTR_PROFILE=.build/debug/codecov/default.profdata
 IGNORE_FILENAME_REGEX=".build|Tests"
 
+FORMAT="lcov"
+OUTPUT_FILE=.build/debug/codecov/lcov.info
+
+while :; do
+    case $1 in
+        -f|--format) FORMAT=$2          
+        ;;
+        -o|--output) OUTPUT_FILE=$2      
+        ;;
+        *) break
+    esac
+    shift
+done
+
 if [[ "$OSTYPE" == "darwin"* ]]; then
     f="$(basename $XCTEST_PATH .xctest)"
     COV_BIN="${COV_BIN}/Contents/MacOS/$f"
@@ -24,4 +38,4 @@ llvm-cov export \
     "${COV_BIN}" \
     -instr-profile=$INSTR_PROFILE \
     -ignore-filename-regex=$IGNORE_FILENAME_REGEX \
-    -format="lcov"
+    -format=$FORMAT > $OUTPUT_FILE

+ 8 - 1
.github/actions/spm-lcov-action/index.js

@@ -1,3 +1,10 @@
+const core = require('@actions/core')
 const exec = require('@actions/exec')
 
-exec.exec(`${__dirname}/cov.sh`)
+async function main() {
+    const format = core.getInput('file-format')
+    const output = core.getInput('output-file')
+    await exec.exec(`${__dirname}/cov.sh -f ${format} -o ${output}`)
+}
+
+main().catch(err => core.setFailed(err.message))