diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1d8026873f1..ebbe447f3d4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -65,41 +65,41 @@ jobs: # Tests - run: make preparetest - - run: docker-compose logs --timestamps + - run: docker compose logs --timestamps if: failure() # Similar to: make tests-commons - run: > - ci/run-dc-logs docker-compose exec -T tests coverage run + ci/run-dc-logs docker compose exec -T tests coverage run --source=/opt/c2cgeoportal/commons/c2cgeoportal_commons --module pytest --verbose --color=yes --junitxml=/tmp/commons.xml /opt/c2cgeoportal/commons/tests # Similar to: make tests-geoportal - run: > - ci/run-dc-logs docker-compose exec -T tests coverage run --append + ci/run-dc-logs docker compose exec -T tests coverage run --append --source=/opt/c2cgeoportal/geoportal/c2cgeoportal_geoportal --module pytest --verbose --color=yes --junitxml=/tmp/geoportal.xml /opt/c2cgeoportal/geoportal/tests # Similar to: make tests-admin - run: > - ci/run-dc-logs docker-compose exec -T tests coverage run --append + ci/run-dc-logs docker compose exec -T tests coverage run --append --source=/opt/c2cgeoportal/admin/c2cgeoportal_admin --module pytest --verbose --color=yes --junitxml=/tmp/admin.xml /opt/c2cgeoportal/admin/tests # Similar to: make tests-qgisserver - run: > - ci/run-dc-logs docker-compose exec -T qgisserver-tests + ci/run-dc-logs docker compose exec -T qgisserver-tests pytest --verbose --color=yes --junitxml=/tmp/qgis.xml /src/tests/functional - name: Extract tests artifacts continue-on-error: true run: | - docker-compose exec -T tests coverage report - docker-compose exec -T tests coverage html --directory=/tmp/coverage + docker compose exec -T tests coverage report + docker compose exec -T tests coverage html --directory=/tmp/coverage mkdir --parent artifacts/geoportal-coverage mkdir --parent artifacts/qgisserver-plugin-coverage docker cp c2cgeoportal_tests_1:/tmp/coverage/ artifacts/geoportal-coverage/ if: always() - - run: docker-compose down + - run: docker compose down - uses: actions/upload-artifact@v2 with: @@ -138,9 +138,9 @@ jobs: - continue-on-error: true run: | cd ${HOME}/workspace/testgeomapfishapp/ - for service in $(docker-compose config --services) + for service in $(docker compose config --services) do - docker-compose logs ${service} + docker compose logs ${service} done if: failure() diff --git a/.github/workflows/qgis.yaml b/.github/workflows/qgis.yaml index 80d776c022d..84e4be39ea6 100644 --- a/.github/workflows/qgis.yaml +++ b/.github/workflows/qgis.yaml @@ -58,13 +58,13 @@ jobs: - name: Acceptance tests run: | cd docker/qgisserver - docker-compose up -d - docker-compose exec -T tests /tests/wait-db - docker-compose exec -T tests alembic --config=/tests/alembic.ini --name=main upgrade head - docker-compose exec -T tests alembic --config=/tests/alembic.ini --name=static upgrade head - docker-compose exec -T tests /tests/fill-db - ../../ci/run-dc-logs docker-compose exec -T tests /tests/acceptance-tests - docker-compose down + docker compose up -d + docker compose exec -T tests /tests/wait-db + docker compose exec -T tests alembic --config=/tests/alembic.ini --name=main upgrade head + docker compose exec -T tests alembic --config=/tests/alembic.ini --name=static upgrade head + docker compose exec -T tests /tests/fill-db + ../../ci/run-dc-logs docker compose exec -T tests /tests/acceptance-tests + docker compose down - run: scripts/get-version --auto-increment --github id: version diff --git a/Makefile b/Makefile index 20046669279..7c775d6a74c 100644 --- a/Makefile +++ b/Makefile @@ -76,37 +76,37 @@ tests: tests-commons tests-geoportal tests-admin tests-qgisserver .PHONY: tests-commons tests-commons: ## Run the commons unit tests - docker-compose exec -T tests pytest --verbose --color=yes \ + docker compose exec -T tests pytest --verbose --color=yes \ /opt/c2cgeoportal/commons/tests .PHONY: tests-geoportal tests-geoportal: ## Run the geoportal unit tests - docker-compose exec -T tests pytest --verbose --color=yes \ + docker compose exec -T tests pytest --verbose --color=yes \ /opt/c2cgeoportal/geoportal/tests .PHONY: tests-admin tests-admin: ## Run the admin unit tests - docker-compose exec -T tests pytest --verbose --color=yes \ + docker compose exec -T tests pytest --verbose --color=yes \ /opt/c2cgeoportal/admin/tests .PHONY: tests-qgis tests-qgisserver: ## Run the qgisserver unit tests - docker-compose exec -T qgisserver-tests pytest --verbose --color=yes \ + docker compose exec -T qgisserver-tests pytest --verbose --color=yes \ /src/tests/functional .PHONY: preparetest preparetest: ## Run the compositon used to run the tests preparetest: stoptest build-tools build-test-db build-test-mapserver build-qgis-server-tests - docker-compose up -d - docker-compose exec -T tests wait-db - docker-compose exec -T tests alembic --config=/opt/c2cgeoportal/commons/alembic.ini --name=main \ + docker compose up -d + docker compose exec -T tests wait-db + docker compose exec -T tests alembic --config=/opt/c2cgeoportal/commons/alembic.ini --name=main \ upgrade head - docker-compose exec -T tests alembic --config=/opt/c2cgeoportal/commons/alembic.ini --name=static \ + docker compose exec -T tests alembic --config=/opt/c2cgeoportal/commons/alembic.ini --name=static \ upgrade head - docker-compose exec -T tests psql --command='DELETE FROM main_static.user_role' - docker-compose exec -T tests psql --command='DELETE FROM main_static."user"' + docker compose exec -T tests psql --command='DELETE FROM main_static.user_role' + docker compose exec -T tests psql --command='DELETE FROM main_static."user"' .PHONY: stoptest stoptest: ## Stop the compositon used to run the tests - docker-compose stop --timeout=0 - docker-compose down --remove-orphans + docker compose stop --timeout=0 + docker compose down --remove-orphans diff --git a/ci/run-dc-logs b/ci/run-dc-logs index a0cbf5ad6fa..29c1b11ab5e 100755 --- a/ci/run-dc-logs +++ b/ci/run-dc-logs @@ -14,5 +14,5 @@ try: except subprocess.CalledProcessError: sys.exit(2) finally: - for container in subprocess.check_output(["docker-compose", "ps", "-q"]).decode().strip().split("\n"): + for container in subprocess.check_output(["docker compose", "ps", "-q"]).decode().strip().split("\n"): subprocess.call(["docker", "logs", "--timestamps", "--since", since, container]) diff --git a/ci/test-app b/ci/test-app index f646fce01b1..82ee37a9084 100755 --- a/ci/test-app +++ b/ci/test-app @@ -14,15 +14,15 @@ c2cciutils-checks cp ${PROJECT_DIR}/ci/project-config.yaml ci/config.yaml c2cciutils-checks ./build -docker-compose down -docker-compose up -d -docker-compose exec -T geoportal bash -c 'PGHOST=externaldb PGDATABASE=test wait-db;' -docker-compose exec -T geoportal wait-db -docker-compose exec -T geoportal alembic --config=alembic.ini --name=main upgrade head -docker-compose exec -T geoportal alembic --config=alembic.ini --name=static upgrade head -docker-compose exec -T geoportal create-demo-theme +docker compose down +docker compose up -d +docker compose exec -T geoportal bash -c 'PGHOST=externaldb PGDATABASE=test wait-db;' +docker compose exec -T geoportal wait-db +docker compose exec -T geoportal alembic --config=alembic.ini --name=main upgrade head +docker compose exec -T geoportal alembic --config=alembic.ini --name=static upgrade head +docker compose exec -T geoportal create-demo-theme make update-po -docker-compose exec -T geoportal theme2fts +docker compose exec -T geoportal theme2fts # Commit the l10n files modifications # To prevent fail on modification files check @@ -30,17 +30,17 @@ docker-compose exec -T geoportal theme2fts #git add geoportal/testgeomapfishapp_geoportal/locale/*/LC_MESSAGES/testgeomapfishapp_geoportal-*.po #git commit -m "Upgrade the po files" -ci/run-dc-logs docker-compose exec -T geoportal ci/waitwsgi https://front/themes +ci/run-dc-logs docker compose exec -T geoportal ci/waitwsgi https://front/themes for path in c2c/health_check c2c/health_check?max_level=9 c2c/health_check?checks=check_collector "layers/test/values/type enum" admin/layertree admin/layertree/children; do - ci/run-dc-logs docker-compose exec -T geoportal ci/test-new-project https://front/${path} - #docker-compose exec -T geoportal curl --insecure https://front/c2c/debug/stacks?secret=c2c + ci/run-dc-logs docker compose exec -T geoportal ci/test-new-project https://front/${path} + #docker compose exec -T geoportal curl --insecure https://front/c2c/debug/stacks?secret=c2c done -ci/run-dc-logs docker-compose exec -T geoportal ci/test-new-project 'http://qgisserver:8080/mapserv_proxy?SERVICE=WMS&REQUEST=GetCapabilities' -ci/run-dc-logs docker-compose exec -T geoportal curl --insecure https://front/admin/ | grep Login -docker-compose stop qgisserver -ci/run-dc-logs docker-compose exec -T geoportal alembic --config=alembic.ini --name=static downgrade base -ci/run-dc-logs docker-compose exec -T geoportal alembic --config=alembic.ini --name=main downgrade base -docker-compose down +ci/run-dc-logs docker compose exec -T geoportal ci/test-new-project 'http://qgisserver:8080/mapserv_proxy?SERVICE=WMS&REQUEST=GetCapabilities' +ci/run-dc-logs docker compose exec -T geoportal curl --insecure https://front/admin/ | grep Login +docker compose stop qgisserver +ci/run-dc-logs docker compose exec -T geoportal alembic --config=alembic.ini --name=static downgrade base +ci/run-dc-logs docker compose exec -T geoportal alembic --config=alembic.ini --name=main downgrade base +docker compose down rm -rf ${HOME}/workspace/testgeomapfishapp docker rmi camptocamp/testgeomapfishapp-geoportal-dev:latest diff --git a/scripts/upgrade b/scripts/upgrade index bf570f83022..d87bf8a3989 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (c) 2019-2020, Camptocamp SA +# Copyright (c) 2019-2024, Camptocamp SA # All rights reserved. # Redistribution and use in source and binary forms, with or without @@ -41,6 +41,7 @@ parser.add_argument( ) parser.add_argument("version", help="the version to upgrade to (master or x.y.z)") parser.add_argument("step", nargs="?", help="the step to run") +parser.add_argument("--docker-compose-version-2", action="store_true", help="Use Docker Compose version 2") parser_finalize = argparse.ArgumentParser(description="Upgrade the project", add_help=False) parser_finalize.add_argument("--finalize", action="store_true", help="finalize the upgrade") parser_finalize.add_argument("--help", action="help", help="show this help message and exit") @@ -48,7 +49,7 @@ parser_finalize.add_argument("build_arg", nargs="*", help="build arguments") if len(sys.argv) >= 2 and sys.argv[1] == "--finalize": args = parser_finalize.parse_args() - + docker_compose = ["docker", "compose"] if args.docker_compose_version_2 else ["docker-compose"] if platform.system() == "Windows": code = subprocess.call(["python", "build"] + args.build_arg) else: @@ -56,14 +57,14 @@ if len(sys.argv) >= 2 and sys.argv[1] == "--finalize": if code != 0: sys.exit(code) - subprocess.call(["docker-compose", "down", "--remove-orphans"]) + subprocess.call([*docker_compose, "down", "--remove-orphans"]) subprocess.call( - ["docker-compose", "pull", "--ignore-pull-failures"], env={**os.environ, "DOCKER_TAG": "unexisting"} + [*docker_compose, "pull", "--ignore-pull-failures"], env={**os.environ, "DOCKER_TAG": "unexisting"} ) - subprocess.check_call(["docker-compose", "up", "-d"]) + subprocess.check_call([*docker_compose, "up", "-d"]) subprocess.check_call( [ - "docker-compose", + *docker_compose, "exec", "geoportal", "alembic",