Closed neelabalan closed 3 years ago
I've heard about github workflows and looked up a tutorial once for 15 minutes but i haven't fully understood how it works. I'll leave it up to you for now. Do you have a simple tutorial for me ? thanks
yeah. Initially I referred to the github docs https://docs.github.com/en/actions/guides/building-and-testing-python and started experimenting with them in my private repos.
I've tested this github action in my private repo and here is what I've added to make it all come together
docker-compose.yml
web-test:
image: alpine
depends_on:
- web-base-image
- web-random
- web-random-pypy
- web-users
- background-mqtt
- web-fulltext-search
- web-geolocation-search
- web-baesian
- web-photo-process
- web-book-collection
- web-users-fast-api
- influxdb
- grafana
- mongo
- mqtt
- krakend
.github/workflows/build.yml
name: test-build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@main
- name: Test
run: docker-compose build && docker-compose up --exit-code-from web-test
It works well. I've tested it for various scenarious like the port collisions and incorrect commands. Let me know what you think. If you are planning for adding integration tests in the future then I think I can work on this combined with integration tests for some more time and raise a PR altogether.
link I found for integration test with docker-compose
Ok, if you say it works in your tests make a PR, i'll test it too
On Sat, Feb 27, 2021 at 2:42 PM neelabalan notifications@github.com wrote:
I've tested this github action in my private repo and here is what I've added to make it all come together
docker-compose.yml
web-test: image: alpine depends_on: - web-base-image - web-random - web-random-pypy - web-users - background-mqtt - web-fulltext-search - web-geolocation-search - web-baesian - web-photo-process - web-book-collection - web-users-fast-api - influxdb - grafana - mongo - mqtt - krakend
.github/workflows/build.yml
name: test-buildon: [push, pull_request]jobs: build: runs-on: ubuntu-latest timeout-minutes: 5 steps:
- name: Checkout uses: actions/checkout@main
- name: Test run: docker-compose build && docker-compose up --exit-code-from web-test
It works well. I've tested it for various scenarious like the port collisions and incorrect commands. Let me know what you think. If you are planning for adding integration tests in the future then I think I can work on this combined with integration tests for some more time and raise a PR altogether.
link I found for integration test https://blog.avenuecode.com/how-to-run-integration-tests-using-docker-compose-and-.net-5 with docker-compose
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/danionescu0/docker-flask-mongodb-example/issues/59#issuecomment-787067150, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDFS3VCWBML34WXDCBFJPTTBDSEXANCNFSM4YJPX5QA .
When i run docker-compose up locally i get this error: docker-flask-mongodb-example_web-test_1 exited with code 0
Do i need to install something else ? Or is it ok to fail after running the tests?
exit code 0 means there is an absence of an attached foreground process which is normal for web-test container. In our case we can do --rm to remove the web-test container after it has exited. I think there are other exit codes like 125 and 126 which represent failure.
ok
Do i need to make extra configuration of the github project so it will be run automatically on push ?
it is running automatically on push
on: [push, pull_request]
Hi. I am working on testing this workflow in my private repos. What do you think?
reference