[Tests] appveyor -> GHA (run tests on Windows in both pwsh and WSL + Ubuntu) #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Native and WSL | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: ${{ matrix.configuration == 'wsl' && 'wsl-bash {0}' || 'pwsh' }} | |
strategy: | |
matrix: | |
os: [windows-2019] | |
node-version: [18, 16, 14, 12, 10, 8, 6, 4] | |
configuration: [wsl, native] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Vampire/setup-wsl@v3 | |
if: matrix.configuration == 'wsl' | |
with: | |
distribution: Ubuntu-22.04 | |
- name: Do everything here because npm is not found when running in separate steps | |
if: matrix.configuration == 'wsl' | |
run: | | |
curl --version | |
export ESLINT_VERSION=7 | |
export TRAVIS_NODE_VERSION=${{ matrix.node-version }} | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
nvm install ${{ matrix.node-version }} | |
nvm use ${{ matrix.node-version }} | |
nvm install-latest-npm | |
if [ ${{ matrix.node-version }} -ge 4 -a ${{ matrix.node-version }} -lt 6 ]; then | |
npm install eslint@4 --no-save --ignore-scripts | |
npm install | |
npm install eslint-import-resolver-typescript@1.0.2 --no-save | |
npm uninstall @angular-eslint/template-parser --no-save | |
npm uninstall @typescript-eslint/parser --no-save | |
fi | |
if [ ${{ matrix.node-version }} -ge 6 -a ${{ matrix.node-version }} -lt 7 ]; then | |
npm install eslint@5 --no-save --ignore-scripts | |
npm install | |
npm install eslint-import-resolver-typescript@1.0.2 --no-save | |
npm uninstall @angular-eslint/template-parser --no-save | |
npm install @typescript-eslint/parser@3 --no-save | |
fi | |
if [ ${{ matrix.node-version }} -ge 7 -a ${{ matrix.node-version }} -lt 8 ]; then | |
npm install eslint@6 --no-save --ignore-scripts | |
npm install | |
npm install eslint-import-resolver-typescript@1.0.2 --no-save | |
npm uninstall @angular-eslint/template-parser --no-save | |
npm install typescript-eslint-parser@20 --no-save | |
fi | |
if [ ${{ matrix.node-version }} -eq 8 ]; then | |
npm install eslint@6 --no-save --ignore-scripts | |
npm install | |
npm uninstall @angular-eslint/template-parser --no-save | |
npm install @typescript-eslint/parser@3 --no-save | |
fi | |
if [ ${{ matrix.node-version }} -gt 8 -a ${{ matrix.node-version }} -lt 10 ]; then | |
npm install eslint@7 --no-save --ignore-scripts | |
npm install | |
npm install @typescript-eslint/parser@3 --no-save | |
fi | |
if [ ${{ matrix.node-version }} -ge 10 -a ${{ matrix.node-version }} -lt 12 ]; then | |
npm install | |
npm install @typescript-eslint/parser@4 --no-save | |
fi | |
if [ ${{ matrix.node-version }} -ge 12 ]; then | |
npm install | |
fi | |
npm run copy-metafiles | |
npm run pretest | |
npm run tests-only | |
- name: Install dependencies for Node <= 10 | |
if: matrix.node-version <= '10' && matrix.configuration == 'native' | |
run: | | |
npm install --legacy-peer-deps | |
npm install eslint@7 --no-save | |
- name: Install dependencies for Node > 10 | |
if: matrix.node-version > '10' && matrix.configuration == 'native' | |
run: npm install | |
- name: Install the latest version of nyc | |
if: matrix.configuration == 'native' | |
run: npm install nyc@latest --no-save | |
- name: Copy metafiles for Node <= 8 | |
if: matrix.node-version <= 8 && matrix.configuration == 'native' | |
env: | |
ESLINT_VERSION: 6 | |
TRAVIS_NODE_VERSION: ${{ matrix.node-version }} | |
run: | | |
npm run copy-metafiles | |
bash ./tests/dep-time-travel.sh 2>&1 | |
- name: Copy metafiles for Node > 8 | |
if: matrix.node-version > 8 && matrix.configuration == 'native' | |
env: | |
ESLINT_VERSION: 7 | |
TRAVIS_NODE_VERSION: ${{ matrix.node-version }} | |
run: | | |
npm run copy-metafiles | |
bash ./tests/dep-time-travel.sh 2>&1 | |
- name: Config git to allow symlinks | |
if: matrix.configuration == 'native' | |
run: | | |
git config core.symlinks true | |
git reset --hard | |
- name: Install ./resolver dependencies in Native | |
if: matrix.configuration == 'native' | |
shell: pwsh | |
run: | | |
npm config set package-lock false | |
$resolverDir = "./resolvers" | |
Get-ChildItem -Directory $resolverDir | | |
ForEach { | |
Write-output $(Resolve-Path $(Join-Path $resolverDir $_.Name)) | |
Push-Location $(Resolve-Path $(Join-Path $resolverDir $_.Name)) | |
npm install | |
npm ls nyc > $null; | |
if ($?) { | |
npm install nyc@latest --no-save | |
} | |
Pop-Location | |
} | |
npm config set package-lock true | |
- name: Run tests in Native | |
if: matrix.configuration == 'native' | |
shell: pwsh | |
run: | | |
npm run pretest | |
npm run tests-only | |
$resolverDir = "./resolvers"; | |
$resolvers = @(); | |
Get-ChildItem -Directory $resolverDir | | |
ForEach { | |
$resolvers += "$(Resolve-Path $(Join-Path $resolverDir $_.Name))"; | |
} | |
$env:RESOLVERS = [string]::Join(";", $resolvers); | |
foreach ($resolver in $resolvers) { | |
Set-Location -Path $resolver.Trim('"') | |
npm test | |
Set-Location -Path $PSScriptRoot | |
} | |
- name: Upload Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos | |
file: ./coverage/coverage-final.json # optional | |
flags: unittests # optional | |
name: codecov-umbrella # optional | |
fail_ci_if_error: true # optional (default = false) |