From fca823b7b6afb5c7ff8b6667db59a05128b2186a Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 2 Feb 2022 14:23:02 -0800 Subject: [PATCH 1/3] Add experimental json update automation --- .github/workflows/exp-json.yml | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/exp-json.yml diff --git a/.github/workflows/exp-json.yml b/.github/workflows/exp-json.yml new file mode 100644 index 00000000000..dfd3f1e9474 --- /dev/null +++ b/.github/workflows/exp-json.yml @@ -0,0 +1,82 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. + +name: PowerShell Experimental Features Json Update +on: + workflow_dispatch: + schedule: + # At 13:00 UTC every day. + - cron: '0 13 * * *' + +defaults: + run: + shell: pwsh + +env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + +jobs: + create-expjson-windows: + name: Update experimental features json + timeout-minutes: 15 + runs-on: windows-latest + if: github.repository == 'PowerShell/PowerShell' + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Create experimental features file + run: | + Import-Module ./build.psm1 -Force + Import-Module ./.github/workflows/GHWorkflowHelper -Force + Start-PSBootstrap + Start-PSBuild -Clean -SkipExperimentalFeatureGeneration + $pwsh = Get-PSOutput + + $getExpFeatureJsonScript = @' + [System.Collections.ArrayList] $expFeatures = Get-ExperimentalFeature | Where-Object Name -NE PS7DscSupport | ForEach-Object -MemberName Name + + # Make sure ExperimentalFeatures from modules in PSHome are added + # https://github.com/PowerShell/PowerShell/issues/10550 + $ExperimentalFeaturesFromGalleryModulesInPSHome = @() + $ExperimentalFeaturesFromGalleryModulesInPSHome | ForEach-Object { + if (!$expFeatures.Contains($_)) { + $null = $expFeatures.Add($_) + } + } + + ConvertTo-Json $expFeatures + '@ + + $expFeaturesJson = & pwsh -c $getExpFeatureJsonScript + $expFeaturesJson | Out-File ./experimental-feature-windows-new.json -Force + + if (Test-Path ./experimental-feature-windows.json) { + $currentExpFeatures = Get-Content ./experimental-feature-windows.json -Raw | ConvertFrom-Json + $newExpFeatures = Get-Content ./experimental-feature-windows-new.json -Raw | ConvertFrom-Json + + if (-not (Compare-Object $currentExpFeatures $newExpFeatures)) { + Write-Verbose -Verbose "No changes to experimental features json file" + Set-GWVariable -Name CREATE_EXP_JSON_PR -Value 'false' + exit 0 + } + } + + Move-Item ./experimental-feature-windows-new.json ./experimental-feature-windows.json -Verbose + Set-GWVariable -Name CREATE_EXP_JSON_PR -Value 'true' + + - name: Upload experimental features windows + uses: actions/upload-artifact@v2 + with: + name: experimental-feature-windows-new.json + path: experimental-feature-windows-new.json + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + id: cpr + if: env.CREATE_EXP_JSON_PR == 'true' + with: + commit-message: "Update experimental-feature-windows.json" + title: "Update experimental-feature-windows.json" + base: master + branch: expjson_update_windows From c7bf1fe7db78df8a38c69ea092dea67e465277c4 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 2 Feb 2022 14:46:23 -0800 Subject: [PATCH 2/3] Add dummy trigger --- .github/workflows/exp-json.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/exp-json.yml b/.github/workflows/exp-json.yml index dfd3f1e9474..006128452bb 100644 --- a/.github/workflows/exp-json.yml +++ b/.github/workflows/exp-json.yml @@ -8,6 +8,9 @@ on: # At 13:00 UTC every day. - cron: '0 13 * * *' + push: + branches: [ doesnotexist ] + defaults: run: shell: pwsh From d76296e2b8a76f187e49514eee16487ee8754a28 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 2 Feb 2022 14:50:52 -0800 Subject: [PATCH 3/3] Address CR comment --- .github/workflows/exp-json.yml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/exp-json.yml b/.github/workflows/exp-json.yml index 006128452bb..5af333cd9ea 100644 --- a/.github/workflows/exp-json.yml +++ b/.github/workflows/exp-json.yml @@ -8,9 +8,6 @@ on: # At 13:00 UTC every day. - cron: '0 13 * * *' - push: - branches: [ doesnotexist ] - defaults: run: shell: pwsh @@ -37,18 +34,18 @@ jobs: $pwsh = Get-PSOutput $getExpFeatureJsonScript = @' - [System.Collections.ArrayList] $expFeatures = Get-ExperimentalFeature | Where-Object Name -NE PS7DscSupport | ForEach-Object -MemberName Name + [System.Collections.ArrayList] $expFeatures = Get-ExperimentalFeature | Where-Object Name -NE PS7DscSupport | ForEach-Object -MemberName Name - # Make sure ExperimentalFeatures from modules in PSHome are added - # https://github.com/PowerShell/PowerShell/issues/10550 - $ExperimentalFeaturesFromGalleryModulesInPSHome = @() - $ExperimentalFeaturesFromGalleryModulesInPSHome | ForEach-Object { - if (!$expFeatures.Contains($_)) { - $null = $expFeatures.Add($_) - } - } + # Make sure ExperimentalFeatures from modules in PSHome are added + # https://github.com/PowerShell/PowerShell/issues/10550 + $ExperimentalFeaturesFromGalleryModulesInPSHome = @() + $ExperimentalFeaturesFromGalleryModulesInPSHome | ForEach-Object { + if (!$expFeatures.Contains($_)) { + $null = $expFeatures.Add($_) + } + } - ConvertTo-Json $expFeatures + ConvertTo-Json $expFeatures '@ $expFeaturesJson = & pwsh -c $getExpFeatureJsonScript