From 9066e314e82dd7dca36a6e4bffc392158c95f179 Mon Sep 17 00:00:00 2001 From: wall_e Date: Thu, 7 Nov 2024 16:30:50 +0100 Subject: [PATCH] Switch to Sinq CI --- .gitlab-ci.yml | 30 +++++++++++++++--------------- scripts/counterbox_4ch.cmd | 3 ++- scripts/counterbox_8ch.cmd | 3 ++- scripts/counterbox_v2.cmd | 3 ++- sim/counterbox_sim.py | 1 - test/ioc.sh | 2 +- test/st.cmd | 2 +- test/test.py | 7 ++++++- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a5d57fb..22a6250 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ default: - image: docker.psi.ch:5000/wall_e/sinqepics:latest + image: docker.psi.ch:5000/sinqdev/sinqepics:latest stages: - lint @@ -13,7 +13,7 @@ cppcheck: artifacts: expire_in: 1 week tags: - - docker + - sinq formatting: stage: lint @@ -22,7 +22,7 @@ formatting: artifacts: expire_in: 1 week tags: - - docker + - sinq # clangtidy: # stage: lint @@ -32,12 +32,13 @@ formatting: # # - dnf install -y clang-tools-extra # # - clang-tidy sinqEPICSApp/src/*.cpp sinqEPICSApp/src/*.c sinqEPICSApp/src/*.h -checks=cppcoreguidelines-*,cert-* # # tags: -# # - docker +# # - sinq build_module: stage: build script: - sed -i 's/ARCH_FILTER=.*/ARCH_FILTER=linux%/' Makefile + - echo "LIBVERSION=${CI_COMMIT_TAG:-0.0.1}" >> Makefile - make install - cp -rT "/ioc/modules/counterbox/$(ls -U /ioc/modules/counterbox/ | head -1)" "./counterbox-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}" artifacts: @@ -47,15 +48,14 @@ build_module: expire_in: 1 week when: always tags: - - docker + - sinq -# TODO I don't know why this fails and gave up debugging for now -# test_module: -# stage: test -# script: -# - mkdir -p "/ioc/modules/counterbox" -# - cp -rT "./counterbox-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}" "/ioc/modules/counterbox/0.0.1" # Seems it needs a number -# - python3 test/test.py -# when: always -# tags: -# - docker +test_module: + stage: test + script: + - mkdir -p "/ioc/modules/counterbox" + - cp -rT "./counterbox-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}" "/ioc/modules/counterbox/${CI_COMMIT_TAG:-0.0.1}" + - python3 test/test.py + when: always + tags: + - sinq diff --git a/scripts/counterbox_4ch.cmd b/scripts/counterbox_4ch.cmd index d0c4d4b..e04fb80 100644 --- a/scripts/counterbox_4ch.cmd +++ b/scripts/counterbox_4ch.cmd @@ -3,11 +3,12 @@ require stream epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT)") +$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc $(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_CNTBOX_HOST", "127.0.0.1:$(CNTBOX_PORT)") $(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT) 4 &" # starting the python socket seems to take a while # and need misc to use built in sleep command -$(SET_SIM_MODE=#) $(SET_SIM_MODE) system 'sleep 3' +$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto") drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) diff --git a/scripts/counterbox_8ch.cmd b/scripts/counterbox_8ch.cmd index a430cc5..7dfbff2 100644 --- a/scripts/counterbox_8ch.cmd +++ b/scripts/counterbox_8ch.cmd @@ -3,11 +3,12 @@ require stream epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT)") +$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc $(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_CNTBOX_HOST", "127.0.0.1:$(CNTBOX_PORT)") $(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT) 10 &" # starting the python socket seems to take a while # and need misc to use built in sleep command -$(SET_SIM_MODE=#) $(SET_SIM_MODE) system 'sleep 3' +$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto") drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) diff --git a/scripts/counterbox_v2.cmd b/scripts/counterbox_v2.cmd index 0471207..da4ea6d 100644 --- a/scripts/counterbox_v2.cmd +++ b/scripts/counterbox_v2.cmd @@ -3,11 +3,12 @@ require stream epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT=2000)") +$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc $(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_CNTBOX_HOST", "127.0.0.1:$(CNTBOX_PORT=2000)") $(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT=2000) 10 &" # starting the python socket seems to take a while # and need misc to use built in sleep command -$(SET_SIM_MODE=#) $(SET_SIM_MODE) system 'sleep 5' +$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto") drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) diff --git a/sim/counterbox_sim.py b/sim/counterbox_sim.py index 898daeb..6f6755a 100644 --- a/sim/counterbox_sim.py +++ b/sim/counterbox_sim.py @@ -80,7 +80,6 @@ class CounterBox: self.presetcount = presetcount self.resetCounts() - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) diff --git a/test/ioc.sh b/test/ioc.sh index 626c851..9236248 100755 --- a/test/ioc.sh +++ b/test/ioc.sh @@ -5,4 +5,4 @@ export EPICS_BASE=/usr/local/epics/base-7.0.7 PARENT_PATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" -"${PARENT_PATH}/st.cmd" +/usr/local/bin/procServ -L - -f -i ^D^C 20001 "${PARENT_PATH}/st.cmd" diff --git a/test/st.cmd b/test/st.cmd index 5d59f9a..afb4067 100755 --- a/test/st.cmd +++ b/test/st.cmd @@ -9,6 +9,6 @@ epicsEnvSet("PREFIX","SQ:TEST") epicsEnvSet("NAME","CB_TEST") epicsEnvSet("SET_SIM_MODE","") # Run Counterbox Simulation Instead of Actual Box -runScript "$(counterbox_DIR)counterbox_v2.cmd" "CNTBOX_IP=localhost, CNTBOX_PORT=2000" +runScript "$(counterbox_DIR)counterbox_v2.cmd" "CNTBOX_IP=127.0.0.1, CNTBOX_PORT=2000" iocInit() diff --git a/test/test.py b/test/test.py index 42717ff..36626cc 100755 --- a/test/test.py +++ b/test/test.py @@ -87,7 +87,7 @@ def testCanCount(prefix, name): def test(prefix, name): # TODO pass prefix and name to script - proc = Popen([f'{os.environ["PARENT_PATH"]}/st.cmd'], stdout=PIPE, stderr=PIPE, shell=False) + proc = Popen([f'{os.environ["PARENT_PATH"]}/ioc.sh'], stdout=PIPE, stderr=PIPE, shell=False) try: stdqueue, errqueue = get_piped_output(proc) @@ -99,6 +99,11 @@ def test(prefix, name): if 'iocRun: All initialization complete' in line: break # IOC is now running + #time.sleep(20) + + print("IOC Initialisation Complete") + print("Starting Tests") + testCanCount(prefix, name) print("Success")