| 1 | name: C2V apps |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - master |
| 7 | paths-ignore: |
| 8 | - '**.md' |
| 9 | - '**.yml' |
| 10 | - '!**/c2v_ci.yml' |
| 11 | - 'doc/**' |
| 12 | - 'examples/**' |
| 13 | - 'tutorials/**' |
| 14 | - 'cmd/tools/**' |
| 15 | - '!cmd/tools/builders/**.v' |
| 16 | pull_request: |
| 17 | paths-ignore: |
| 18 | - '**.md' |
| 19 | - '**.yml' |
| 20 | - '!**/c2v_ci.yml' |
| 21 | - 'doc/**' |
| 22 | - 'examples/**' |
| 23 | - 'tutorials/**' |
| 24 | - 'cmd/tools/**' |
| 25 | - '!cmd/tools/builders/**.v' |
| 26 | |
| 27 | concurrency: |
| 28 | group: c2v-${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} |
| 29 | cancel-in-progress: true |
| 30 | |
| 31 | jobs: |
| 32 | build-doom: |
| 33 | runs-on: ubuntu-24.04 |
| 34 | timeout-minutes: 30 |
| 35 | steps: |
| 36 | - uses: actions/checkout@v6 |
| 37 | - uses: ./.github/actions/cache-apt-packages-action |
| 38 | - name: Build V |
| 39 | run: make && ./v symlink |
| 40 | |
| 41 | - name: Set 8.8.8.8 as dns server |
| 42 | run: | |
| 43 | sudo sed -i 's/#DNS=/DNS=8.8.8.8 8.8.4.4/g' /etc/systemd/resolved.conf |
| 44 | sudo systemctl daemon-reload |
| 45 | sudo systemctl restart systemd-networkd |
| 46 | sudo systemctl restart systemd-resolved |
| 47 | dig distro.ibiblio.org |
| 48 | |
| 49 | - name: Install C2V |
| 50 | run: | |
| 51 | v retry -- v install --git https://github.com/vlang/c2v |
| 52 | v -g ~/.vmodules/c2v/ || true |
| 53 | - name: Install dependencies |
| 54 | run: | |
| 55 | if [ "${{ runner.os }}" == "Linux" ]; then |
| 56 | .github/workflows/disable_azure_mirror.sh |
| 57 | v retry -- sudo apt update -y -qq |
| 58 | v retry -- sudo apt install libsdl2-dev libsdl2-mixer-dev libsdl2-net-dev libpng-dev libsamplerate0-dev |
| 59 | else |
| 60 | v retry -- brew install sdl2 sdl2_mixer sdl2_net libpng libsamplerate |
| 61 | fi |
| 62 | - name: Build original Chocolate Doom |
| 63 | run: | |
| 64 | v retry -- git clone --quiet --depth 1 https://github.com/vlang/doom ~/code/doom |
| 65 | cd ~/code/doom/chocolate-doom |
| 66 | cmake -DCMAKE_BUILD_TYPE=Debug . |
| 67 | make chocolate-doom |
| 68 | - name: Translate the whole game in project/folder mode and compile it |
| 69 | run: | |
| 70 | touch ~/DOOM1.WAD |
| 71 | WAD_FILE=~/DOOM1.WAD ~/code/doom/build_whole_project.sh |
| 72 | |
| 73 | test-regression: |
| 74 | runs-on: ubuntu-24.04 |
| 75 | timeout-minutes: 20 |
| 76 | env: |
| 77 | VFLAGS: -cc tcc |
| 78 | DISPLAY: :99 |
| 79 | LIBGL_ALWAYS_SOFTWARE: true |
| 80 | VTMP: /tmp |
| 81 | steps: |
| 82 | - uses: actions/checkout@v6 |
| 83 | - uses: ./.github/actions/cache-apt-packages-action |
| 84 | - name: Build V |
| 85 | run: make && ./v symlink |
| 86 | |
| 87 | - name: Set 8.8.8.8 as dns server |
| 88 | run: | |
| 89 | sudo sed -i 's/#DNS=/DNS=8.8.8.8 8.8.4.4/g' /etc/systemd/resolved.conf |
| 90 | sudo systemctl daemon-reload |
| 91 | sudo systemctl restart systemd-networkd |
| 92 | sudo systemctl restart systemd-resolved |
| 93 | dig distro.ibiblio.org |
| 94 | |
| 95 | - name: Install C2V |
| 96 | run: | |
| 97 | v retry -- v install --git https://github.com/vlang/c2v |
| 98 | v -g ~/.vmodules/c2v/ || true |
| 99 | - name: Install dependencies |
| 100 | run: | |
| 101 | .github/workflows/disable_azure_mirror.sh |
| 102 | v retry -- sudo apt update -y -qq |
| 103 | v retry -- sudo apt install libsdl2-dev libsdl2-mixer-dev libsdl2-net-dev libpng-dev libsamplerate0-dev |
| 104 | # c2v / DOOM dependencies |
| 105 | # vgret dependencies |
| 106 | # imagemagick : convert, mogrify, import |
| 107 | # xvfb : For starting X11 Virtual FrameBuffers |
| 108 | # openimageio-tools : idiff |
| 109 | # libgl1-mesa-dri : For headless rendering / software DRI driver (LIBGL_ALWAYS_SOFTWARE=true) |
| 110 | # freeglut3-dev : Fixes graphic apps compilation with tcc |
| 111 | v retry -- sudo apt install imagemagick openimageio-tools freeglut3-dev libgl1-mesa-dri xvfb xsel xclip |
| 112 | - name: Setup test tools |
| 113 | run: | |
| 114 | # Fetch the free ~4MB DOOM1.WAD from the link at https://doomwiki.org/wiki/DOOM1.WAD |
| 115 | v retry -- v download https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad |
| 116 | mv doom1.wad ~/doom1.wad |
| 117 | # Get imgur upload script |
| 118 | v retry -- v download https://raw.githubusercontent.com/tremby/imgur.sh/c98345d/imgur.sh |
| 119 | chmod +x ./imgur.sh |
| 120 | # Get regression images to test against |
| 121 | v retry -- git clone https://github.com/Larpon/doom-regression-images |
| 122 | - name: Build original Chocolate Doom |
| 123 | run: | |
| 124 | v retry -- git clone --quiet --depth 1 https://github.com/vlang/doom ~/code/doom |
| 125 | cd ~/code/doom/chocolate-doom |
| 126 | cmake -DCMAKE_BUILD_TYPE=Debug . |
| 127 | make chocolate-doom |
| 128 | - name: Translate the whole game in project/folder mode |
| 129 | run: WAD_FILE=~/doom1.wad ~/code/doom/build_whole_project.sh |
| 130 | - name: Sample and compare with vgret |
| 131 | id: compare |
| 132 | continue-on-error: true |
| 133 | run: | |
| 134 | Xvfb "$DISPLAY" -screen 0 800x600x24 -fbdir /var/tmp/ & |
| 135 | sleep 2; while [ ! -f /var/tmp/Xvfb_screen0 ]; do sleep 0.5; done # give xvfb time to start, even on slow CI runs |
| 136 | sleep 5; v gret -r ~/code/doom -t ./doom-regression-images/vgret.doom.toml -v ./doom-sample_images ./doom-regression-images |
| 137 | - name: Upload regression to imgur |
| 138 | if: steps.compare.outcome != 'success' |
| 139 | run: | |
| 140 | ./imgur.sh /tmp/fail.png |
| 141 | ./imgur.sh /tmp/diff.png |
| 142 | exit 1 |
| 143 | |