How to finish docker-compose action and mark as succes #26852
-
Hi, I have a pyhon project that runs a couple of containers: nginx, uwsgi, mysql, celery, rabbitmq.
This builds the containers, starts them and runs the integration tests as part of the entrypoint script of the integration-tests container. But after finishing the tests, all containers keep running, or at leasts the ones running a service such as nginx, uwsgi, celery, mysql. Valentijn |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
So you could use a sequence like this:
|
Beta Was this translation helpful? Give feedback.
-
My first try was with ‘up -d’ which kills the containers too soon indeed. Didn’t want to with some strange dev/null tail in my Dockerfile as suggested elsewhere.
Which seems to correctly wait until the integrationtest container finishes. That container exist/fails with exit code 1 due to a failing test. But the github action is marked as succesful. Not sure how this works, the whole docker-compose setup seems to be undocumented for GitHub actions? Github Actions as Status checks? Now trying your suggestion, build takes 30 minutes. Not sure what the single ‘|’ command does? |
Beta Was this translation helpful? Give feedback.
-
Tried with the suggested '|'command, but that doesn’t seem to do anything but instantly complete. So containers are killed, no integration tests are run. Probably need to use docker inspect or something to get the exit code. |
Beta Was this translation helpful? Give feedback.
-
valentijnscholten:
That’s probably because reading the log (what If you just need the exit code: I’ve done something similar before where I was running the test container independent of
valentijnscholten:
That’s not a command, that’s YAML syntax to start a text block that preserves line breaks. That way you can have more than a one line command in a single Example from one of my workflows:
For more on YAML multiline text, take a look at: YAML Multiline Strings |
Beta Was this translation helpful? Give feedback.
-
Actually I am migrating from Travis and there we are running the integration tests not in a container, but in the main travis script and connecting to the exposes port 8080. I could do the same here I guess and just let the exit code cascade from there. Hopefully it works :slight_smile: |
Beta Was this translation helpful? Give feedback.
-
That sounds promising, I’d like to hear if it works! 🙂 |
Beta Was this translation helpful? Give feedback.
-
I decided to keep the tests running in the container. But started all other containers first with
this works and the exit code is cascaded nicely into the GitHub action. |
Beta Was this translation helpful? Give feedback.
I decided to keep the tests running in the container. But started all other containers first with
up -d
and then start the container with the tests with ‘up --exit-code-from’this works and the exit code is cascaded nicely into the GitHub action.