From dcec573bae6fd168b6190a08839583b27715e262 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 9 Nov 2022 16:22:20 -0800 Subject: [PATCH] Use node-gyp compatible version of Python in runner for test workflow The node-gyp dependency of this project uses a Python script. Previously, the test GitHub Actions workflow was not configured to install a specific version of Python, so whichever version of Python 3.x that was pre-installed on the GitHub Actions runner machine was used. The documentation for the node-gyp@7.1.2 version used by this project indicates the newest supported Python version is 3.8. Clearly newer versions did work because the workflow has been running with Python 3.10. However, the macos-latest runner was updated to using Python 3.11 and the script now fails when `npm install` is ran in the project: ValueError: invalid mode: 'rU' while trying to load binding. The solution is to install a specific version of Python. It seems safest to use the newest version explicitly stated as supported by the node-gyp@7.1.2 documentation, so Python 3.8 is installed. --- .github/workflows/test-typescript-npm.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test-typescript-npm.yml b/.github/workflows/test-typescript-npm.yml index e7eb503..5679d03 100644 --- a/.github/workflows/test-typescript-npm.yml +++ b/.github/workflows/test-typescript-npm.yml @@ -3,6 +3,10 @@ name: Test TypeScript env: # See: https://github.com/actions/setup-node/#readme NODE_VERSION: 10.x + # See: https://github.com/actions/setup-python/tree/main#available-versions-of-python + # Using newest version documented as supported by node-gyp dependency: + # https://github.com/nodejs/node-gyp/tree/v7.1.2#installation + PYTHON_VERSION: 3.8 on: push: @@ -60,6 +64,11 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Install dependencies run: npm install