From fa60e3d738078fa2fccbc36260b9da534795f720 Mon Sep 17 00:00:00 2001 From: Joey Guerra Date: Tue, 19 Mar 2024 17:33:40 -0500 Subject: [PATCH] [Tests] appveyor -> GHA (run tests on Windows in both pwsh and WSL + Ubuntu) --- .github/workflows/native-wsl.yml | 151 ++++++++++++++++++++++++++++ CHANGELOG.md | 3 + appveyor.yml | 165 ------------------------------- 3 files changed, 154 insertions(+), 165 deletions(-) create mode 100644 .github/workflows/native-wsl.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/native-wsl.yml b/.github/workflows/native-wsl.yml new file mode 100644 index 000000000..893d2248d --- /dev/null +++ b/.github/workflows/native-wsl.yml @@ -0,0 +1,151 @@ +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: + fail-fast: false + 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 + - run: curl --version + - name: 'WSL: do all npm install steps' + if: matrix.configuration == 'wsl' + env: + ESLINT_VERSION: 7 + TRAVIS_NODE_VERSION: ${{ matrix.node-version }} + run: | + 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 + nvm install --latest-npm ${{ matrix.node-version }} + + if [ ${{ matrix.node-version }} -ge 4 ] && [ ${{ 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 @typescript-eslint/parser --no-save + fi + if [ ${{ matrix.node-version }} -ge 6 ] && [ ${{ matrix.node-version }} -lt 7 ]; then + npm install eslint@5 --no-save --ignore-scripts + npm install + npm uninstall @angular-eslint/template-parser --no-save + npm install eslint-import-resolver-typescript@1.0.2 @typescript-eslint/parser@3 --no-save + fi + if [ ${{ matrix.node-version }} -ge 7 ] && [ ${{ 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 typescript-eslint-parser@20 --no-save + npm uninstall @angular-eslint/template-parser --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 ] && [ ${{ 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 ] && [ ${{ 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: 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 + } + + - 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 run tests-only + Set-Location -Path $PSScriptRoot + } + + - name: codecov + uses: codecov/codecov-action@v3.1.5 + + windows: + runs-on: ubuntu-latest + needs: [build] + steps: + - run: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c908dc3..f8a6f80d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange - [Refactor] `ExportMap`: make procedures static instead of monkeypatching exportmap ([#2982], thanks [@soryy708]) - [Refactor] `ExportMap`: separate ExportMap instance from its builder logic ([#2985], thanks [@soryy708]) - [Docs] `order`: Add a quick note on how unbound imports and --fix ([#2640], thanks [@minervabot]) +- [Tests] appveyor -> GHA (run tests on Windows in both pwsh and WSL + Ubuntu) ([#2987], thanks [@joeyguerra]) ## [2.29.1] - 2023-12-14 @@ -1111,6 +1112,7 @@ for info on changes for earlier releases. [`memo-parser`]: ./memo-parser/README.md +[#2987]: https://github.com/import-js/eslint-plugin-import/pull/2987 [#2985]: https://github.com/import-js/eslint-plugin-import/pull/2985 [#2982]: https://github.com/import-js/eslint-plugin-import/pull/2982 [#2944]: https://github.com/import-js/eslint-plugin-import/pull/2944 @@ -1791,6 +1793,7 @@ for info on changes for earlier releases. [@jkimbo]: https://github.com/jkimbo [@joaovieira]: https://github.com/joaovieira [@joe-matsec]: https://github.com/joe-matsec +[@joeyguerra]: https://github.com/joeyguerra [@johndevedu]: https://github.com/johndevedu [@johnthagen]: https://github.com/johnthagen [@jonboiser]: https://github.com/jonboiser diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index e50ab87d2..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,165 +0,0 @@ -configuration: - - Native - - WSL - -# Test against this version of Node.js -environment: - matrix: - - nodejs_version: "16" - - nodejs_version: "14" - - nodejs_version: "12" - - nodejs_version: "10" - - nodejs_version: "8" - # - nodejs_version: "6" - # - nodejs_version: "4" - -image: Visual Studio 2019 -matrix: - fast_finish: false - exclude: - - configuration: WSL - nodejs_version: "8" - - configuration: WSL - nodejs_version: "6" - - configuration: WSL - nodejs_version: "4" - - allow_failures: - - nodejs_version: "4" # for eslint 5 - - configuration: WSL - -platform: - - x86 - - x64 - -# 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")) { - $env:NPM_VERSION="6" - } - if ($env:nodejs_version -in @("10", "12", "14", "16")) { - $env:NPM_VERSION="6" # TODO: use npm 7 - $env:NPM_CONFIG_LEGACY_PEER_DEPS="true" - } - - ps: >- - $env:ESLINT_VERSION="7"; - if ([int]$env:nodejs_version -le 8) { - $env:ESLINT_VERSION="6" - } - if ([int]$env:nodejs_version -le 7) { - $env:ESLINT_VERSION="5" - } - if ([int]$env:nodejs_version -le 6) { - $env:ESLINT_VERSION="4" - } - - ps: $env:WINDOWS_NYC_VERSION = "15.0.1" - - ps: $env:TRAVIS_NODE_VERSION = $env:nodejs_version - - # 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 - - ci npm run copy-metafiles - - bash ./tests/dep-time-travel.sh 2>&1 - - # 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 $_))"; - } - $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 ) - -# 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 ) - # TODO: enable codecov for native windows builds - #on_success: - #- ci $ProgressPreference = 'SilentlyContinue' - #- ci Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe - #- ci -Outfile codecov.exe - #- ci .\codecov.exe - - 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 - on_success: - - ci curl -Os https://uploader.codecov.io/latest/linux/codecov - - ci chmod +x codecov - - ci ./codecov - -build: on