From d6920cd82e749c0480b2bb805490ec949488b530 Mon Sep 17 00:00:00 2001 From: Javier Arroyo Date: Fri, 20 Sep 2024 18:32:10 +0200 Subject: [PATCH] Refactor to pull boptest_base image. --- .github/workflows/github-actions.yml | 22 +++------ testing/Makefile | 73 +++++++++++++++++----------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 4191d91..a526493 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -16,12 +16,8 @@ jobs: uses: actions/checkout@v3 - name: Pull boptestgym image from registry run: make pull-boptestgym - - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: List of files in the repository - run: | - ls ${{ github.workspace }} - - name: Set up Docker - uses: docker/setup-buildx-action@v2 + - name: Pull boptest_base image from registry + run: make pull-boptestbase - name: Install Docker Compose run: | sudo apt-get update @@ -38,12 +34,8 @@ jobs: uses: actions/checkout@v3 - name: Pull boptestgym image from registry run: make pull-boptestgym - - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: List of files in the repository - run: | - ls ${{ github.workspace }} - - name: Set up Docker - uses: docker/setup-buildx-action@v2 + - name: Pull boptest_base image from registry + run: make pull-boptestbase - name: Install Docker Compose run: | sudo apt-get update @@ -60,10 +52,8 @@ jobs: uses: actions/checkout@v3 - name: Pull boptestgym image from registry run: make pull-boptestgym - - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: List of files in the repository - run: | - ls ${{ github.workspace }} + - name: Pull boptest_base image from registry + run: make pull-boptestbase - name: Test service version run: make test-service-in-container \ No newline at end of file diff --git a/testing/Makefile b/testing/Makefile index f1ff5ba..ea04040 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -2,91 +2,108 @@ ROOT ?= $(shell dirname \ $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))) -# Local image name and home -IMG_NAME=boptestgym -IMG_HOME=/home/developer/boptestgym +# Local image name, home directory, and remote registry for BOPTEST-Gym +IMG_NAME_BOPTESTGYM=boptestgym +IMG_HOME_BOPTESTGYM=/home/developer/boptestgym +IMG_REGI_BOPTESTGYM=javierarroyo/boptestgym -# Name of remote registry image -IMG_REGI=javierarroyo/boptestgym +# Local image name and remote registry for the BOPTEST test case +IMG_NAME_BOPTESTBASE=boptest_base +IMG_REGI_BOPTESTBASE=javierarroyo/boptest_base # BOPTEST commit used for the tests BOPTEST_COMMIT=78665506a620fc07bc2a8f301661aef3dd6c88c2 # Define current BOPTEST-Gym version (should be even with BOPTEST version defined in commit above) -VERSION = 0.6.0 +VERSION = 0.6.0-dev build-boptestgym: docker build -f ${ROOT}/testing/Dockerfile \ - --progress=plain --rm -t ${IMG_NAME} . + --progress=plain --rm -t ${IMG_NAME_BOPTESTGYM} . build-boptestgym-no-cache: docker build -f ${ROOT}/testing/Dockerfile \ - --progress=plain --no-cache --rm -t ${IMG_NAME} . - + --progress=plain --no-cache --rm -t ${IMG_NAME_BOPTESTGYM} . + +# Build the generic BOPTEST base image without mounting any test case +build-boptestbase: + make download-boptest + cd project1-boptest-${BOPTEST_COMMIT} && \ + docker compose build + run-boptestgym: docker run \ - --name ${IMG_NAME} \ + --name ${IMG_NAME_BOPTESTGYM} \ --detach=false \ --network=host \ --rm \ --user $(id -u):$(id -g) \ - -v ${ROOT}:${IMG_HOME}:rw \ - -w ${IMG_HOME}/testing \ + -v ${ROOT}:${IMG_HOME_BOPTESTGYM}:rw \ + -w ${IMG_HOME_BOPTESTGYM}/testing \ -it \ - ${IMG_NAME} + ${IMG_NAME_BOPTESTGYM} run-boptestgym-detached: docker run \ - --name ${IMG_NAME} \ + --name ${IMG_NAME_BOPTESTGYM} \ --detach=true \ --network=host \ --rm \ --user $(id -u):$(id -g) \ - -v ${ROOT}:${IMG_HOME}:rw \ - -w ${IMG_HOME}/testing \ + -v ${ROOT}:${IMG_HOME_BOPTESTGYM}:rw \ + -w ${IMG_HOME_BOPTESTGYM}/testing \ -it \ - ${IMG_NAME} + ${IMG_NAME_BOPTESTGYM} stop-boptestgym: - docker stop ${IMG_NAME} + docker stop ${IMG_NAME_BOPTESTGYM} exec-boptestgym: docker exec \ -i \ - ${IMG_NAME} \ + ${IMG_NAME_BOPTESTGYM} \ /bin/bash -c "${ARGS} && exit" push-boptestgym: # requires `docker login` first - docker tag ${IMG_NAME} ${IMG_REGI}:${VERSION} - docker push ${IMG_REGI}:${VERSION} + docker tag ${IMG_NAME_BOPTESTGYM} ${IMG_REGI_BOPTESTGYM}:${VERSION} + docker push ${IMG_REGI_BOPTESTGYM}:${VERSION} pull-boptestgym: - docker pull ${IMG_REGI}:${VERSION} - docker tag ${IMG_REGI}:${VERSION} ${IMG_NAME} + docker pull ${IMG_REGI_BOPTESTGYM}:${VERSION} + docker tag ${IMG_REGI_BOPTESTGYM}:${VERSION} ${IMG_NAME_BOPTESTGYM} + +push-boptestbase: +# requires `docker login` first + docker tag ${IMG_NAME_BOPTESTBASE} ${IMG_REGI_BOPTESTBASE}:${VERSION} + docker push ${IMG_REGI_BOPTESTBASE}:${VERSION} + +pull-boptestbase: + docker pull ${IMG_REGI_BOPTESTBASE}:${VERSION} + docker tag ${IMG_REGI_BOPTESTBASE}:${VERSION} ${IMG_NAME_BOPTESTBASE} -make download-boptest: +download-boptest: curl -L -o boptest.zip https://github.com/ibpsa/project1-boptest/archive/${BOPTEST_COMMIT}.zip unzip -o -q boptest.zip run-boptest-case: make download-boptest cd project1-boptest-${BOPTEST_COMMIT} && \ - TESTCASE=bestest_hydronic_heat_pump docker-compose up -d --quiet-pull + TESTCASE=bestest_hydronic_heat_pump docker compose up -d run-boptest-case-no-cache: make download-boptest cd project1-boptest-${BOPTEST_COMMIT} && \ - TESTCASE=bestest_hydronic_heat_pump docker-compose up -d --force-recreate --build + TESTCASE=bestest_hydronic_heat_pump docker compose up -d --force-recreate --build run-boptest-vectorized: make download-boptest && \ cd .. && python3 generateDockerComposeYml.py testing/project1-boptest-${BOPTEST_COMMIT} && \ cd testing/project1-boptest-${BOPTEST_COMMIT} && \ - TESTCASE=bestest_hydronic_heat_pump docker-compose up -d --quiet-pull + TESTCASE=bestest_hydronic_heat_pump docker compose up -d stop-boptest-case: - cd project1-boptest-${BOPTEST_COMMIT} && docker-compose down + cd project1-boptest-${BOPTEST_COMMIT} && docker compose down cleanup-boptest: rm boptest.zip