From d1176d7c49818d77759d0c0a2fb40b9f297d59b3 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 13 May 2020 13:19:16 -0700 Subject: [PATCH] ci: switch to GitHub Actions Co-authored-by: Christian Clauss Co-authored-by: Matias Lopez PR-URL: https://github.com/nodejs/node-gyp/pull/2210 Closes: #2127 Closes: #2209 --- .github/workflows/Python_tests.yml | 40 ------------- .github/workflows/tests.yml | 51 ++++++++++++++++ .travis.yml | 93 ------------------------------ test/test-options.js | 16 +++-- 4 files changed, 62 insertions(+), 138 deletions(-) delete mode 100644 .github/workflows/Python_tests.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml deleted file mode 100644 index 067294515d..0000000000 --- a/.github/workflows/Python_tests.yml +++ /dev/null @@ -1,40 +0,0 @@ -# TODO: Line 15, enable python-version: 3.5 -# TODO: Line 36, enable pytest --doctest-modules - -name: Python_tests -on: [push, pull_request] -jobs: - Python_tests: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - max-parallel: 15 - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - python-version: [2.7, 3.6, 3.7, 3.8] # 3.5, - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest # -r requirements.txt - - name: Lint with flake8 - if: matrix.os == 'ubuntu-latest' - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest (Linux and macOS) - if: matrix.os != 'windows-latest' - run: pytest - - name: Test with pytest (Windows) - if: matrix.os == 'windows-latest' - shell: bash - run: GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" pytest - # - name: Run doctests with pytest - # run: pytest --doctest-modules diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..729a8f05e9 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,51 @@ +# TODO: Line 47, enable pytest --doctest-modules + +name: Tests +on: [push, pull_request] +jobs: + Tests: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + node: [10.x, 12.x, 14.x] + python: [3.6, 3.7, 3.8] + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - name: Use Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + env: + PYTHON_VERSION: ${{ matrix.python }} + - name: Install Dependencies + run: | + npm install --no-progress + pip install flake8 pytest + - name: Set Windows environment + if: matrix.os == 'windows-latest' + run: + echo '::set-env name=GYP_MSVS_VERSION::2015' + echo '::set-env name=GYP_MSVS_OVERRIDE_PATH::C:\\Dummy' + - name: Lint Python + if: matrix.os == 'ubuntu-latest' + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Run Python tests + run: | + python -m pytest + # - name: Run doctests with pytest + # run: python -m pytest --doctest-modules + - name: Run Node tests + run: | + npm test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ae691bed48..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,93 +0,0 @@ -dist: xenial -language: python -cache: pip -addons: - homebrew: - update: true - packages: - - npm - - pyenv -jobs: - include: - - name: "Python 2.7 on Linux" - env: NODE_GYP_FORCE_PYTHON=python2 - python: 2.7 - - - name: "Node.js 10 & Python 3.8 on Linux" - python: 3.8 - env: NODE_GYP_FORCE_PYTHON=python3 - before_install: nvm install 10 - - - name: "Node.js 12 & Python 3.5 on Linux" - python: 3.5 - env: NODE_GYP_FORCE_PYTHON=python3 - before_install: nvm install 12 - - name: "Node.js 12 & Python 3.6 on Linux" - python: 3.6 - env: NODE_GYP_FORCE_PYTHON=python3 - before_install: nvm install 12 - - name: "Node.js 12 & Python 3.7 on Linux" - python: 3.7 - env: NODE_GYP_FORCE_PYTHON=python3 - before_install: nvm install 12 - - name: "Node.js 12 & Python 3.8 on Linux" - python: 3.8 - env: NODE_GYP_FORCE_PYTHON=python3 - before_install: nvm install 12 - - - name: "Python 2.7 on macOS" - os: osx - osx_image: xcode11.2 - language: shell # 'language: python' is not yet supported on macOS - env: NODE_GYP_FORCE_PYTHON=python2 PATH=$HOME/.pyenv/shims:$PATH PYENV_VERSION=2.7.17 - before_install: pyenv install $PYENV_VERSION - - name: "Python 3.8 on macOS" - os: osx - osx_image: xcode11.2 - language: shell # 'language: python' is not yet supported on macOS - env: NODE_GYP_FORCE_PYTHON=python3 PATH=$HOME/.pyenv/shims:$PATH PYENV_VERSION=3.8.0 - before_install: pyenv install $PYENV_VERSION - - - name: "Node.js 12 & Python 2.7 on Windows" - os: windows - language: node_js - node_js: 12 # node - env: >- - PATH=/c/Python27:/c/Python27/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe - before_install: choco install python2 - - - name: "Node.js 12 & Python 3.7 on Windows" - os: windows - language: node_js - node_js: 12 # node - env: >- - PATH=/c/Python37:/c/Python37/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe - before_install: choco install python --version=3.7.4 - - name: "Node.js 12 & Python 3.8 on Windows" - os: windows - language: node_js - node_js: 12 # node - env: >- - PATH=/c/Python38:/c/Python38/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python38/python.exe - before_install: choco install python - -install: - - python -m pip install --upgrade flake8 pytest==4.6.6 # pytest 5 no longer supports legacy Python -before_script: - - python -m flake8 --version - # stop the build if there are Python syntax errors or undefined names - - python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. Two space indentation is OK. The GitHub editor is 127 chars wide - - python -m flake8 . --count --exit-zero --ignore=E111,E114,W503 --max-complexity=10 --max-line-length=127 --statistics - - npm install - - npm list -script: - - node -e 'require("npmlog").level="verbose"; require("./lib/find-python")(null,()=>{})' - - npm test - - GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" python -m pytest -notifications: - on_success: change - on_failure: change # `always` will be the setting once code changes slow down diff --git a/test/test-options.js b/test/test-options.js index 252baa2035..b2ac62c874 100644 --- a/test/test-options.js +++ b/test/test-options.js @@ -3,13 +3,19 @@ const test = require('tap').test const gyp = require('../lib/node-gyp') -test('options in environment', function (t) { +test('options in environment', (t) => { t.plan(1) // `npm test` dumps a ton of npm_config_* variables in the environment. Object.keys(process.env) - .filter(function (key) { return /^npm_config_/.test(key) }) - .forEach(function (key) { delete process.env[key] }) + .filter((key) => /^npm_config_/.test(key)) + .forEach((key) => { delete process.env[key] }) + + // in some platforms, certain keys are stubborn and cannot be removed + const keys = Object.keys(process.env) + .filter((key) => /^npm_config_/.test(key)) + .map((key) => key.substring('npm_config_'.length)) + .concat('argv', 'x') // Zero-length keys should get filtered out. process.env.npm_config_ = '42' @@ -18,8 +24,8 @@ test('options in environment', function (t) { // Except loglevel. process.env.npm_config_loglevel = 'debug' - var g = gyp() + const g = gyp() g.parseArgv(['rebuild']) // Also sets opts.argv. - t.deepEqual(Object.keys(g.opts).sort(), ['argv', 'x']) + t.deepEqual(Object.keys(g.opts).sort(), keys.sort()) })