Skip to content

Commit

Permalink
[Tests] Improve AppVeyor Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
manuth authored and ljharb committed Jun 2, 2020
1 parent 9dfef28 commit e1ed323
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 115 deletions.
225 changes: 110 additions & 115 deletions appveyor.yml
Expand Up @@ -5,10 +5,10 @@ configuration:
# Test against this version of Node.js
environment:
matrix:
- nodejs_version: "14"
- nodejs_version: "12"
- nodejs_version: "10"
- nodejs_version: "8"
- nodejs_version: "14"
- nodejs_version: "12"
- nodejs_version: "10"
- nodejs_version: "8"
# - nodejs_version: "6"
# - nodejs_version: "4"

Expand All @@ -26,118 +26,113 @@ matrix:
# - x86
# - x64

for:
-
matrix:
only:
- configuration: Native
# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version

# install modules
- ps: >-
if ($env:nodejs_version -eq "4") {
cmd /c npm install -g npm@3;
}
if ($env:nodejs_version -in @("8", "10", "12")) {
cmd /c npm install -g npm@6.14.5;
# Initialization scripts. (runs before repo cloning)
init:
# Declare version-numbers of packages to install
- ps: >-
if ($env:nodejs_version -eq "4") {
$env:NPM_VERSION="3"
}
if ($env:nodejs_version -in @("8", "10", "12")) {
$env:NPM_VERSION="6.14.5"
}
- ps: >-
if ([int]$env:nodejs_version -le 8) {
$env:ESLINT_VERSION="6"
}
- ps: $env:WINDOWS_NYC_VERSION = "15.0.1"

# Add `ci`-command to `PATH` for running commands either using cmd or wsl depending on the configuration
- ps: $env:PATH += ";$(Join-Path $(pwd) "scripts")"

# Install scripts. (runs after repo cloning)
before_build:
# Install propert `npm`-version
- IF DEFINED NPM_VERSION ci sudo npm install -g npm@%NPM_VERSION%

# Install dependencies
- ci npm install

# fix symlinks
- git config core.symlinks true
- git reset --hard
- ci git reset --hard

# Install dependencies of resolvers
- ps: >-
$resolverDir = "./resolvers";
$resolvers = @();
Get-ChildItem -Directory $resolverDir |
ForEach {
$resolvers += "$(Resolve-Path $(Join-Path $resolverDir $_))";
}
- npm install

- ps: >-
if ([int]$env:nodejs_version -le 8) {
cmd /c npm i eslint@6 2`>`&1;
}
# fix symlinks
- git config core.symlinks true
- git reset --hard

# todo: learn how to do this for all .\resolvers\* on Windows
- cd .\resolvers\webpack && npm install && cd ..\..
- cd .\resolvers\node && npm install && cd ..\..

# Upgrade nyc
- npm i --no-save nyc@15.0.1
- ps: >-
$resolverDir = "./resolvers";
Get-ChildItem -Directory $resolverDir |
ForEach-Object {
Push-Location $(Resolve-Path $(Join-Path $resolverDir $_));
cmd /c npm ls nyc 2`>`&1;
if ($?) {
cmd /c npm i --no-save nyc@15.0.1 2`>`&1;
}
Pop-Location;
$env:RESOLVERS = [string]::Join(";", $resolvers);
- FOR %%G in ("%RESOLVERS:;=";"%") do ( pushd %%~G & ci npm install & popd )

# Install proper `eslint`-version
- IF DEFINED ESLINT_VERSION ci npm install --no-save eslint@%ESLINT_VERSION%

# Build scripts (project isn't actually built)
build_script:
- ps: "# This Project isn't actually built"

# Test scripts
test_script:
# Output useful info for debugging.
- ci node --version
- ci npm --version

# Run core tests
- ci npm run pretest
- ci npm run tests-only

# Run resolver tests
- ps: >-
$resolverDir = "./resolvers";
$resolvers = @();
Get-ChildItem -Directory $resolverDir |
ForEach {
$resolvers += "$(Resolve-Path $(Join-Path $resolverDir $_))";
}
$env:RESOLVERS = [string]::Join(";", $resolvers);
- FOR %%G in ("%RESOLVERS:;=";"%") do ( pushd %%~G & ci npm test & popd )

# Post-install test scripts.
test_script:
on_success:
- ci npm run coveralls

# Output useful info for debugging.
- node --version
- npm --version

# core tests
- npm run pretest
- npm run tests-only

# resolver tests
- cd .\resolvers\webpack && npm test && cd ..\..
- cd .\resolvers\node && npm test && cd ..\..

on_success:
- npm run coveralls
-
matrix:
only:
- configuration: WSL
# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: $env:WSLENV += ":nodejs_version"
- ps: wsl curl -sL 'https://deb.nodesource.com/setup_${nodejs_version}.x' `| sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 -E bash -
- wsl sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs

# install modules
- ps: >-
if ($env:nodejs_version -eq "4") {
wsl sudo npm install -g npm@3;
}
if ($env:nodejs_version -in @("8", "10", "12")) {
wsl sudo npm install -g npm@6.10.3;
}
- wsl npm install

# fix symlinks
- git config core.symlinks true
- git reset --hard
# reset new-line characters
- wsl git reset --hard

# todo: learn how to do this for all .\resolvers\* on Windows
- cd .\resolvers\webpack && wsl npm install && cd ..\..
- cd .\resolvers\node && wsl npm install && cd ..\..

# Post-install test scripts.
test_script:

# Output useful info for debugging.
- wsl node --version
- wsl npm --version

# core tests
- wsl npm run pretest
- wsl npm run tests-only

# resolver tests
- cd .\resolvers\webpack && wsl npm test && cd ..\..
- cd .\resolvers\node && wsl npm test && cd ..\..

on_success:
- wsl npm run coveralls

# Don't actually build.
build: off
# Configuration-specific steps
for:
- matrix:
except:
- configuration: WSL
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
before_test:
# Upgrade nyc
- ci npm i --no-save nyc@%WINDOWS_NYC_VERSION%
- ps: >-
$resolverDir = "./resolvers";
$resolvers = @();
Get-ChildItem -Directory $resolverDir |
ForEach {
Push-Location $(Resolve-Path $(Join-Path $resolverDir $_));
ci npm ls nyc > $null;
if ($?) {
$resolvers += "$(pwd)";
}
Pop-Location;
}
$env:RESOLVERS = [string]::Join(";", $resolvers);
- IF DEFINED RESOLVERS FOR %%G in ("%RESOLVERS:;=";"%") do ( pushd %%~G & ci npm install --no-save nyc@%WINDOWS_NYC_VERSION% & popd )
- matrix:
only:
- configuration: WSL
# Install scripts. (runs after repo cloning)
install:
# Get a specific version of Node.js
- ps: $env:WSLENV += ":nodejs_version"
- ps: wsl curl -sL 'https://deb.nodesource.com/setup_${nodejs_version}.x' `| sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 -E bash -
- wsl sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs

build: on
12 changes: 12 additions & 0 deletions scripts/GetCI/GetCI.psm1
@@ -0,0 +1,12 @@
function Get-CICommand {
$arguments = [System.Collections.ArrayList]$args
if ($env:CONFIGURATION -eq "WSL") {
$arguments.Insert(0, "wsl");
} else {
if ($arguments[0] -eq "sudo") {
$arguments.RemoveAt(0)
}
}
$arguments.Insert(0, "echo");
cmd /c $arguments[0] $arguments[1..$($arguments.Count - 1)];
}
8 changes: 8 additions & 0 deletions scripts/ci.cmd
@@ -0,0 +1,8 @@
@echo off

FOR /F "tokens=* usebackq" %%F IN (`powershell -Command "& { Import-Module %~dp0GetCI; Get-CICommand %* }"`) DO (
SET args=%%F
)

echo ^> cmd /c %args%
cmd /c %args%

0 comments on commit e1ed323

Please sign in to comment.