Skip to content

Swarco ITC-2

Swarco ITC-2 #779

Workflow file for this run

name: Swarco ITC-2
on:
pull_request:
types: [ labeled ]
schedule:
# schedule runs only on the default branch. time is in UTC.
# * is a special character in YAML so you have to quote this string.
# run every night at 3:45AM UTC.
- cron: '45 0 * * *'
jobs:
test:
if: ${{ github.event_name == 'schedule' || github.event.label.name == 'equipment' }}
runs-on: ubuntu-22.04
steps:
- name: Install prerequisites
run: |
sudo apt-get update
sudo apt-get -y install gcc-mingw-w64-i686 binfmt-support qemu-user-static xvfb xdotool ffmpeg jq
- name: Install wine32
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo dpkg --add-architecture i386
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libc6:i386 libgcc-s1:i386 libstdc++6:i386 wine
- name: Checkout repo
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems
- name: Download simulator
if: steps.cache-simulator.outputs.cache-hit != 'true'
run: |
mkdir bin
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \
--data-raw '{"shortGUIDs":[{"value":"046MP_5CfrnFI72sUS-jIUQnQ"}]}' --compressed | jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')
wget --quiet -O bin/simulator.exe "$URL"
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \
--data-raw '{"shortGUIDs":[{"value":"0eehofH2tHgAKy3z_FHKO0zaw"}]}' --compressed | jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')
wget --quiet -O bin/rootfs "$URL"
- name: Install simulator
run: |
echo "${{ secrets.ITC2_INSTALL }}" > install.sh
chmod +x install.sh
./install.sh
- name: Apply workaround
run: |
echo -e "#include <stdio.h>\nint main() {fflush(stdout);getchar();return 0;}" > itc.c
i686-w64-mingw32-gcc-win32 itc.c -o itc.exe
mv sim/lib/itc.exe sim/lib/itc-orig.exe
mv itc.exe sim/lib/itc.exe
- name: Install simulator. part 2
run: |
echo "${{ secrets.ITC2_RING }}" > ring
echo "${{ secrets.ITC2_INSTALL2 }}" > install2.sh
chmod +x install2.sh
./install2.sh
- name: Install TLC configuration
run: |
# copy tlc config
cp config/swarco_itc2/*.PTC2 sim
# copy rsmp config
mkdir -p itc_root/home/swarco/rsmp/config
sudo cp config/swarco_itc2/config.json itc_root/home/swarco/rsmp/config/
- name: Start simulator executable
timeout-minutes: 5
working-directory: sim
env:
DISPLAY: :0
run: |
Xvfb & # start display server
nohup wine simulator.exe *.PTC2 >/tmp/itc-sim.log 2>/tmp/itc-sim-2.log &
- name: Start screencast
run: nohup ffmpeg -y -r 5 -f x11grab -s 1280x1024 -i :0+nomouse -c:v libx264rgb -crf 15 -preset:v ultrafast -af aresample=async=1:first_pts=0 output.mkv &
- name: Wait until simulator executable has started
timeout-minutes: 5
run: |
while ! grep -q "File saved." /tmp/itc-sim.log; do sleep 1; done
sleep 1
while ! xdotool search --name "ITC"; do sleep 1; done
sleep 1
env:
DISPLAY: :0
- name: Start simulation
timeout-minutes: 5
run: xdotool search --name "ITC" key --clearmodifiers --delay 200 "ctrl+r"
env:
DISPLAY: :0
- name: Verify that simulation has started
timeout-minutes: 5
env:
LOG: /tmp/itc-sim-2.log
run: while ! grep -q "Start called." $LOG; do sleep 1; done
- name: Start main TLC executable
run: |
export LISTEN=`grep listen /tmp/itc-sim.log | sed 's/.*--listen 0.0.0.0://' | sed 's/ --config.*//'`
export TMP=`grep location /tmp/itc-sim.log | sed 's/.*itc2sim//' | sed 's/\\\itc.xml//' | sed 's/\r//'`
export SIMDIR=~/.wine/drive_c/users/$USER/Temp/itc2sim$TMP
cd ~/.wine/drive_c/users/$USER/Temp/itc2sim$TMP
sed -i '37d' itc.xml
sed -i '36 a\ <communication type="ethernet"><parameters remote-address="127.0.1.1:4000"/></communication>' itc.xml
cd -
cp sim/lib/*.exe $SIMDIR
cp sim/lib/*.dll $SIMDIR
cd ~/.wine/drive_c/users/$USER/Temp/itc2sim$TMP
nohup wine itc-orig.exe --listen 0.0.0.0:$LISTEN --config itc.xml --access itc-cmd-access.xml -v >/dev/null &
cd -
# Start rsmp service
sudo -b chroot itc_root/ /etc/init.d/user-appl-available.d/90_rsmp restart >/dev/null
- name: Wait for simulator to start
timeout-minutes: 5
run: |
LISTEN=`grep listen /tmp/itc-sim.log | sed 's/.*--listen 0.0.0.0://' | sed 's/ --config.*//'`
DATE=`date +%Y-%m-%d`
TIME=`date +%H-%M-%S`
LEVEL1="${{ secrets.ITC2_LEVEL1 }}"
# Set date in TLC
echo -e "LOGIN USER -l 1 $LEVEL1\nF102N1=$DATE\nF101N1=$TIME\nEXIT" | nc localhost $LISTEN
# Wait for simulator to start and completes startup sequence
until `echo -e "ITC\nEXIT" | nc localhost $LISTEN | grep -q -a "3-light"`; do echo Waiting...; sleep 5; done
- name: Run tests
run: bundle exec rspec --format Validator::Brief --format Validator::Details --out log/validation.log spec/site/tlc
env:
SITE_CONFIG: config/swarco_itc2.yaml
- name: Show detailed log
if: always()
run: cat log/validation.log
- name: Rename validation.log
if: always()
run: mv log/validation.log log/validation_itc2_$(date +%F_%H-%M-%S).log
- name: Upload validation.log
if: always()
uses: actions/upload-artifact@v3
with:
name: rspec validation
path: log/validation_itc2_*.log
- name: Upload screencast
if: always()
uses: actions/upload-artifact@v3
with:
name: screencast
path: output.mkv