1name: CI
2on: [push, pull_request]
3jobs:
4
5
6#  v-fmt:
7#    runs-on: ubuntu-18.04
8#    steps:
9#    - uses: actions/checkout@v2
10#    - name: getting all branch metainfo from github
11#      run: |
12#          git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
13#          echo "Changed files compared to origin/master are:" && git diff --name-status origin/master HEAD -- '*.v'
14#    - name: Build v (there is no need for dependencies for fmt)
15#      run: make -j4
16#    - name: Build a production cmd/tools/vfmt
17#      run: ./v -prod -d vfmt cmd/tools/vfmt.v
18#    - name: Run v fmt -diff on only the changed files. Does NOT fail for now.
19#      run: git diff --name-status origin/master HEAD -- '*.v' |grep -v '^D'|rev|cut -f1|rev| xargs ./v fmt -noerror -diff
20#    - name: Run v test-fmt
21#      run: echo "TODO" #./v test-fmt
22
23  ubuntu-tcc:
24    runs-on: ubuntu-18.04
25    env:
26      VFLAGS: -cc /var/tmp/tcc/bin/tcc -cflags -bt10
27    steps:
28    - uses: actions/checkout@v2
29    - name: Install dependencies
30      run: |
31           sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update;
32           sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev valgrind
33           ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
34    - name: Build v
35      run: |
36        echo $VFLAGS
37        make -j4
38        ./v -cg -o v cmd/v
39    - name: Test v->c
40      run: |
41        sudo ln -s /var/tmp/tcc/bin/tcc /usr/local/bin/tcc
42        tcc -version
43        ./v -cg -o v cmd/v # Make sure vtcc can build itself twice
44#        ./v -silent test-compiler
45    - name: Fixed tests
46      run: ./v test-fixed
47    - name: Test building v tools
48      run: ./v build-tools
49    - name: v vet
50      run: |
51        ./v vet vlib/sqlite
52        ./v vet vlib/v
53    - name: v fmt
54      run: |
55        ./v fmt -verify vlib/v/checker/checker.v
56        ./v fmt -verify vlib/v/fmt/fmt.v
57        ./v fmt -verify vlib/v/parser/parser.v
58        ./v fmt -verify vlib/v/gen/cgen.v
59        ./v fmt -verify vlib/v/gen/x64/gen.v
60#    - name: Test v binaries
61#      run: ./v -silent build-vbinaries
62
63  # Alpine docker pre-built container
64  alpine-docker-musl-gcc:
65    name: alpine-musl
66    runs-on: ubuntu-latest
67    container:
68      image: thevlang/vlang:alpine-build
69      env:
70        V_CI_MUSL: 1
71
72      volumes:
73        - ${{github.workspace}}:/opt/vlang
74    steps:
75      - name: Checkout
76        uses: actions/checkout@v2
77
78      - name: Build V
79        run: |
80          make CC=clang
81      - name: Test V fixed tests
82        run: |
83          v test-fixed
84
85  macos:
86    runs-on: ${{ matrix.os }}
87    strategy:
88      matrix:
89        os: [macOS-latest]
90    steps:
91    - uses: actions/checkout@v2
92    - uses: actions/setup-node@v1
93      with:
94        node-version: 12.x
95    - name: Install dependencies
96      run: |
97        ##brew install libpq openssl freetype ### these are *already installed* on Catalina ...
98        brew uninstall --ignore-dependencies libpq ## libpq is a dependency of PHP
99        brew install postgresql
100        brew install glfw
101        ## brew install sdl2 sdl2_ttf sdl2_mixer sdl2_image
102        export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
103    - name: Build V
104      run:  make -j4 && ./v -cg -o v cmd/v
105    - name: Build V using V
106      run:  ./v -o v2 cmd/v && ./v2 -o v3 cmd/v
107    - name: Test symlink
108      run:  sudo ./v symlink
109#    - name: Set up pg database
110#      run: |
111#        pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
112#        psql -d postgres -c 'select rolname from pg_roles'
113#        psql -d postgres -c 'create database customerdb;'
114#        psql -d customerdb -f examples/database/pg/mydb.sql
115#    - name: Test v->c
116#      run: ./v -silent test-compiler
117#    - name: Test v binaries
118#      run: ./v -silent build-vbinaries
119##    - name: Test v->js
120##      run: ./v -o hi.js examples/hello_v_js.v && node hi.js
121    - name: Test symlink
122      run:  ./v symlink && v -o v2 cmd/v
123    - name: Fixed tests
124      run: ./v test-fixed
125    - name: Build examples
126      run: ./v build-examples
127    - name: Cross-compilation to Linux
128      run: ./v -os linux cmd/v
129#    - name: Test vsh
130#      run:  ./v examples/v_script.vsh
131    - name: Test vid
132      run: |
133        git clone --depth 1 https://github.com/vlang/vid
134        cd vid && ../v -o vid .
135    - name: Build V UI examples
136      run: |
137        git clone --depth 1 https://github.com/vlang/ui
138        cd ui
139        mkdir -p ~/.vmodules
140        ln -s $(pwd) ~/.vmodules/ui
141        ../v examples/rectangles.v
142#        ../v examples/users.v
143#        ../v examples/calculator.v
144
145  ubuntu:
146    runs-on: ubuntu-18.04
147    steps:
148    - uses: actions/checkout@v2
149    - uses: actions/setup-node@v1
150      with:
151        node-version: 12.x
152    - name: Install dependencies
153      run: |
154         sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list;
155         sudo apt-get update;
156         sudo apt-get install --quiet -y postgresql libpq-dev libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev valgrind
157         ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
158    - name: Build V
159      run: make -j4 && ./v -cc gcc -o v cmd/v
160#    - name: Test V
161#      run: ./v -silent test-compiler
162#    - name: Test v binaries
163#      run: ./v -silent build-vbinaries
164##    - name: Test v->js
165##      run: ./v -o hi.js examples/hello_v_js.v && node hi.js
166#    - name: Build Vorum
167#      run: git clone --depth 1 https://github.com/vlang/vorum && cd vorum && ../v . && cd ..
168#    - name: Build vpm
169#      run: git clone --depth 1 https://github.com/vlang/vpm && cd vpm && ../v . && cd ..
170#    - name: Build V UI examples
171#      run: ./v install ui && git clone --depth 1 https://github.com/vlang/ui && cd ui && ../v examples/calculator.v && cd ..
172#    - name: Freestanding
173#      run: ./v -freestanding -o bare vlib/os/bare/bare_example_linux.v
174    - name: v self compilation
175      run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
176    - name: Fixed tests
177      run: |
178        ./v test-fixed
179    - name: Fixed tests (-prod)
180      run: ./v -o vprod -prod cmd/v && ./vprod test-fixed
181    - name: Build examples
182      run: ./v build-examples
183    - name: Build modules
184      run: |
185        ./v build-module vlib/os
186        ./v build-module vlib/builtin
187        ./v build-module vlib/strconv
188    - name: x64 machine code generation
189      run: |
190        exit
191        ./v -o vprod -prod cmd/v
192        cd cmd/tools
193        echo "Generating a 1m line V file..."
194        ../../vprod gen1m.v
195        ./gen1m > 1m.v
196        echo "Building it..."
197        ../../vprod -backend x64 -o 1m 1m.v
198        echo "Running it..."
199        ls
200#    - name: SDL examples
201#      run: git clone --depth 1 https://github.com/vlang/sdl && cd sdl
202
203#        ./1m
204      #run: echo "TODO" #cd examples/x64 && ../../v -x64 hello_world.v && ./hello_world
205#    - name: Coveralls GitHub Action
206#      uses: coverallsapp/github-action@v1.0.1
207#      with:
208#        github-token: ${{ secrets.GITHUB_TOKEN }}
209
210
211  ubuntu-autofree-selfcompile:
212    runs-on: ubuntu-18.04
213    env:
214      VFLAGS: -cc gcc
215    steps:
216    - uses: actions/checkout@v2
217    - name: Build V
218      run: make -j4
219    - name: V self compilation with -autofree
220      run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v
221
222
223  # Ubuntu docker pre-built container
224  ubuntu-musl:
225    name: ubuntu-musl
226    runs-on: ubuntu-latest
227    container:
228      image: thevlang/vlang:ubuntu-build
229      env:
230        V_CI_MUSL: 1
231        V_CI_UBUNTU_MUSL: 1
232        VFLAGS: -cc musl-gcc
233      volumes:
234        - ${{github.workspace}}:/opt/vlang
235    steps:
236      - name: Checkout
237        uses: actions/checkout@v2
238
239      - name: Build V
240        run: |
241          echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
242      - name: Test V fixed tests
243        run: |
244          v test-fixed
245
246#   ubuntu-musl:
247#     runs-on: ubuntu-18.04
248#     env:
249#       VFLAGS: -cc musl-gcc
250#       V_CI_MUSL: 1
251#     steps:
252#     - uses: actions/checkout@v2
253#     - uses: actions/setup-node@v1
254#       with:
255#         node-version: 12.x
256#     - name: Install dependencies
257#       run: |
258#          sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list;
259#          sudo apt-get update;
260#          sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
261#          sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
262#     - name: Build v
263#       run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
264# #    - name: Test v binaries
265# #      run: ./v -silent build-vbinaries
266# ##    - name: Test v->js
267# ##      run: ./v -o hi.js examples/hello_v_js.v && node hi.js
268#     - name: quick debug
269#       run: ./v -stats vlib/strconv/format_test.v
270#     - name: Fixed tests
271#       run: ./v test-fixed
272
273  ubuntu-llvm-mingw:
274    runs-on: ubuntu-18.04
275    steps:
276    - uses: actions/checkout@v2
277#    - name: Cross-compile V
278#      run: docker build . -f Dockerfile.cross
279
280  windows-gcc:
281    runs-on: windows-2019
282    env:
283        VFLAGS: -cc gcc
284    steps:
285    - uses: actions/checkout@v2
286    #- uses: actions/setup-node@v1
287    #  with:
288    #    node-version: 12.x
289    - name: Build
290      run: |
291        gcc --version
292        .\make.bat -gcc
293    - name: Test new v.c
294      run: .\v.exe -o v.c cmd/v && gcc -municode -w v.c
295    - name: Install dependencies
296      run: |
297        .\v.exe setup-freetype
298        .\.github\workflows\windows-install-sqlite.bat
299        ## .\.github\workflows\windows-install-sdl.bat
300    - name: Fixed tests
301      run: |
302        .\v.exe test-fixed
303#    - name: Test
304#      run: |
305#        .\v.exe -silent test-compiler
306      ## v.js dosent work on windows
307        #.\v.exe -o hi.js examples/hello_v_js.v
308        #node hi.js
309#    - name: Test v binaries
310#      run: ./v -silent build-vbinaries
311#    - name: v2 self compilation
312#      run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
313
314  windows-msvc:
315    runs-on: windows-2019
316    env:
317        VFLAGS: -cc msvc
318    steps:
319    - uses: actions/checkout@v2
320    #- uses: actions/setup-node@v1
321    #  with:
322    #    node-version: 12.x
323    - name: Build
324      run: |
325        echo %VFLAGS%
326        echo $VFLAGS
327        .\make.bat -msvc
328    - name: Install dependencies
329      run: |
330        .\v.exe setup-freetype
331        .\.github\workflows\windows-install-sqlite.bat
332        ## .\.github\workflows\windows-install-sdl.bat
333    - name: Fixed tests
334      run: |
335        ./v -cg cmd\tools\vtest-fixed.v
336        ./v test-fixed
337#    - name: Test
338#      run: |
339#        .\v.exe -silent test-compiler
340#      ## v.js dosent work on windows
341        #.\v.exe -o hi.js examples/hello_v_js.v
342        #node hi.js
343#    - name: Test v binaries
344#      run: ./v -silent build-vbinaries
345
346  windows-tcc:
347    runs-on: windows-2019
348    # We are simulating a user with no cc installed.
349    # This way, v's cc detection on Windows is also tested.
350    # env:
351    #   VFLAGS: -cc tcc
352    steps:
353    - uses: actions/checkout@v2
354    #- uses: actions/setup-node@v1
355    #  with:
356    #    node-version: 12.x
357    - name: Build
358      # We need to move gcc and msvc, so that V can't find an existing C compiler and downloads tcc
359      run: |
360        'for /f "usebackq tokens=*" %i in (`where gcc.exe`) do move /Y "%i" "%i.old"'     | cmd
361        'for /f "usebackq tokens=*" %i in (`where vswhere.exe`) do move /Y "%i" "%i.old"' | cmd
362        move "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe.old"
363        .\make.bat
364    - name: Test new v.c
365      run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -w -ladvapi32 -bt10 v.c
366    - name: Install dependencies
367      run: |
368        .\v.exe setup-freetype
369        .\.github\workflows\windows-install-sqlite.bat
370        ## .\.github\workflows\windows-install-sdl.bat
371    - name: Fixed tests
372      run: |
373        .\v.exe test-fixed
374#    - name: Test
375#      run: |
376#        .\v.exe -silent test-compiler
377      ## v.js dosent work on windows
378        #.\v.exe -o hi.js examples/hello_v_js.v
379        #node hi.js
380#    - name: Test v binaries
381#      run: ./v -silent build-vbinaries
382#    - name: v2 self compilation
383#      run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
384
385  docs-line-len-check:
386    runs-on: ubuntu-18.04
387    steps:
388    - uses: actions/checkout@v2
389    - name: Build
390      run: make
391    - name: Check docs line length
392      run: ./v run cmd/tools/check-md.v doc/docs.md CHANGELOG.md
393
394
395  compilable-v-c-and-v-win-c:
396    runs-on: ubuntu-latest
397    steps:
398    - uses: actions/checkout@v2
399    - name: Install dependencies
400      run: |
401        sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list
402        sudo apt-get update
403        sudo apt install --quiet -y mingw-w64 wine-stable winetricks
404    - name: Build V
405      run: make -j4
406    - name: v.c can be compiled and run
407      run: |
408        ./v -os cross -o /tmp/v.c cmd/v
409        gcc  -g -std=gnu11 -w -o v_from_vc /tmp/v.c  -lm -lpthread
410        ls -lart v_from_vc
411        ./v_from_vc version
412    - name: v_win.c can be compiled and run
413      run: |
414        ./v -os windows -o /tmp/v_win.c cmd/v
415        x86_64-w64-mingw32-gcc  /tmp/v_win.c -std=c99 -w -municode -o v_from_vc.exe
416        ls -lart v_from_vc.exe
417        winetricks nocrashdialog
418        wine v_from_vc.exe version
419
420
421  ubuntu-c-plus-plus:
422    runs-on: ubuntu-18.04
423    steps:
424    - uses: actions/checkout@v2
425    - name: Install dependencies
426      run: |
427        sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list;
428        sudo apt-get update;
429        sudo apt-get install --quiet -y postgresql libpq-dev libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev
430        sudo apt-get install --quiet -y valgrind g++-9
431        ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
432    - name: Build V
433      run: make -j4
434    - name: g++ version
435      run: g++-9 --version
436#    - name: Running tests with g++
437#      run: ./v -cc g++-9 test-fixed
438#    - name: V self compilation with g++
439#      run: ./v -cc g++-9 -o v2 cmd/v && ./v2 -cc g++-9 -o v3 cmd/v
440
441  install-modules:
442    runs-on: ubuntu-latest
443    steps:
444    - uses: actions/checkout@v2
445    - name: Install dependencies
446      run: sudo apt-get install --quiet -y libssl-dev
447    - name: Build V
448      run: make -j4
449    - name: Installing V modules
450      run: |
451        ./v install ui
452        ./v install nedpals.args
453
454  gitly-compiles:
455    runs-on: ubuntu-18.04
456    steps:
457    - uses: actions/checkout@v2
458    - name: Install dependencies
459      run: sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev
460    - name: Build V
461      run: make -j2 && ./v -cc gcc -o v cmd/v
462    - name: Install markdown
463      run: ./v install markdown
464    - name: Build Gitly
465      run: |
466        git clone --depth 1 https://github.com/vlang/gitly
467        cd gitly
468        ../v .
469        ../v -autofree .
470        cd ..
471