Skip to content

Commit e1ed323

Browse files
manuthljharb
authored andcommitted
[Tests] Improve AppVeyor Configuration
1 parent 9dfef28 commit e1ed323

File tree

3 files changed

+130
-115
lines changed

3 files changed

+130
-115
lines changed

appveyor.yml

+110-115
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ configuration:
55
# Test against this version of Node.js
66
environment:
77
matrix:
8-
- nodejs_version: "14"
9-
- nodejs_version: "12"
10-
- nodejs_version: "10"
11-
- nodejs_version: "8"
8+
- nodejs_version: "14"
9+
- nodejs_version: "12"
10+
- nodejs_version: "10"
11+
- nodejs_version: "8"
1212
# - nodejs_version: "6"
1313
# - nodejs_version: "4"
1414

@@ -26,118 +26,113 @@ matrix:
2626
# - x86
2727
# - x64
2828

29-
for:
30-
-
31-
matrix:
32-
only:
33-
- configuration: Native
34-
# Install scripts. (runs after repo cloning)
35-
install:
36-
# Get the latest stable version of Node.js or io.js
37-
- ps: Install-Product node $env:nodejs_version
38-
39-
# install modules
40-
- ps: >-
41-
if ($env:nodejs_version -eq "4") {
42-
cmd /c npm install -g npm@3;
43-
}
44-
if ($env:nodejs_version -in @("8", "10", "12")) {
45-
cmd /c npm install -g [email protected];
29+
# Initialization scripts. (runs before repo cloning)
30+
init:
31+
# Declare version-numbers of packages to install
32+
- ps: >-
33+
if ($env:nodejs_version -eq "4") {
34+
$env:NPM_VERSION="3"
35+
}
36+
if ($env:nodejs_version -in @("8", "10", "12")) {
37+
$env:NPM_VERSION="6.14.5"
38+
}
39+
- ps: >-
40+
if ([int]$env:nodejs_version -le 8) {
41+
$env:ESLINT_VERSION="6"
42+
}
43+
- ps: $env:WINDOWS_NYC_VERSION = "15.0.1"
44+
45+
# Add `ci`-command to `PATH` for running commands either using cmd or wsl depending on the configuration
46+
- ps: $env:PATH += ";$(Join-Path $(pwd) "scripts")"
47+
48+
# Install scripts. (runs after repo cloning)
49+
before_build:
50+
# Install propert `npm`-version
51+
- IF DEFINED NPM_VERSION ci sudo npm install -g npm@%NPM_VERSION%
52+
53+
# Install dependencies
54+
- ci npm install
55+
56+
# fix symlinks
57+
- git config core.symlinks true
58+
- git reset --hard
59+
- ci git reset --hard
60+
61+
# Install dependencies of resolvers
62+
- ps: >-
63+
$resolverDir = "./resolvers";
64+
$resolvers = @();
65+
Get-ChildItem -Directory $resolverDir |
66+
ForEach {
67+
$resolvers += "$(Resolve-Path $(Join-Path $resolverDir $_))";
4668
}
47-
- npm install
48-
49-
- ps: >-
50-
if ([int]$env:nodejs_version -le 8) {
51-
cmd /c npm i eslint@6 2`>`&1;
52-
}
53-
54-
# fix symlinks
55-
- git config core.symlinks true
56-
- git reset --hard
57-
58-
# todo: learn how to do this for all .\resolvers\* on Windows
59-
- cd .\resolvers\webpack && npm install && cd ..\..
60-
- cd .\resolvers\node && npm install && cd ..\..
61-
62-
# Upgrade nyc
63-
- npm i --no-save [email protected]
64-
- ps: >-
65-
$resolverDir = "./resolvers";
66-
Get-ChildItem -Directory $resolverDir |
67-
ForEach-Object {
68-
Push-Location $(Resolve-Path $(Join-Path $resolverDir $_));
69-
cmd /c npm ls nyc 2`>`&1;
70-
if ($?) {
71-
cmd /c npm i --no-save [email protected] 2`>`&1;
72-
}
73-
Pop-Location;
69+
$env:RESOLVERS = [string]::Join(";", $resolvers);
70+
- FOR %%G in ("%RESOLVERS:;=";"%") do ( pushd %%~G & ci npm install & popd )
71+
72+
# Install proper `eslint`-version
73+
- IF DEFINED ESLINT_VERSION ci npm install --no-save eslint@%ESLINT_VERSION%
74+
75+
# Build scripts (project isn't actually built)
76+
build_script:
77+
- ps: "# This Project isn't actually built"
78+
79+
# Test scripts
80+
test_script:
81+
# Output useful info for debugging.
82+
- ci node --version
83+
- ci npm --version
84+
85+
# Run core tests
86+
- ci npm run pretest
87+
- ci npm run tests-only
88+
89+
# Run resolver tests
90+
- ps: >-
91+
$resolverDir = "./resolvers";
92+
$resolvers = @();
93+
Get-ChildItem -Directory $resolverDir |
94+
ForEach {
95+
$resolvers += "$(Resolve-Path $(Join-Path $resolverDir $_))";
7496
}
97+
$env:RESOLVERS = [string]::Join(";", $resolvers);
98+
- FOR %%G in ("%RESOLVERS:;=";"%") do ( pushd %%~G & ci npm test & popd )
7599

76-
# Post-install test scripts.
77-
test_script:
100+
on_success:
101+
- ci npm run coveralls
78102

79-
# Output useful info for debugging.
80-
- node --version
81-
- npm --version
82-
83-
# core tests
84-
- npm run pretest
85-
- npm run tests-only
86-
87-
# resolver tests
88-
- cd .\resolvers\webpack && npm test && cd ..\..
89-
- cd .\resolvers\node && npm test && cd ..\..
90-
91-
on_success:
92-
- npm run coveralls
93-
-
94-
matrix:
95-
only:
96-
- configuration: WSL
97-
# Install scripts. (runs after repo cloning)
98-
install:
99-
# Get the latest stable version of Node.js or io.js
100-
- ps: $env:WSLENV += ":nodejs_version"
101-
- ps: wsl curl -sL 'https://deb.nodesource.com/setup_${nodejs_version}.x' `| sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 -E bash -
102-
- wsl sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs
103-
104-
# install modules
105-
- ps: >-
106-
if ($env:nodejs_version -eq "4") {
107-
wsl sudo npm install -g npm@3;
108-
}
109-
if ($env:nodejs_version -in @("8", "10", "12")) {
110-
wsl sudo npm install -g [email protected];
111-
}
112-
- wsl npm install
113-
114-
# fix symlinks
115-
- git config core.symlinks true
116-
- git reset --hard
117-
# reset new-line characters
118-
- wsl git reset --hard
119-
120-
# todo: learn how to do this for all .\resolvers\* on Windows
121-
- cd .\resolvers\webpack && wsl npm install && cd ..\..
122-
- cd .\resolvers\node && wsl npm install && cd ..\..
123-
124-
# Post-install test scripts.
125-
test_script:
126-
127-
# Output useful info for debugging.
128-
- wsl node --version
129-
- wsl npm --version
130-
131-
# core tests
132-
- wsl npm run pretest
133-
- wsl npm run tests-only
134-
135-
# resolver tests
136-
- cd .\resolvers\webpack && wsl npm test && cd ..\..
137-
- cd .\resolvers\node && wsl npm test && cd ..\..
138-
139-
on_success:
140-
- wsl npm run coveralls
141-
142-
# Don't actually build.
143-
build: off
103+
# Configuration-specific steps
104+
for:
105+
- matrix:
106+
except:
107+
- configuration: WSL
108+
install:
109+
# Get the latest stable version of Node.js or io.js
110+
- ps: Install-Product node $env:nodejs_version
111+
before_test:
112+
# Upgrade nyc
113+
- ci npm i --no-save nyc@%WINDOWS_NYC_VERSION%
114+
- ps: >-
115+
$resolverDir = "./resolvers";
116+
$resolvers = @();
117+
Get-ChildItem -Directory $resolverDir |
118+
ForEach {
119+
Push-Location $(Resolve-Path $(Join-Path $resolverDir $_));
120+
ci npm ls nyc > $null;
121+
if ($?) {
122+
$resolvers += "$(pwd)";
123+
}
124+
Pop-Location;
125+
}
126+
$env:RESOLVERS = [string]::Join(";", $resolvers);
127+
- IF DEFINED RESOLVERS FOR %%G in ("%RESOLVERS:;=";"%") do ( pushd %%~G & ci npm install --no-save nyc@%WINDOWS_NYC_VERSION% & popd )
128+
- matrix:
129+
only:
130+
- configuration: WSL
131+
# Install scripts. (runs after repo cloning)
132+
install:
133+
# Get a specific version of Node.js
134+
- ps: $env:WSLENV += ":nodejs_version"
135+
- ps: wsl curl -sL 'https://deb.nodesource.com/setup_${nodejs_version}.x' `| sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 -E bash -
136+
- wsl sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs
137+
138+
build: on

scripts/GetCI/GetCI.psm1

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function Get-CICommand {
2+
$arguments = [System.Collections.ArrayList]$args
3+
if ($env:CONFIGURATION -eq "WSL") {
4+
$arguments.Insert(0, "wsl");
5+
} else {
6+
if ($arguments[0] -eq "sudo") {
7+
$arguments.RemoveAt(0)
8+
}
9+
}
10+
$arguments.Insert(0, "echo");
11+
cmd /c $arguments[0] $arguments[1..$($arguments.Count - 1)];
12+
}

scripts/ci.cmd

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
3+
FOR /F "tokens=* usebackq" %%F IN (`powershell -Command "& { Import-Module %~dp0GetCI; Get-CICommand %* }"`) DO (
4+
SET args=%%F
5+
)
6+
7+
echo ^> cmd /c %args%
8+
cmd /c %args%

0 commit comments

Comments
 (0)