diff --git a/.github/scripts/setup-system.ps1 b/.github/scripts/setup-system.ps1 index 99c8049e8..b2651a40c 100644 --- a/.github/scripts/setup-system.ps1 +++ b/.github/scripts/setup-system.ps1 @@ -1,12 +1,15 @@ +# Get ci parameter to check if running with ci +param( + [Parameter()] + [Switch]$ci +) + # Get temp folder $temp = [System.IO.Path]::GetTempPath() # Get current running dir $currentLocation = $((Get-Location).path) -$Host.UI.RawUI.WindowTitle = "Spacedrive DE Setup (Administrator)" -$Host.UI.RawUI.BackgroundColor = "Black" - # Check to see if a command exists (eg if an app is installed) Function CheckCommand { @@ -24,8 +27,6 @@ Function CheckCommand { } -Clear-Host - Write-Host "Spacedrive Development Environment Setup" -ForegroundColor Magenta Write-Host @" @@ -80,7 +81,7 @@ if ($pnpmCheck -eq $false) { #pnpm installer taken from https://pnpm.io Invoke-WebRequest https://get.pnpm.io/install.ps1 -useb | Invoke-Expression - # Reset the PATH env variables to make sure pnpm is accessible + # Reset the PATH env variables to make sure pnpm is accessible $env:PNPM_HOME = [System.Environment]::GetEnvironmentVariable("PNPM_HOME", "User") $env:Path = [System.Environment]::ExpandEnvironmentVariables([System.Environment]::GetEnvironmentVariable("Path", "User")) @@ -89,29 +90,47 @@ else { Write-Host "pnpm is installed." } -Write-Host -Write-Host "Using pnpm to install the latest version of Node..." -ForegroundColor Yellow -Write-Host "This will set your global Node version to the latest!" -Start-Sleep -Milliseconds 150 +# A GitHub Action takes care of installing node, so this isn't necessary if running in the ci. +if ($ci -eq $True) { + Write-Host + Write-Host "Running with Ci, skipping Node install." -ForegroundColor Yellow +} +else { + Write-Host + Write-Host "Using pnpm to install the latest version of Node..." -ForegroundColor Yellow + Write-Host "This will set your global Node version to the latest!" + Start-Sleep -Milliseconds 150 -# Runs the pnpm command to use the latest version of node, which also installs it -Start-Process -Wait -FilePath "pnpm" -ArgumentList "env use --global latest" -PassThru -Verb runAs + # Runs the pnpm command to use the latest version of node, which also installs it + Start-Process -Wait -FilePath "pnpm" -ArgumentList "env use --global latest" -PassThru -Verb runAs +} -Write-Host -Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow -# Downloads latest installer for LLVM -$filenamePattern = "*-win64.exe" -$releasesUri = "https://api.github.com/repos/llvm/llvm-project/releases/latest" -$downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url -Start-BitsTransfer -Source $downloadUri -Destination "$temp\llvm.exe" -Write-Host -Write-Host "Running the LLVM installer..." -ForegroundColor Yellow -Write-Host "Please follow the instructions to install LLVM." -Write-Host "Ensure you add LLVM to your PATH." +# We can't run the installer if running in ci, so we install LLVM through a GitHub Action instead. +if ($ci -eq $True) { + Write-Host + Write-Host "Running with Ci, skipping LLVM install." -ForegroundColor Yellow +} +else { + Write-Host + Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow + # Downloads latest installer for LLVM + $filenamePattern = "*-win64.exe" + $releasesUri = "https://api.github.com/repos/llvm/llvm-project/releases/latest" + $downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url + + Start-BitsTransfer -Source $downloadUri -Destination "$temp\llvm.exe" + + Write-Host + Write-Host "Running the LLVM installer..." -ForegroundColor Yellow + Write-Host "Please follow the instructions to install LLVM." + Write-Host "Ensure you add LLVM to your PATH." + + Start-Process "$temp\llvm.exe" -Wait +} + -Start-Process "$temp\llvm.exe" -Wait Write-Host Write-Host "Downloading the latest ffmpeg build..." -ForegroundColor Yellow diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 013354f45..d78582456 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: id: pnpm-cache run: | echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" - + - uses: actions/cache@v3 name: Setup pnpm cache with: @@ -44,7 +44,7 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - + - name: Install pnpm dependencies run: pnpm --frozen-lockfile i @@ -81,7 +81,7 @@ jobs: with: version: 7 run_install: false - + - name: Install Rust stable uses: actions-rs/toolchain@v1 with: @@ -89,19 +89,25 @@ jobs: profile: minimal override: true components: rustfmt, rust-src - + - name: Cache Rust Dependencies uses: Swatinem/rust-cache@v1 with: sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }} + - name: Install LLVM and Clang + if: matrix.platform == 'windows-latest' + uses: KyleMayes/install-llvm-action@v1 + with: + version: '14' + - name: Run 'setup-system.sh' script if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest' run: ./.github/scripts/setup-system.sh - + - name: Run 'setup-system.ps1' script if: matrix.platform == 'windows-latest' - run: ./.github/scripts/setup-system.ps1 + run: ./.github/scripts/setup-system.ps1 -ci - name: Get pnpm store directory id: pnpm-cache @@ -116,7 +122,7 @@ jobs: ${{ runner.os }}-pnpm-store- - name: Install pnpm dependencies run: pnpm --frozen-lockfile i - + - name: Cache Prisma codegen id: cache-prisma uses: actions/cache@v3