Action-Test - [Refactor version resolution logic into helper functions #2] by @MariusStorhaug #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Action-Test | |
| run-name: 'Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}' | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| ActionTest-PatchBump: | |
| name: Action-Test - [Patch bump] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Create fake PR event | |
| shell: pwsh | |
| run: | | |
| $event = @{ | |
| pull_request = @{ | |
| head = @{ ref = 'feat/test-patch' } | |
| labels = @( | |
| @{ name = 'patch' } | |
| ) | |
| } | |
| } | ConvertTo-Json -Depth 5 | |
| $event | Set-Content -Path "$env:RUNNER_TEMP/event.json" | |
| "GITHUB_EVENT_PATH=$env:RUNNER_TEMP/event.json" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Resolve-PSModuleVersion | |
| id: resolve | |
| uses: ./ | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| with: | |
| Settings: | | |
| { | |
| "Publish": { | |
| "Module": { | |
| "ReleaseType": "Release", | |
| "AutoPatching": false, | |
| "VersionPrefix": "v", | |
| "MajorLabels": "major", | |
| "MinorLabels": "minor", | |
| "PatchLabels": "patch", | |
| "IgnoreLabels": "" | |
| } | |
| } | |
| } | |
| EventJson: '{"pull_request":{"head":{"ref":"feat/test-patch"},"labels":[{"name":"patch"}]}}' | |
| - name: Verify - Patch bump | |
| shell: pwsh | |
| env: | |
| RESOLVE_CREATE_RELEASE: ${{ steps.resolve.outputs.CreateRelease }} | |
| RESOLVE_VERSION: ${{ steps.resolve.outputs.Version }} | |
| RESOLVE_RELEASE_TYPE: ${{ steps.resolve.outputs.ReleaseType }} | |
| RESOLVE_FULL_VERSION: ${{ steps.resolve.outputs.FullVersion }} | |
| run: | | |
| Write-Host '--- Input ---' | |
| Write-Host "EventJson: {\"pull_request\":{\"head\":{\"ref\":\"feat/test-patch\"},\"labels\":[{\"name\":\"patch\"}]}}" | |
| Write-Host "Settings: ReleaseType=Release, AutoPatching=false, PatchLabels=patch" | |
| Write-Host '' | |
| Write-Host '--- Expected vs Actual ---' | |
| Write-Host "CreateRelease: expected='true' actual='$env:RESOLVE_CREATE_RELEASE'" | |
| Write-Host "ReleaseType: expected='Release' actual='$env:RESOLVE_RELEASE_TYPE'" | |
| Write-Host "Version: expected='non-empty' actual='$env:RESOLVE_VERSION'" | |
| Write-Host "FullVersion: actual='$env:RESOLVE_FULL_VERSION'" | |
| Write-Host '' | |
| $failed = $false | |
| if ($env:RESOLVE_CREATE_RELEASE -ne 'true') { | |
| Write-Error "CreateRelease: expected 'true', got '$env:RESOLVE_CREATE_RELEASE'" | |
| $failed = $true | |
| } | |
| if ([string]::IsNullOrEmpty($env:RESOLVE_VERSION)) { | |
| Write-Error "Version: expected non-empty, got empty" | |
| $failed = $true | |
| } | |
| if ($env:RESOLVE_RELEASE_TYPE -ne 'Release') { | |
| Write-Error "ReleaseType: expected 'Release', got '$env:RESOLVE_RELEASE_TYPE'" | |
| $failed = $true | |
| } | |
| if ($failed) { exit 1 } | |
| ActionTest-MinorBump: | |
| name: Action-Test - [Minor bump] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Create fake PR event | |
| shell: pwsh | |
| run: | | |
| $event = @{ | |
| pull_request = @{ | |
| head = @{ ref = 'feat/test-minor' } | |
| labels = @( | |
| @{ name = 'minor' } | |
| ) | |
| } | |
| } | ConvertTo-Json -Depth 5 | |
| $event | Set-Content -Path "$env:RUNNER_TEMP/event.json" | |
| "GITHUB_EVENT_PATH=$env:RUNNER_TEMP/event.json" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Resolve-PSModuleVersion | |
| id: resolve | |
| uses: ./ | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| with: | |
| Settings: | | |
| { | |
| "Publish": { | |
| "Module": { | |
| "ReleaseType": "Release", | |
| "AutoPatching": false, | |
| "VersionPrefix": "v", | |
| "MajorLabels": "major", | |
| "MinorLabels": "minor", | |
| "PatchLabels": "patch", | |
| "IgnoreLabels": "" | |
| } | |
| } | |
| } | |
| EventJson: '{"pull_request":{"head":{"ref":"feat/test-minor"},"labels":[{"name":"minor"}]}}' | |
| - name: Verify - Minor bump | |
| shell: pwsh | |
| env: | |
| RESOLVE_CREATE_RELEASE: ${{ steps.resolve.outputs.CreateRelease }} | |
| RESOLVE_VERSION: ${{ steps.resolve.outputs.Version }} | |
| RESOLVE_RELEASE_TYPE: ${{ steps.resolve.outputs.ReleaseType }} | |
| RESOLVE_FULL_VERSION: ${{ steps.resolve.outputs.FullVersion }} | |
| run: | | |
| Write-Host '--- Input ---' | |
| Write-Host "EventJson: {\"pull_request\":{\"head\":{\"ref\":\"feat/test-minor\"},\"labels\":[{\"name\":\"minor\"}]}}" | |
| Write-Host "Settings: ReleaseType=Release, AutoPatching=false, MinorLabels=minor" | |
| Write-Host '' | |
| Write-Host '--- Expected vs Actual ---' | |
| Write-Host "CreateRelease: expected='true' actual='$env:RESOLVE_CREATE_RELEASE'" | |
| Write-Host "ReleaseType: expected='Release' actual='$env:RESOLVE_RELEASE_TYPE'" | |
| Write-Host "Version: expected='non-empty' actual='$env:RESOLVE_VERSION'" | |
| Write-Host "FullVersion: actual='$env:RESOLVE_FULL_VERSION'" | |
| Write-Host '' | |
| $failed = $false | |
| if ($env:RESOLVE_CREATE_RELEASE -ne 'true') { | |
| Write-Error "CreateRelease: expected 'true', got '$env:RESOLVE_CREATE_RELEASE'" | |
| $failed = $true | |
| } | |
| if ([string]::IsNullOrEmpty($env:RESOLVE_VERSION)) { | |
| Write-Error "Version: expected non-empty, got empty" | |
| $failed = $true | |
| } | |
| if ($env:RESOLVE_RELEASE_TYPE -ne 'Release') { | |
| Write-Error "ReleaseType: expected 'Release', got '$env:RESOLVE_RELEASE_TYPE'" | |
| $failed = $true | |
| } | |
| if ($failed) { exit 1 } | |
| ActionTest-MajorBump: | |
| name: Action-Test - [Major bump] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Create fake PR event | |
| shell: pwsh | |
| run: | | |
| $event = @{ | |
| pull_request = @{ | |
| head = @{ ref = 'feat/test-major' } | |
| labels = @( | |
| @{ name = 'major' } | |
| ) | |
| } | |
| } | ConvertTo-Json -Depth 5 | |
| $event | Set-Content -Path "$env:RUNNER_TEMP/event.json" | |
| "GITHUB_EVENT_PATH=$env:RUNNER_TEMP/event.json" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Resolve-PSModuleVersion | |
| id: resolve | |
| uses: ./ | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| with: | |
| Settings: | | |
| { | |
| "Publish": { | |
| "Module": { | |
| "ReleaseType": "Release", | |
| "AutoPatching": false, | |
| "VersionPrefix": "v", | |
| "MajorLabels": "major", | |
| "MinorLabels": "minor", | |
| "PatchLabels": "patch", | |
| "IgnoreLabels": "" | |
| } | |
| } | |
| } | |
| EventJson: '{"pull_request":{"head":{"ref":"feat/test-major"},"labels":[{"name":"major"}]}}' | |
| - name: Verify - Major bump | |
| shell: pwsh | |
| env: | |
| RESOLVE_CREATE_RELEASE: ${{ steps.resolve.outputs.CreateRelease }} | |
| RESOLVE_VERSION: ${{ steps.resolve.outputs.Version }} | |
| RESOLVE_RELEASE_TYPE: ${{ steps.resolve.outputs.ReleaseType }} | |
| RESOLVE_FULL_VERSION: ${{ steps.resolve.outputs.FullVersion }} | |
| run: | | |
| Write-Host '--- Input ---' | |
| Write-Host "EventJson: {\"pull_request\":{\"head\":{\"ref\":\"feat/test-major\"},\"labels\":[{\"name\":\"major\"}]}}" | |
| Write-Host "Settings: ReleaseType=Release, AutoPatching=false, MajorLabels=major" | |
| Write-Host '' | |
| Write-Host '--- Expected vs Actual ---' | |
| Write-Host "CreateRelease: expected='true' actual='$env:RESOLVE_CREATE_RELEASE'" | |
| Write-Host "ReleaseType: expected='Release' actual='$env:RESOLVE_RELEASE_TYPE'" | |
| Write-Host "Version: expected='non-empty' actual='$env:RESOLVE_VERSION'" | |
| Write-Host "FullVersion: actual='$env:RESOLVE_FULL_VERSION'" | |
| Write-Host '' | |
| $failed = $false | |
| if ($env:RESOLVE_CREATE_RELEASE -ne 'true') { | |
| Write-Error "CreateRelease: expected 'true', got '$env:RESOLVE_CREATE_RELEASE'" | |
| $failed = $true | |
| } | |
| if ([string]::IsNullOrEmpty($env:RESOLVE_VERSION)) { | |
| Write-Error "Version: expected non-empty, got empty" | |
| $failed = $true | |
| } | |
| if ($env:RESOLVE_RELEASE_TYPE -ne 'Release') { | |
| Write-Error "ReleaseType: expected 'Release', got '$env:RESOLVE_RELEASE_TYPE'" | |
| $failed = $true | |
| } | |
| if ($failed) { exit 1 } | |
| ActionTest-AutoPatch: | |
| name: Action-Test - [Auto-patch] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Create fake PR event | |
| shell: pwsh | |
| run: | | |
| $event = @{ | |
| pull_request = @{ | |
| head = @{ ref = 'feat/test-autopatch' } | |
| labels = @() | |
| } | |
| } | ConvertTo-Json -Depth 5 | |
| $event | Set-Content -Path "$env:RUNNER_TEMP/event.json" | |
| "GITHUB_EVENT_PATH=$env:RUNNER_TEMP/event.json" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Resolve-PSModuleVersion | |
| id: resolve | |
| uses: ./ | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| with: | |
| Settings: | | |
| { | |
| "Publish": { | |
| "Module": { | |
| "ReleaseType": "Release", | |
| "AutoPatching": true, | |
| "VersionPrefix": "v", | |
| "MajorLabels": "major", | |
| "MinorLabels": "minor", | |
| "PatchLabels": "patch", | |
| "IgnoreLabels": "" | |
| } | |
| } | |
| } | |
| EventJson: '{"pull_request":{"head":{"ref":"feat/test-autopatch"},"labels":[]}}' | |
| - name: Verify - Auto-patch | |
| shell: pwsh | |
| env: | |
| RESOLVE_CREATE_RELEASE: ${{ steps.resolve.outputs.CreateRelease }} | |
| RESOLVE_VERSION: ${{ steps.resolve.outputs.Version }} | |
| RESOLVE_RELEASE_TYPE: ${{ steps.resolve.outputs.ReleaseType }} | |
| RESOLVE_FULL_VERSION: ${{ steps.resolve.outputs.FullVersion }} | |
| run: | | |
| Write-Host '--- Input ---' | |
| Write-Host "EventJson: {\"pull_request\":{\"head\":{\"ref\":\"feat/test-autopatch\"},\"labels\":[]}}" | |
| Write-Host "Settings: ReleaseType=Release, AutoPatching=true, PatchLabels=patch" | |
| Write-Host '' | |
| Write-Host '--- Expected vs Actual ---' | |
| Write-Host "CreateRelease: expected='true' actual='$env:RESOLVE_CREATE_RELEASE'" | |
| Write-Host "ReleaseType: expected='Release' actual='$env:RESOLVE_RELEASE_TYPE'" | |
| Write-Host "Version: expected='non-empty' actual='$env:RESOLVE_VERSION'" | |
| Write-Host "FullVersion: actual='$env:RESOLVE_FULL_VERSION'" | |
| Write-Host '' | |
| $failed = $false | |
| if ($env:RESOLVE_CREATE_RELEASE -ne 'true') { | |
| Write-Error "CreateRelease: expected 'true', got '$env:RESOLVE_CREATE_RELEASE'" | |
| $failed = $true | |
| } | |
| if ([string]::IsNullOrEmpty($env:RESOLVE_VERSION)) { | |
| Write-Error "Version: expected non-empty, got empty" | |
| $failed = $true | |
| } | |
| if ($env:RESOLVE_RELEASE_TYPE -ne 'Release') { | |
| Write-Error "ReleaseType: expected 'Release', got '$env:RESOLVE_RELEASE_TYPE'" | |
| $failed = $true | |
| } | |
| if ($failed) { exit 1 } | |
| ActionTest-IgnoreLabel: | |
| name: Action-Test - [Ignore label] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Create fake PR event | |
| shell: pwsh | |
| run: | | |
| $event = @{ | |
| pull_request = @{ | |
| head = @{ ref = 'feat/test-ignore' } | |
| labels = @( | |
| @{ name = 'patch' } | |
| @{ name = 'skip-release' } | |
| ) | |
| } | |
| } | ConvertTo-Json -Depth 5 | |
| $event | Set-Content -Path "$env:RUNNER_TEMP/fake-event.json" | |
| "GITHUB_EVENT_PATH=$env:RUNNER_TEMP/fake-event.json" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Resolve-PSModuleVersion | |
| id: resolve | |
| uses: ./ | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| with: | |
| Settings: | | |
| { | |
| "Publish": { | |
| "Module": { | |
| "ReleaseType": "Release", | |
| "AutoPatching": false, | |
| "VersionPrefix": "v", | |
| "MajorLabels": "major", | |
| "MinorLabels": "minor", | |
| "PatchLabels": "patch", | |
| "IgnoreLabels": "skip-release" | |
| } | |
| } | |
| } | |
| EventPath: ${{ runner.temp }}/fake-event.json | |
| EventJson: '{"pull_request":{"head":{"ref":"feat/test-ignore"},"labels":[{"name":"patch"},{"name":"skip-release"}]}}' | |
| - name: Verify - Ignore label | |
| shell: pwsh | |
| env: | |
| RESOLVE_CREATE_RELEASE: ${{ steps.resolve.outputs.CreateRelease }} | |
| RESOLVE_RELEASE_TYPE: ${{ steps.resolve.outputs.ReleaseType }} | |
| run: | | |
| Write-Host '--- Input ---' | |
| Write-Host "EventJson: {\"pull_request\":{\"head\":{\"ref\":\"feat/test-ignore\"},\"labels\":[{\"name\":\"patch\"},{\"name\":\"skip-release\"}]}}" | |
| Write-Host "Settings: ReleaseType=Release, AutoPatching=false, IgnoreLabels=skip-release" | |
| Write-Host '' | |
| Write-Host '--- Expected vs Actual ---' | |
| Write-Host "CreateRelease: expected='false' actual='$env:RESOLVE_CREATE_RELEASE'" | |
| Write-Host "ReleaseType: expected='None' actual='$env:RESOLVE_RELEASE_TYPE'" | |
| Write-Host '' | |
| $failed = $false | |
| if ($env:RESOLVE_CREATE_RELEASE -ne 'false') { | |
| Write-Error "CreateRelease: expected 'false', got '$env:RESOLVE_CREATE_RELEASE'" | |
| $failed = $true | |
| } | |
| if ($env:RESOLVE_RELEASE_TYPE -ne 'None') { | |
| Write-Error "ReleaseType: expected 'None', got '$env:RESOLVE_RELEASE_TYPE'" | |
| $failed = $true | |
| } | |
| if ($failed) { exit 1 } | |
| ActionTest-None: | |
| name: Action-Test - [None release type] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Create fake PR event | |
| shell: pwsh | |
| run: | | |
| $event = @{ | |
| pull_request = @{ | |
| head = @{ ref = 'feat/test-none' } | |
| labels = @( | |
| @{ name = 'patch' } | |
| ) | |
| } | |
| } | ConvertTo-Json -Depth 5 | |
| $event | Set-Content -Path "$env:RUNNER_TEMP/event.json" | |
| "GITHUB_EVENT_PATH=$env:RUNNER_TEMP/event.json" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Resolve-PSModuleVersion | |
| id: resolve | |
| uses: ./ | |
| with: | |
| Settings: | | |
| { | |
| "Publish": { | |
| "Module": { | |
| "ReleaseType": "None", | |
| "AutoPatching": false, | |
| "VersionPrefix": "v", | |
| "MajorLabels": "major", | |
| "MinorLabels": "minor", | |
| "PatchLabels": "patch", | |
| "IgnoreLabels": "" | |
| } | |
| } | |
| } | |
| EventJson: '{"pull_request":{"head":{"ref":"feat/test-none"},"labels":[{"name":"patch"}]}}' | |
| - name: Verify - None release type | |
| shell: pwsh | |
| env: | |
| RESOLVE_CREATE_RELEASE: ${{ steps.resolve.outputs.CreateRelease }} | |
| RESOLVE_VERSION: ${{ steps.resolve.outputs.Version }} | |
| RESOLVE_RELEASE_TYPE: ${{ steps.resolve.outputs.ReleaseType }} | |
| run: | | |
| Write-Host '--- Input ---' | |
| Write-Host "EventJson: {\"pull_request\":{\"head\":{\"ref\":\"feat/test-none\"},\"labels\":[{\"name\":\"patch\"}]}}" | |
| Write-Host "Settings: ReleaseType=None, AutoPatching=false" | |
| Write-Host '' | |
| Write-Host '--- Expected vs Actual ---' | |
| Write-Host "CreateRelease: expected='false' actual='$env:RESOLVE_CREATE_RELEASE'" | |
| Write-Host "ReleaseType: expected='None' actual='$env:RESOLVE_RELEASE_TYPE'" | |
| Write-Host "Version: expected='' actual='$env:RESOLVE_VERSION'" | |
| Write-Host '' | |
| $failed = $false | |
| if ($env:RESOLVE_CREATE_RELEASE -ne 'false') { | |
| Write-Error "CreateRelease: expected 'false', got '$env:RESOLVE_CREATE_RELEASE'" | |
| $failed = $true | |
| } | |
| if (-not [string]::IsNullOrEmpty($env:RESOLVE_VERSION)) { | |
| Write-Error "Version: expected empty, got '$env:RESOLVE_VERSION'" | |
| $failed = $true | |
| } | |
| if ($env:RESOLVE_RELEASE_TYPE -ne 'None') { | |
| Write-Error "ReleaseType: expected 'None', got '$env:RESOLVE_RELEASE_TYPE'" | |
| $failed = $true | |
| } | |
| if ($failed) { exit 1 } |