@@ -73,6 +73,120 @@ jobs:
7373 ShowInit : true
7474 ShowRateLimit : true
7575
76+ ActionTestVersionExact :
77+ name : Version [Exact]
78+ # Version resolution is OS-independent, so these logic tests run once (on Linux) to keep CI lean.
79+ if : ${{ inputs.runs-on == 'ubuntu-latest' }}
80+ runs-on : ${{ inputs.runs-on }}
81+ steps :
82+ # Need to check out as part of the test, as its a local action
83+ - name : Checkout repo
84+ uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
85+ with :
86+ persist-credentials : false
87+ # A bare version must resolve to that EXACT version (not "minimum inclusive"), which
88+ # guarantees backward compatibility for callers that pin an exact version today.
89+ - name : Action-Test [exact version]
90+ uses : ./
91+ with :
92+ Version : ' 0.40.0'
93+ Prerelease : ${{ inputs.Prerelease }}
94+ ShowInit : true
95+ ShowRateLimit : true
96+ Script : |
97+ $loaded = (Get-Module -Name GitHub).Version
98+ if ("$loaded" -ne '0.40.0') {
99+ throw "Expected the GitHub module 0.40.0 to be loaded, but found '$loaded'."
100+ }
101+ Write-Host "OK: exact version resolved to $loaded"
102+
103+ ActionTestVersionRange :
104+ name : Version [Bounded range]
105+ if : ${{ inputs.runs-on == 'ubuntu-latest' }}
106+ runs-on : ${{ inputs.runs-on }}
107+ steps :
108+ # Need to check out as part of the test, as its a local action
109+ - name : Checkout repo
110+ uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
111+ with :
112+ persist-credentials : false
113+ # A bounded range must resolve to the highest satisfying version: [0.38.0, 0.40.0) -> 0.39.0.
114+ - name : Action-Test [bounded range]
115+ uses : ./
116+ with :
117+ Version : ' [0.38.0, 0.40.0)'
118+ Prerelease : ${{ inputs.Prerelease }}
119+ ShowInit : true
120+ ShowRateLimit : true
121+ Script : |
122+ $loaded = (Get-Module -Name GitHub).Version
123+ if ($loaded -ne [version]'0.39.0') {
124+ throw "Expected '[0.38.0, 0.40.0)' to resolve to 0.39.0, but found '$loaded'."
125+ }
126+ Write-Host "OK: bounded range resolved to $loaded"
127+
128+ ActionTestVersionMinimum :
129+ name : Version [Minimum range]
130+ if : ${{ inputs.runs-on == 'ubuntu-latest' }}
131+ runs-on : ${{ inputs.runs-on }}
132+ steps :
133+ # Need to check out as part of the test, as its a local action
134+ - name : Checkout repo
135+ uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
136+ with :
137+ persist-credentials : false
138+ # A minimum-inclusive range must resolve to a version >= the lower bound.
139+ - name : Action-Test [minimum range]
140+ uses : ./
141+ with :
142+ Version : ' [0.40.0, ]'
143+ Prerelease : ${{ inputs.Prerelease }}
144+ ShowInit : true
145+ ShowRateLimit : true
146+ Script : |
147+ $loaded = (Get-Module -Name GitHub).Version
148+ if ($loaded -lt [version]'0.40.0') {
149+ throw "Expected '[0.40.0, ]' to resolve to >= 0.40.0, but found '$loaded'."
150+ }
151+ Write-Host "OK: minimum range resolved to $loaded"
152+
153+ ActionTestVersionAlreadyInstalled :
154+ name : Version [Already installed]
155+ if : ${{ inputs.runs-on == 'ubuntu-latest' }}
156+ runs-on : ${{ inputs.runs-on }}
157+ steps :
158+ # Need to check out as part of the test, as its a local action
159+ - name : Checkout repo
160+ uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
161+ with :
162+ persist-credentials : false
163+ # Pre-install a version that satisfies the range requested below.
164+ - name : Pre-install GitHub 0.40.0
165+ shell : pwsh
166+ run : |
167+ Install-PSResource -Name GitHub -Version '0.40.0' -Repository PSGallery -TrustRepository -Reinstall
168+ # When an installed version already satisfies the requested range, the action must reuse it
169+ # and must not install another copy. The exact-string already-installed check never matches a
170+ # range, so it reinstalls the latest (leaving two installed versions); the range-aware check
171+ # keeps exactly one.
172+ - name : Action-Test [already-installed range]
173+ uses : ./
174+ with :
175+ Version : ' [0.40.0, ]'
176+ Prerelease : ${{ inputs.Prerelease }}
177+ ShowInit : true
178+ ShowRateLimit : true
179+ Script : |
180+ $installed = @(Get-InstalledPSResource -Name GitHub)
181+ $loaded = (Get-Module -Name GitHub).Version
182+ if ($installed.Count -ne 1) {
183+ throw "Expected exactly 1 installed GitHub version (satisfying version reused, no reinstall), but found $($installed.Count): $(($installed.Version) -join ', ')."
184+ }
185+ if ("$loaded" -ne '0.40.0') {
186+ throw "Expected the already-installed 0.40.0 to be reused, but found '$loaded'."
187+ }
188+ Write-Host "OK: already-installed satisfying version reused ($loaded)"
189+
76190 ActionTestWithScript :
77191 name : WithScript
78192 runs-on : ${{ inputs.runs-on }}
0 commit comments