Keeping cht-couch2pg updated

Hey @andrablaj @diana and @twier - what do you think about keeping the cht-couch2pg repository updated? I made a very small PR to update the readme to use docker compose instead of the outdated docker-compose.

CI then failed because CI itself no longer can work with docker-compose (oh, the irony!!):

Run docker-compose -f docker-compose.test.yml build --build-arg node_version=8 cht-couch2pg
  docker-compose -f docker-compose.test.yml build --build-arg node_version=8 cht-couch2pg
  shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/6f6b08a4-8c91-444e-99a7-de5e01bf8aea.sh: line 1: docker-compose: command not found
Error: Process completed with exit code 127.

When I fixed that though it’s brought up another error I cited in the PR:

 Container cht-couch2pg-couch-1  Started
 Container cht-couch2pg-postgres-1  Started
/usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:84
  var flags = Array.from(process.allowedNodeEnvironmentFlags);
                    ^

TypeError: Cannot convert undefined or null to object
    at Function.from (native)
    at getFlags (/usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:84:21)
    at /usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:142:5
    at /usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:70:14
    at FSReqWrap.oncomplete (fs.js:135:15)
Error: Process completed with exit code 1.

Given I’m trying to make a very small change in the docs, and now instead I’m knee deep in refactoring CI, I wanted to check in this was a path we should go down given we marked the repo as deprecated 5mo ago?

My vote is we fix CI and keep it status quo (no new features, but working as is). This is because there’s still a number of CHT Core instances still using this as their main workflow - including just about every Medic hosted CHT instance.

(Posting over here in the forums for maybe little more exposure than just in the CHT couch2pg repo, and trying the whole “community first” approach. Feedback on this approach welcome!)

My vote is we fix CI and keep it status quo (no new features, but working as is).

I agree

Completely agree with this!

Thanks you two!

As such, I welcome any tips on how to debug my issue :sweat_smile:

It looks like the grunt-cli version that gets installed is not compatible with Node 8 - which is one suite for our e2e tests, it looks like the target node versions are 8, 10 and 12.

The error that you’re seeing is:

/usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:84
  var flags = Array.from(process.allowedNodeEnvironmentFlags);
                    ^

TypeError: Cannot convert undefined or null to object
    at Function.from (native)
    at getFlags (/usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:84:21)
    at /usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:142:5
    at /usr/local/lib/node_modules/grunt-cli/node_modules/v8flags/index.js:70:14
    at FSReqWrap.oncomplete (fs.js:135:15)

And process.allowedNodeEnvironmentFlags was only added in Node 10: Process | Node.js v23.7.0 Documentation

So the grunt-cli code is basically doing Array.from(undefined) and this fails in any node version (as expected).

It seems that we just install a random version of grunt-cli in our docker image: cht-couch2pg/Dockerfile at main · medic/cht-couch2pg · GitHub instead of the “locked” one in our package.json, so I’m assuming that at some point, grunt-cli became incompatible with Node 8.

The solution can be:

  • make sure we use a version of grunt-cli that is compatible with Node 8
  • drop Node 8 support from cht-couch2pg

Dropping Node 8 support is quite easy and only requires a small change in the CI test runner. Locking to a specific version of grunt needs a bit more effort but is the better long term solution.

awesome! I’ll try and dive into this in the coming few days - thanks for the tips!!