Merge branch 'customci' into 'master'

Switch to Sinq CI and run tests

See merge request sinq-epics-modules/counterbox!3
This commit is contained in:
2024-11-07 16:30:50 +01:00
8 changed files with 29 additions and 22 deletions

View File

@ -1,5 +1,5 @@
default: default:
image: docker.psi.ch:5000/wall_e/sinqepics:latest image: docker.psi.ch:5000/sinqdev/sinqepics:latest
stages: stages:
- lint - lint
@ -13,7 +13,7 @@ cppcheck:
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
tags: tags:
- docker - sinq
formatting: formatting:
stage: lint stage: lint
@ -22,7 +22,7 @@ formatting:
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
tags: tags:
- docker - sinq
# clangtidy: # clangtidy:
# stage: lint # stage: lint
@ -32,12 +32,13 @@ formatting:
# # - dnf install -y clang-tools-extra # # - dnf install -y clang-tools-extra
# # - clang-tidy sinqEPICSApp/src/*.cpp sinqEPICSApp/src/*.c sinqEPICSApp/src/*.h -checks=cppcoreguidelines-*,cert-* # # - clang-tidy sinqEPICSApp/src/*.cpp sinqEPICSApp/src/*.c sinqEPICSApp/src/*.h -checks=cppcoreguidelines-*,cert-*
# # tags: # # tags:
# # - docker # # - sinq
build_module: build_module:
stage: build stage: build
script: script:
- sed -i 's/ARCH_FILTER=.*/ARCH_FILTER=linux%/' Makefile - sed -i 's/ARCH_FILTER=.*/ARCH_FILTER=linux%/' Makefile
- echo "LIBVERSION=${CI_COMMIT_TAG:-0.0.1}" >> Makefile
- make install - make install
- cp -rT "/ioc/modules/counterbox/$(ls -U /ioc/modules/counterbox/ | head -1)" "./counterbox-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}" - cp -rT "/ioc/modules/counterbox/$(ls -U /ioc/modules/counterbox/ | head -1)" "./counterbox-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
artifacts: artifacts:
@ -47,15 +48,14 @@ build_module:
expire_in: 1 week expire_in: 1 week
when: always when: always
tags: tags:
- docker - sinq
# TODO I don't know why this fails and gave up debugging for now test_module:
# test_module: stage: test
# stage: test script:
# script: - mkdir -p "/ioc/modules/counterbox"
# - mkdir -p "/ioc/modules/counterbox" - cp -rT "./counterbox-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}" "/ioc/modules/counterbox/${CI_COMMIT_TAG:-0.0.1}"
# - 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
# - python3 test/test.py when: always
# when: always tags:
# tags: - sinq
# - docker

View File

@ -3,11 +3,12 @@ require stream
epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT)") 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) 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 &" $(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT) 4 &"
# starting the python socket seems to take a while # starting the python socket seems to take a while
# and need misc to use built in sleep command # 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") epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto")
drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0)

View File

@ -3,11 +3,12 @@ require stream
epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT)") 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) 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 &" $(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT) 10 &"
# starting the python socket seems to take a while # starting the python socket seems to take a while
# and need misc to use built in sleep command # 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") epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto")
drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0)

View File

@ -3,11 +3,12 @@ require stream
epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT=2000)") 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) 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 &" $(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 # starting the python socket seems to take a while
# and need misc to use built in sleep command # 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") epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto")
drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0)

View File

@ -80,7 +80,6 @@ class CounterBox:
self.presetcount = presetcount self.presetcount = presetcount
self.resetCounts() self.resetCounts()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT)) s.bind((HOST, PORT))

View File

@ -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="$( 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"

View File

@ -9,6 +9,6 @@ epicsEnvSet("PREFIX","SQ:TEST")
epicsEnvSet("NAME","CB_TEST") epicsEnvSet("NAME","CB_TEST")
epicsEnvSet("SET_SIM_MODE","") # Run Counterbox Simulation Instead of Actual Box 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() iocInit()

View File

@ -87,7 +87,7 @@ def testCanCount(prefix, name):
def test(prefix, name): def test(prefix, name):
# TODO pass prefix and name to script # 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: try:
stdqueue, errqueue = get_piped_output(proc) stdqueue, errqueue = get_piped_output(proc)
@ -99,6 +99,11 @@ def test(prefix, name):
if 'iocRun: All initialization complete' in line: if 'iocRun: All initialization complete' in line:
break # IOC is now running break # IOC is now running
#time.sleep(20)
print("IOC Initialisation Complete")
print("Starting Tests")
testCanCount(prefix, name) testCanCount(prefix, name)
print("Success") print("Success")