Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
pull_request:
workflow_dispatch:

permissions: {}

jobs:
unit_test:
name: Unit Test
Expand All @@ -21,6 +23,7 @@ jobs:
with:
# Need at least 2 commits to properly gather changed files for linting
fetch-depth: 2
persist-credentials: false
- name: Install and cache test dependencies
uses: potatoqualitee/psmodulecache@ee5e9494714abf56f6efbfa51527b2aec5c761b8 # v6.2.1
with:
Expand All @@ -40,5 +43,25 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Run tests
run: ./.github/scripts/e2e-test.ps1
ci_iex:
name: CI IEX Simulation
runs-on: windows-latest
strategy:
matrix:
shell: [powershell, pwsh]
defaults:
run:
shell: ${{ matrix.shell }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
with:
persist-credentials: false
- name: Run
run: |
Get-Content -Raw -Path ./install.ps1 | Invoke-Expression
scoop help
35 changes: 34 additions & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,34 @@ function Write-DebugInfo {
Write-Verbose "SCOOP_CONFIG_HOME: $SCOOP_CONFIG_HOME"
}

function Test-ShouldRunInstall {
param(
[Parameter(Mandatory = $True)]
[String] $InvocationName
)

# not dot-sourced, run the install flow
if ($InvocationName -ne '.') {
return $true
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

# dot-sourced, but not in CI, don't run the install flow
if (-not $env:CI) {
return $false
}

# dot-sourced, in CI, determined by env SCOOP_NOINSTALL
$should = $true
if ($null -ne $env:SCOOP_NOINSTALL) {
$value = $env:SCOOP_NOINSTALL.ToString().Trim().ToLowerInvariant()
if ($value -in @('1', 'true', 'yes', 'on')) {
$should = $false
}
}

return $should
}

# Prepare variables
$IS_EXECUTED_FROM_IEX = ($null -eq $MyInvocation.MyCommand.Path)

Expand Down Expand Up @@ -742,7 +770,12 @@ $SCOOP_MAIN_BUCKET_GIT_REPO = 'https://github.com/ScoopInstaller/Main.git'
# not when dot-sourced. Dot-sourcing the installer will not trigger the
# installation, and only the functions will be loaded, e.g., for testing.
# Downstreams can call `Install-Scoop` explicitly to start the installation.
if ($MyInvocation.InvocationName -ne '.') {
# In CI, dot-sourced execution is allowed by default as GitHub Actions executors
# run the job step in a dot-sourced session. To disable the install flow in CI,
# set `SCOOP_NOINSTALL=true` to force dot-sourced CI sessions to only
# load functions.
$shouldRunInstall = Test-ShouldRunInstall -InvocationName $MyInvocation.InvocationName
if ($shouldRunInstall) {
$oldErrorActionPreference = $ErrorActionPreference
try {
$ErrorActionPreference = 'Stop'
Expand Down
8 changes: 8 additions & 0 deletions test/install.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
BeforeAll {
$script:OriginalScoop = $env:SCOOP
$script:OriginalScoopGlobal = $env:SCOOP_GLOBAL
$script:OriginalScoopNoInstall = $env:SCOOP_NOINSTALL

$env:SCOOP = Join-Path $TestDrive 'scoop'
$env:SCOOP_GLOBAL = Join-Path $TestDrive 'scoop-global'
$env:SCOOP_NOINSTALL = 'true'

# Load SUT
$sut = (Split-Path -Leaf $PSCommandPath).Replace('.Tests.ps1', '.ps1')
Expand All @@ -22,6 +24,12 @@ AfterAll {
} else {
$env:SCOOP_GLOBAL = $script:OriginalScoopGlobal
}

if ($null -eq $script:OriginalScoopNoInstall) {
Remove-Item Env:SCOOP_NOINSTALL -ErrorAction SilentlyContinue
} else {
$env:SCOOP_NOINSTALL = $script:OriginalScoopNoInstall
}
}

Describe 'Get-Downloader' -Tag 'Proxy' {
Expand Down
Loading