Skip to content

Conversation

@jwikman
Copy link
Contributor

@jwikman jwikman commented Oct 16, 2025

Related to discussion: #1952

❔What, Why & How

This pull request introduces a new feature that allows repository maintainers to specify default values for workflow inputs using the workflowInputDefaults setting. This makes it easier to run workflows manually with consistent input values and improves configuration management for workflows triggered via workflow_dispatch. The implementation includes updates to documentation, schema validation, and the workflow update logic to support this feature.

New Feature: Workflow Input Defaults

  • Added support for the workflowInputDefaults setting in repository settings, enabling configuration of default values for workflow_dispatch inputs. The setting is now read and applied when updating AL-Go system files. [1] [2]
  • Implemented the ApplyWorkflowInputDefaults function in CheckForUpdates.HelperFunctions.ps1 to validate and inject default values into workflow YAML files. This function ensures the value types match input definitions and provides error messages for misconfigurations.

Documentation and Schema Updates

  • Updated settings.schema.json to define the structure for workflowInputDefaults, including type validation and descriptions for each property.
  • Enhanced documentation in settings.md and added release notes in RELEASENOTES.md to explain usage, configuration, and validation for the new setting. [1] [2]

Other Improvements

  • Exported the SanitizeWorkflowName function to support workflow name matching when applying defaults.

Note

The "hide" functionality mentioned in the discussion will come in its own PR when this is completed, to keep this PR cleaner and easier to review.

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

@jwikman jwikman marked this pull request as ready for review October 17, 2025 07:53
@jwikman jwikman requested a review from a team as a code owner October 17, 2025 07:53
Copilot AI review requested due to automatic review settings October 17, 2025 07:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for defining and applying default values to workflow_dispatch inputs via a new workflowInputDefaults repository setting. Updates include implementation logic, schema extension, documentation, release notes, and corresponding tests.

  • Introduces ApplyWorkflowInputDefaults to inject validated defaults into workflow YAML.
  • Extends settings schema and default settings; exports SanitizeWorkflowName for name matching.
  • Adds comprehensive tests and documentation for the new setting.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Implements ApplyWorkflowInputDefaults and integrates it into workflow processing.
Actions/.Modules/ReadSettings.psm1 Adds default and exports SanitizeWorkflowName for reuse.
Actions/.Modules/settings.schema.json Adds schema definition for workflowInputDefaults.
Tests/CheckForUpdates.Action.Test.ps1 Adds test cases covering application and validation of input defaults.
Scenarios/settings.md Documents new workflowInputDefaults setting.
RELEASENOTES.md Announces new feature with example configuration.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PSScriptAnalyzer found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@jwikman
Copy link
Contributor Author

jwikman commented Oct 17, 2025

PSScriptAnalyzer found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

🫣

I'll need to get this PSScriptAnalyzer to work... Will update

@jwikman
Copy link
Contributor Author

jwikman commented Oct 20, 2025

Strange, I believe these tests worked last week.

I'll investigate

@jwikman
Copy link
Contributor Author

jwikman commented Oct 20, 2025

@mazhelez I cannot see this error coming from this PR, do you? 🤔

The failing test:

Error: [-] ReadSettings.Reads settings from all settings locations 12ms (11ms|1ms)
Message
  IOException: An item with the specified name /tmp/b4900e85-aaba-4297-896a-ac992ec3e615 already exists.
  at <ScriptBlock>, /home/runner/work/AL-Go/AL-Go/Tests/ReadSettings.Test.ps1:21

This PR do not touch ReadSettings.Test.ps1 and pester shows 10 out of 10 successful tests when running locally. Do they fail for you?

It complains on the last of these lines:

            $tempName = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
            $githubFolder = Join-Path $tempName ".github"
            $ALGoFolder = Join-Path $tempName $ALGoFolderName
            $projectALGoFolder = Join-Path $tempName "Project/$ALGoFolderName"

            New-Item $githubFolder -ItemType Directory | Out-Null
            New-Item $ALGoFolder -ItemType Directory | Out-Null

$ALGoFolderName should've been initialized from the ReadSettings module, if I'm not mistaken. But it looks as if it is not. 😕

It would probably work if I just added $ALGoFolderName = '.AL-Go' before this code, but that does not solve the root cause...

Advice? 🙂

@jwikman
Copy link
Contributor Author

jwikman commented Oct 20, 2025

Just realized that I could run the CI pipeline for this branch in my own repo, and it is failing as well - so now I can test things out myself.

Going forward, I will run CI self before creating PRs. 👍

@mazhelez
Copy link
Collaborator

@mazhelez I cannot see this error coming from this PR, do you? 🤔

The failing test:

Error: [-] ReadSettings.Reads settings from all settings locations 12ms (11ms|1ms)
Message
  IOException: An item with the specified name /tmp/b4900e85-aaba-4297-896a-ac992ec3e615 already exists.
  at <ScriptBlock>, /home/runner/work/AL-Go/AL-Go/Tests/ReadSettings.Test.ps1:21

This PR do not touch ReadSettings.Test.ps1 and pester shows 10 out of 10 successful tests when running locally. Do they fail for you?

It complains on the last of these lines:

            $tempName = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
            $githubFolder = Join-Path $tempName ".github"
            $ALGoFolder = Join-Path $tempName $ALGoFolderName
            $projectALGoFolder = Join-Path $tempName "Project/$ALGoFolderName"

            New-Item $githubFolder -ItemType Directory | Out-Null
            New-Item $ALGoFolder -ItemType Directory | Out-Null

$ALGoFolderName should've been initialized from the ReadSettings module, if I'm not mistaken. But it looks as if it is not. 😕

It would probably work if I just added $ALGoFolderName = '.AL-Go' before this code, but that does not solve the root cause...

Advice? 🙂

It looks like $ALGoFolderName isn't defined, which is weird as I see it exported from Actions\.Modules\ReadSettings.psm1. Don't have theories why this test fails on your PR. You can try including the module import in the test itself to see, if that fixes it.

@jwikman
Copy link
Contributor Author

jwikman commented Oct 20, 2025

It looks like $ALGoFolderName isn't defined, which is weird as I see it exported from Actions\.Modules\ReadSettings.psm1. Don't have theories why this test fails on your PR. You can try including the module import in the test itself to see, if that fixes it.

I agree, something weird is going on. :)
But I will narrow it down in my own repo and then we'll see what action is needed.

@jwikman
Copy link
Contributor Author

jwikman commented Oct 20, 2025

@mazhelez it was a scoping issue, I believe... I've never really got my head around the scoping in PS...
And obviously we do not have test isolations between the different tests here.

But if you kick on the workflow again, it should pass!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants