Skip to content

Commit

Permalink
[#13] feat!: use GitHub's way to print debug info
Browse files Browse the repository at this point in the history
The only action's input - `verbose` - is now not needed.
  • Loading branch information
krzema12 committed Jul 22, 2022
1 parent 66f7a98 commit 6b4fa38
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
3 changes: 0 additions & 3 deletions action-types.yml
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
inputs:
verbose:
type: boolean
5 changes: 0 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: GitHub Actions Typing
description: Bring type-safety to your GitHub actions' API!
author: Piotr Krzemiński
inputs:
verbose:
description: 'Set to true to display debug information helpful when troubleshooting issues with this action.'
required: false
default: 'false'
runs:
using: 'docker'
image: 'Dockerfile'
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.krzeminski.githubactionstyping

import it.krzeminski.githubactionstyping.github.getBooleanInput
import it.krzeminski.githubactionstyping.parsing.TypesManifest
import it.krzeminski.githubactionstyping.parsing.parseManifest
import it.krzeminski.githubactionstyping.parsing.parseTypesManifest
Expand Down Expand Up @@ -30,27 +29,30 @@ fun manifestsToReport(manifest: String, typesManifest: String): Pair<Boolean, St
throw IllegalStateException("The same set of outputs should exist in action manifest and types manifest!")
}

if (getBooleanInput("verbose")) {
println("Action's manifest:")
println(manifest)
printlnDebug("Action's manifest:")
printlnDebug(manifest)

println("Parsed manifest:")
println(parsedManifest)
printlnDebug("Parsed manifest:")
printlnDebug(parsedManifest)

println("Action's types manifest:")
println(typesManifest)
printlnDebug("Action's types manifest:")
printlnDebug(typesManifest)

println("Parsed types manifest:")
println(parsedTypesManifest)
printlnDebug("Parsed types manifest:")
printlnDebug(parsedTypesManifest)

println()
println("==============================================")
println()
}
printlnDebug()
printlnDebug("==============================================")
printlnDebug()

val validationResult = parsedTypesManifest.validate()
val isValid = validationResult.overallResult is ItemValidationResult.Valid
val report = validationResult.toPlaintextReport()

return Pair(isValid, report)
}

private fun printlnDebug(string: Any? = null) =
(string ?: "").toString().lines()
.map { "::debug::$it" }
.forEach { println(it) }

This file was deleted.

0 comments on commit 6b4fa38

Please sign in to comment.