From 2172934d15a657318b63ff47e092317542103993 Mon Sep 17 00:00:00 2001 From: Matt Thalman Date: Thu, 18 Apr 2024 19:06:26 -0500 Subject: [PATCH] more diagnostics --- action.yml | 9 +++++++-- container/entrypoint.ps1 | 13 ++++++++++--- container/get-base-image.ps1 | 12 +++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 70e7e41..02708a0 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,9 @@ runs: $containerName = "docker-bump-checker" $containerSrcPath = "/src" + echo "workspace: ${env:GITHUB_WORKSPACE}" + Get-ChildItem "${env:GITHUB_WORKSPACE}../" + # The repo directory will be volume-mounted into the container so the Dockerfile path needs to be modified accordingly $dockerfile = "$containerSrcPath/$dockerfile" $result = docker run ` @@ -63,13 +66,15 @@ runs: throw "command failed" } - docker cp ${containerName}:/home/app homedir - Get-ChildItem homedir + docker cp ${containerName}:/home/app/log.txt log.txt + docker cp ${containerName}:/home/app/log1.txt log1.txt if ($LASTEXITCODE -ne 0) { throw "command failed" } Get-Content log.txt + echo "foo" + Get-Content log1.txt docker rm $containerName if ($LASTEXITCODE -ne 0) { throw "command failed" diff --git a/container/entrypoint.ps1 b/container/entrypoint.ps1 index ac6fb60..30b2fe0 100644 --- a/container/entrypoint.ps1 +++ b/container/entrypoint.ps1 @@ -17,9 +17,16 @@ $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' Set-StrictMode -Version 2.0 -if (-not $baseImage) { - $baseImage = $(& $PSScriptRoot/get-base-image.ps1 -DockerfilePath $DockerfilePath -BaseStageName $BaseStageName) +Write-Output "x${BaseImage}y" | Out-File $env:HOME/log.txt -Append +if ($BaseImage) { + Write-Output "x${BaseImage}y" | Out-File $env:HOME/log1.txt -Append } -$triggerWorkflow = $(& $PSScriptRoot/check-image.ps1 -TargetImage $targetImage -BaseImage $baseImage -Architecture $Architecture) +if (-not $BaseImage) { + Write-Output "x" | Out-File $env:HOME/log1.txt -Append + & $PSScriptRoot/get-base-image.ps1 -DockerfilePath $DockerfilePath -BaseStageName $BaseStageName +} + +$triggerWorkflow = $(& $PSScriptRoot/check-image.ps1 -TargetImage $targetImage -BaseImage $BaseImage -Architecture $Architecture) + return $triggerWorkflow diff --git a/container/get-base-image.ps1 b/container/get-base-image.ps1 index 5154dba..7ebd045 100644 --- a/container/get-base-image.ps1 +++ b/container/get-base-image.ps1 @@ -8,8 +8,11 @@ $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' Set-StrictMode -Version 2.0 +Write-Output "x" | Out-File $env:HOME/log2.txt -Append + function LogMessage ($Message) { - Write-Output $Message | Out-File $env:HOME/log.txt + Write-Output $Message | Out-File $env:HOME/log.txt -Append + Get-Content $env:HOME/log.txt } if (-not $DockerfilePath) { @@ -31,6 +34,8 @@ $dfspyArgs = @( # Otherwise, we need to derive the base image by finding the last stage of the Dockerfile and walking # its parent chain. To do that, we need the graph layout. +Write-Output foo1 + if (-not $BaseStageName) { LogMessage 'Stage name not provided. Will derive base image by walking parent chain.' $dfspyArgs += '--layout' @@ -44,6 +49,9 @@ if ($LASTEXITCODE -ne 0) { throw "dfspy failed" } +Write-Output foo2 + + if ($BaseStageName) { $baseImage = $fromOutput | Where-Object { $_.PSObject.Properties.Name -contains "stageName" -and $_.stageName -eq $BaseStageName } | Select-Object -ExpandProperty imageName } else { @@ -59,6 +67,8 @@ if ($BaseStageName) { $baseImage = $currentNode.fromInstruction.imageName } +Write-Output foo3 + LogMessage "Using base image name '$baseImage'." return $baseImage