entropic-dev / entropic

🦝 :package: a package registry for anything, but mostly javascript 🦝 🦝 🦝
https://discourse.entropic.dev/
Apache License 2.0
5.29k stars 152 forks source link

Integration tests for docker-compose #281

Open toddself opened 5 years ago

toddself commented 5 years ago

We need tests to ensure changes are able to generate packages and that running docker-compose doesn't fail on these changes.

If anyone is interested in working on this that would be great!

nveenjain commented 5 years ago

I would love to work on this issue, would you please just guide me to what should i do? I'm thinking of writing a test in js which forks docker compose up, and checking it's exit code. Will this be fine or should I do something else? PS. I'm new to this project but want to contribute to this awesome initiative..

zacanger commented 5 years ago

The rest of the tests are running in Docker in Circle, but since these would be testing that the docker-compose setup itself works (and everything running in Docker works together), you'll probably want to use a VM executor: https://circleci.com/docs/2.0/executor-types/

An initial test could probably be as simple as:

Related, once #204 is in, we should figure out if there's a good way to test that, too. Maybe microk8s + an extra Postgres pod?

nveenjain commented 5 years ago

After some digginig, I guess, I could use remote docker command for the same https://circleci.com/docs/2.0/building-docker-images/ Thoughts? If building docker fails, test will fail..

zacanger commented 5 years ago

Yep, those docs are a better example than the link I found, especially the last example. If building the containers fails CI should fail, but I think maybe that should be a separate step, since building containers to push to Docker Hub for production deployment is different than spinning up docker-compose and making sure everything can still talk to everything else.

toddself commented 5 years ago

Yeah, we want two things really:

  1. Docker images should build without fail
  2. They should be able to be started with docker-compose and have a working running instance (ideally we'd curl against it to at least give it a litmus check that the server started)
toddself commented 5 years ago

Also @nveenjain thank you for coming by and pitching in!

zacanger commented 5 years ago

@toddself do you have Circle access? 1. Docker iamges should build without fail is what this script is for, and my thought was that it should be run on each merge to master and git tag. We'd need a Docker Hub service account credentials added in Circle for that to work.

toddself commented 5 years ago

@zacanger I can give it a shot in the am!

nveenjain commented 5 years ago

I'm thinking of creating a new build job

  build:
    docker:
      - image: circleci/node:latest
      - image: circleci/postgres:latest
    steps:
      - checkout
      - setup_remote_docker
      - run: npm install
      - run: 
          name: Docker compose up
          command: |
            set -ex
            docker-compose up -d

Should i send request to every app after we do docker-compose, also if I'm doing anything wrong, please tell, I'm not quite familiar with CircleCI...

toddself commented 5 years ago

I don't think you need the postgres container in there -- the docker compose command should cause a postgres container to be spun up automatically.

@zacanger if it requires putting secret creds into circle-ci that could be a problem -- or we would only have to let that test run on master since even if you have creds in the "secure env variables" section, they still need to be decrypted when passed on the command line which can cause cred leakage :(

zacanger commented 5 years ago

Good point. I opened a new issue #291 about this so I don't hijack this issue.