Hi All! Could you please review my issue and give ...
# pact-js
t
Hi All! Could you please review my issue and give me a hint how it can be solved? I am using
"@pact_foundation/pact": "^10.1.4"
for my consumer testing. I added consumer tests but I didn’t include tests to CI pipeline, so the consumer tests are not executed in the pipeline yet. However, my
build
job is failing in my CI pipeline with errors regarding Python (errors attached in thread).
build
job looks like:
Copy code
build:
  stage: build
  variables:
    ENV: "localhost"
    NPM_TOKEN: '$CI_JOB_TOKEN'
  before_script:
    - gitlab/configure-npm.sh
    - apk add --update make
  script:
    - make set-environment ENV=$ENV
    - yarn install --frozen-lockfile
    - make build
  artifacts:
    paths:
      - dist
gitlab/configure-npm.sh
looks like:
Copy code
#!/bin/sh

set -o errexit
set -x

yarn config set -H npmScopes.codility.npmRegistryServer "<https://gitlab.codility.net/api/v4/projects/519/packages/npm/>"
yarn config set -H npmScopes.codility.npmAuthToken "${NPM_TOKEN}"
I use
gitlab-ci
, the app uses
TS
,
React
,
yarn
. Also, as I can see we don’t use
docker-compose
,
dockerfile
in our app. But in CI logs I see:
Copy code
Running with gitlab-runner 15.5.0 (0d4137b8)
  on gitlab-runners-manager-spot-c5-
Resolving secrets
00:00
Preparing the "docker+machine" executor
00:08
Using Docker executor with image node:16.13.0-alpine ...
Pulling docker image node:16.13.0-alpine ...
Using docker image sha256:44e24535dfbf4b7415c16a5828 for node:16.13.0-alpine with digest node@sha256:60ef0bed1dc2ec835cfe3c4 ...
I suspect that I need to install python3, but I am not sure if I should do it since it’s React app. Please advice 🙏
Error in CI pipeline:
Copy code
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python 
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python Python is not set from command line or npm configuration
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python Python is not set from environment variable PYTHON
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python checking if "python3" can be used
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python - "python3" is not in PATH or produced an error
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python checking if "python" can be used
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python - "python" is not in PATH or produced an error
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python 
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python

➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python You need to install the latest version of Python.
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python you can try one of the following options:
➤ YN0000: │ @pact-foundation/pact-core@npm:13.9.0 STDERR gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
Btw, locally everything works fine, I have python3 installed on my machine.
m
It’s because we use native extensions, the standard Node tooling uses a tool called node gyp which needs Python - a bit unfortunately, yes.
Also, Pact won’t work on Alpine
t
Thank you, I’ll try to use ubuntu or debian instead of alpine and install python…
👍 1
Hi again, do you have any examples of including pact-js to pipelines using python and ubuntu/debian image for node?
m
From https://docs.pact.io/docker#running-pact-on-docker:
Copy code
FROM node:18

RUN apt-get update -y && \
    apt-get install -y git g++ python3 build-essential && \
    rm -rf /var/lib/apt/lists/*

COPY ./ /app/
WORKDIR /app
RUN npm install
CMD ["npm", "t"]
That image should get you what you need
👍 1
t
Thanks!
👍 1
m
Is that what you were after?
t
Well, not 100%. I don’t create a dockerfile for pact tests just yet. I am trying to update my
build
job in the
.gitlab-ci.yaml
file with python and using debian node image. Because after installing pact library I had errors described above in the CI/CD. Anyway, you helped me! I used installation commands from your message and my build was successful 👍 Thank you very much, you’re helping me a lot with Pact!
🙌 1
m
Amazing 👏 You’re welcome, and glad to see you’re up and going. we could definitely make this clearer. May I ask, where did you first look when things didn’t work? I’m wondering if I can create a hook or something in the
node-gyp
process that prints out possible causes and solutions. But outside of the build logs, where did you go for help? (befaure coming here, obviously 😛 )
t
I tried to google the errors and possible solutions on the internet, for example here. Also, went through this page. Actually, the errors were clear, it couldn’t find python, but I wasn’t sure 100% if it was ok to install python for react app. That’s why I decided to come here and clarify the question if it’s alright or maybe I could avoid python installation.