Skip to content

Commit

Permalink
New way of saving Environment variable space (#640)
Browse files Browse the repository at this point in the history
This is a different approach to solve the flooding of ENV

This PR will do the following changes:
- The ReadSettings action will always return Settings in ENV:Settings
and will NOT add settings to output
- Only specific settings specifíed in get: to the ReadSettings action
will be emitted as separate ENV variables (for use in yaml files)
- Settings are not transferred to actions in with: - but instead just
taken from $ENV:Settings in the action.yaml - settings will ever only
exist once.
- SettingsJson input is still available in action.yaml to ensure that
people on preview can upgrade.

Still needed (will be done as separate PR's after this one is merged)
- Do not re-write settings in ReadSecrets and DetermineArtifactUrl -
ReadSettings should be the only one.
- Split AnalyzeRepo into specific functions (instead of one function
with some -doNot's)
- A few actions will call ReadSettings instead of using $ENV:Settings -
we should always use the same $ENV:Settings pattern
- Remove SettingsJson from action.yaml 1 month after we ship
- Make Update AL.-Go System Files independent of the "old" repo.

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk authored Aug 4, 2023
1 parent d411e62 commit 78365a5
Show file tree
Hide file tree
Showing 76 changed files with 704 additions and 515 deletions.
37 changes: 21 additions & 16 deletions Actions/AddExistingApp/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Add existing app
Add an existing app to a AL-Go repository
## Parameters
### actor (default github.actor)
The GitHub actor running the action
### token (default github.token)
The GitHub token running the action
### parentTelemetryScopeJson (default {})
Specifies the parent telemetry scope for the telemetry signal
### project
Project name if the repository is setup for multiple projects
### type (required)
Type of apps in the repository (Per Tenant Extension, AppSource App)
### url (required)
Direct Download Url of .app or .zip file
### directCommit (default N)
Direct Commit (Y/N)
Add an existing app to an AL-Go for GitHub repository

## INPUT

### ENV variables
none

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| actor | | The GitHub actor running the action | github.actor |
| token | | The GitHub token running the action | github.token |
| parentTelemetryScopeJson | | Specifies the parent telemetry scope for the telemetry signal | {} |
| project | | Project name if the repository is setup for multiple projects | . |
| url | Yes | Direct Download Url of .app or .zip file to add to the repository | |
| updateBranch | | Which branch should the app be added to | github.ref_name |
| directCommit | | Y if the action should create a direct commit against the branch or N to create a Pull Request | N |

## OUTPUT
none
40 changes: 29 additions & 11 deletions Actions/AnalyzeTests/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# Analyze Tests
Analyze results of tests
## Parameters
### actor (default github.actor)
The GitHub actor running the action
### token (default github.token)
The GitHub token running the action
### parentTelemetryScopeJson (default {})
Specifies the parent telemetry scope for the telemetry signal
### projet (required)
Project to analyze
# Analyze Tests
Analyze results of tests from the RunPipeline action

## INPUT

### ENV variables
none

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| actor | | The GitHub actor running the action | github.actor |
| token | | The GitHub token running the action | github.token |
| parentTelemetryScopeJson | | Specifies the parent telemetry scope for the telemetry signal | {} |
| project | Yes | Name of project to analyze or . if the repository is setup for single project | |

## OUTPUT

### ENV variables
none

### OUTPUT variables
| Name | Description |
| :-- | :-- |
| TestResultMD | MarkDown of the test result with \n instead of line breaks |

### SUMMARY
This function will set the test result markdown in the GITHUB_STEP_SUMMARY section
5 changes: 1 addition & 4 deletions Actions/CalculateArtifactNames/CalculateArtifactNames.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Param(
[Parameter(HelpMessage = "Settings from repository in compressed Json format", Mandatory = $true)]
[string] $settingsJson,
[Parameter(HelpMessage = "Name of the built project", Mandatory = $true)]
[string] $project,
[Parameter(HelpMessage = "Build mode used when building the artifacts", Mandatory = $true)]
Expand All @@ -19,8 +17,7 @@ function Set-EnvVariable([string] $name, [string] $value) {

$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0

Write-Host $settingsJson
$settings = $settingsJson | ConvertFrom-Json
$settings = $env:Settings | ConvertFrom-Json

if ($project -eq ".") {
$project = $settings.repoName
Expand Down
59 changes: 46 additions & 13 deletions Actions/CalculateArtifactNames/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
# Calculate Artifact Names
Calculate Artifact Names for AL-Go workflows
## Parameters
### settingsJson
Settings from repository in compressed Json format
### project
Name of the built project
### buildMode
Build mode used when building the artifacts
### branchName
Name of the branch the workflow is running on
### suffix
A suffix to add to artifacts names
Note: if a suffix is specified, the current date will be added extra
Default suffix is the current build version

## INPUT

### ENV variables
| Name | Description |
| :-- | :-- |
| Settings | env.Settings must be set by a prior call to the ReadSettings Action |

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| project | Yes | Name of the built project or . if the repository is setup for single project | |
| buildMode | Yes |Build mode used when building the artifacts | |
| branchName | Yes | Name of the branch the workflow is running on | |
| suffix | | A suffix to add to artifacts names. **Note:** if a suffix is specified, the current date will be added extra | Build version |

## OUTPUT

### ENV variables
| Name | Description |
| :-- | :-- |
| ThisBuildAppsArtifactsName | Artifact name for apps being built in the current workflow run |
| ThisBuildTestAppsArtifactsName | Artifact name for test apps being built in the current workflow run |
| AppsArtifactsName | Artifacts name for Apps |
| DependenciesArtifactsName | Artifacts name for Dependencies |
| TestAppsArtifactsName | Artifacts name for TestApps |
| TestResultsArtifactsName | Artifacts name for TestResults |
| BcptTestResultsArtifactsName | Artifacts name for BcptTestResults |
| BuildOutputArtifactsName | Artifacts name for BuildOutput |
| ContainerEventLogArtifactsName | Artifacts name for ContainerEventLog |
| BuildMode | Build mode used when building the artifacts |

### OUTPUT variables
| Name | Description |
| :-- | :-- |
| ThisBuildAppsArtifactsName | Artifact name for apps being built in the current workflow run |
| ThisBuildTestAppsArtifactsName | Artifact name for test apps being built in the current workflow run |
| AppsArtifactsName | Artifacts name for Apps |
| DependenciesArtifactsName | Artifacts name for Dependencies |
| TestAppsArtifactsName | Artifacts name for TestApps |
| TestResultsArtifactsName | Artifacts name for TestResults |
| BcptTestResultsArtifactsName | Artifacts name for BcptTestResults |
| BuildOutputArtifactsName | Artifacts name for BuildOutput |
| ContainerEventLogArtifactsName | Artifacts name for ContainerEventLog |
| BuildMode | Build mode used when building the artifacts |
6 changes: 1 addition & 5 deletions Actions/CalculateArtifactNames/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ inputs:
description: Shell in which you want to run the action (powershell or pwsh)
required: false
default: powershell
settingsJson:
description: Settings from repository in compressed Json format
required: true
project:
description: Name of the built project
required: true
Expand Down Expand Up @@ -59,12 +56,11 @@ runs:
shell: ${{ inputs.shell }}
id: calculateartifactnames
env:
_settingsJson: ${{ inputs.settingsJson }}
_project: ${{ inputs.project }}
_buildMode: ${{ inputs.buildMode }}
_branchName: ${{ inputs.branchName }}
_suffix: ${{ inputs.suffix }}
run: try { ${{ github.action_path }}/CalculateArtifactNames.ps1 -settingsJson $ENV:_settingsJson -project $ENV:_project -buildMode $ENV:_buildMode -branchName $ENV:_branchName -suffix $ENV:_suffix } catch { Write-Host "::Error::Unexpected error when running action ($($_.Exception.Message.Replace("*",'').Replace("*",' ')))"; exit 1 }
run: try { ${{ github.action_path }}/CalculateArtifactNames.ps1 -project $ENV:_project -buildMode $ENV:_buildMode -branchName $ENV:_branchName -suffix $ENV:_suffix } catch { Write-Host "::Error::Unexpected error when running action ($($_.Exception.Message.Replace("*",'').Replace("*",' ')))"; exit 1 }
branding:
icon: terminal
color: blue
35 changes: 21 additions & 14 deletions Actions/CheckForUpdates/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# Check for updates
Check for updates to AL-Go system files
## Parameters
### actor (default github.actor)
The GitHub actor running the action
### token (default github.token)
The GitHub token running the action
### parentTelemetryScopeJson (default {})
Specifies the parent telemetry scope for the telemetry signal
### update (default N)
Set this input to Y in order to update AL-Go System Files if needed
### updateBranch (default github.ref_name)
Set the branch to update. In case `directCommit` parameter is set to 'Y', then the branch the action is run on will be updated.
### directCommit (default N)
Direct Commit (Y/N)
Check for updates to AL-Go system files and perform the update if requested

## INPUT

### ENV variables
none

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| actor | | The GitHub actor running the action | github.actor |
| token | | The GitHub token running the action | github.token |
| parentTelemetryScopeJson | | Specifies the parent telemetry scope for the telemetry signal | {} |
| templateBranch | | Branch in template repository to use for the update | default branch |
| update | | Set this input to Y in order to update AL-Go System Files if needed | N |
| updateBranch | | Set the branch to update. In case `directCommit` parameter is set to 'Y', then the branch the action is run on will be updated | github.ref_name |
| directCommit | | Y if the action should create a direct commit against the branch or N to create a Pull Request | N |

## OUTPUT
none
44 changes: 26 additions & 18 deletions Actions/CreateApp/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# Create a new app
Create a new app and add it to your AL-Go repository
## Parameters
### actor (default github.actor)
The GitHub actor running the action
### token (default github.token)
The GitHub token running the action
### parentTelemetryScopeJson (default {})
Specifies the parent telemetry scope for the telemetry signal
### type (required)
Type of app to add (Per Tenant Extension, AppSource App, Test App)
### publisher (required)
Publisher name of the app
### name (required)
Name of the app
### idrange (required)
ID range of the app
### directCommit (default N)
Direct Commit (Y/N)
Create a new app and add it to an AL-Go repository

## INPUT

### ENV variables
none

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| actor | | The GitHub actor running the action | github.actor |
| token | | The GitHub token running the action | github.token |
| parentTelemetryScopeJson | | Specifies the parent telemetry scope for the telemetry signal | {} |
| project | | Project name if the repository is setup for multiple projects | . |
| type | Yes | Type of app to add (PTE, AppSource App, Test App) | |
| name | Yes | App Name | |
| publisher | Yes | Publisher | |
| idrange | Yes | ID range | |
| sampleCode | | Include Sample Code (Y/N) | N |
| sampleSuite | | Include Sample BCPT Suite (Y/N) | N |
| updateBranch | | Which branch should the app be added to | github.ref_name |
| directCommit | | Y if the action should create a direct commit against the branch or N to create a Pull Request | N |

## OUTPUT
none
35 changes: 22 additions & 13 deletions Actions/CreateDevelopmentEnvironment/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# Create Development Environment
Create an online development environment
## Parameters
### actor (default github.actor)
The GitHub actor running the action
### token (default github.token)
The GitHub token running the action
### parentTelemetryScopeJson (default {})
Specifies the parent telemetry scope for the telemetry signal
### environmentName (required)
Name of the online environment to create
### adminCenterApiCredentials (required)
ClientId/ClientSecret or Refresh token for Admin Center API authentication
### directCommit (default N)
Direct Commit (Y/N)

## INPUT

### ENV variables
none

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| actor | | The GitHub actor running the action | github.actor |
| token | | The GitHub token running the action | github.token |
| parentTelemetryScopeJson | | Specifies the parent telemetry scope for the telemetry signal | {} |
| environmentName | Yes | Name of the online environment to create |
| project | | Project name if the repository is setup for multiple projects | . |
| adminCenterApiCredentials | | ClientId/ClientSecret or Refresh token for Admin Center API authentication | |
| reUseExistingEnvironment | | Reuse existing environment if it exists | N |
| updateBranch | | Which branch should the app be added to | github.ref_name |
| directCommit | | Y if the action should create a direct commit against the branch or N to create a Pull Request | N |

## OUTPUT
none
39 changes: 27 additions & 12 deletions Actions/CreateReleaseNotes/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
# Creates release notes
Creates release notes for a release, based on a given tag and the tag from the latest release.
## Parameters
### actor (default github.actor)
The GitHub actor running the action
### token (default github.token)
The GitHub token running the action
### parentTelemetryScopeJson (default {})
Specifies the parent telemetry scope for the telemetry signal
### tag_name (required)
This release tag name
### target_commitish (default last)
Last commit to include in release notes
Creates release notes for a release, based on a given tag and the tag from the latest release

## INPUT

### ENV variables
none

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| actor | | The GitHub actor running the action | github.actor |
| token | | The GitHub token running the action | github.token |
| parentTelemetryScopeJson | | Specifies the parent telemetry scope for the telemetry signal | {} |
| tag_name | Yes | This release tag name | |
| target_commitish | | Last commit to include in release notes | Latest |

## OUTPUT

### ENV variables
none

### OUTPUT variables
| Name | Description |
| :-- | :-- |
| ReleaseBranch | Name of the release branch |
| ReleaseNotes | Release notes generated based on the changes |
8 changes: 4 additions & 4 deletions Actions/Deliver/Deliver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ try {
$project = $thisProject.Replace('\','_').Replace('/','_')
}
else {
$project = $env:repoName
$project = $settings.repoName
}
# projectName is the project name stripped for special characters
$projectName = $project -replace "[^a-z0-9]", "-"
Expand Down Expand Up @@ -296,14 +296,14 @@ try {
$parameters.dependencyAppFiles = @(Get-Item -Path (Join-Path $dependenciesFolder[0] "*.app") | ForEach-Object { $_.FullName })
}
if ($nuGetAccount.Keys -contains 'PackageName') {
$parameters.packageId = $nuGetAccount.PackageName.replace('{project}',$projectName).replace('{owner}',$ENV:GITHUB_REPOSITORY_OWNER).replace('{repo}',$env:repoName)
$parameters.packageId = $nuGetAccount.PackageName.replace('{project}',$projectName).replace('{owner}',$ENV:GITHUB_REPOSITORY_OWNER).replace('{repo}',$settings.repoName)
}
else {
if ($thisProject -and ($thisProject -eq '.')) {
$parameters.packageId = "$($ENV:GITHUB_REPOSITORY_OWNER)-$($env:repoName)"
$parameters.packageId = "$($ENV:GITHUB_REPOSITORY_OWNER)-$($settings.repoName)"
}
else {
$parameters.packageId = "$($ENV:GITHUB_REPOSITORY_OWNER)-$($env:repoName)-$ProjectName"
$parameters.packageId = "$($ENV:GITHUB_REPOSITORY_OWNER)-$($settings.repoName)-$ProjectName"
}
}
if ($type -eq 'CD') {
Expand Down
Loading

0 comments on commit 78365a5

Please sign in to comment.