aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/Test.yml
blob: 80da7080176d4eddb16a50a3b0ddac4e22ce187e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
name: Test

on:
  push:
  pull_request:
  workflow_dispatch:

env:
  CI: true
  DOCKER_BUILDKIT: 1

jobs:

#
# Doc
#

  doc:
    runs-on: ubuntu-latest
    name: '๐Ÿ““ Docs'
    steps:

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - name: Build ghdl/doc
      run: |
        docker build -t ghdl/doc . -f- <<-EOF
        FROM ghdl/build:buster-mcode
        ENV PYTHONPATH=/opt/ghdl/pyGHDL
        RUN apt update -qq && apt install -y python3-pip gnat-gps graphviz \
         && ln -s /usr/bin/pip3 /usr/bin/pip
        COPY . /opt/ghdl
        RUN cd /opt/ghdl && ./configure && make && make install
        EOF

    - name: Run gnatdoc
      run: |
        cat > run.sh <<-EOF
        #!/usr/bin/env sh
        gnatdoc -P./ghdl
        mkdir /src/public
        mv gnatdoc /src/public/gnatdoc
        EOF
        chmod +x run.sh
        docker run --rm -v $(pwd):/src -w /opt/ghdl ghdl/doc /src/run.sh

    - name: '๐Ÿ““ BuildTheDocs (BTD)'
      if: github.event_name != 'pull_request'
      uses: buildthedocs/btd@v0
      with:
        token: ${{ github.token }}

    #- run: nroff -man doc/_build/man/ghdl.1

    - name: '๐Ÿ“ค Upload artifact: HTML and LaTeX'
      if: github.event_name != 'pull_request'
      uses: actions/upload-artifact@v2
      with:
        name: doc
        path: |
          doc/_build/html
          doc/_build/latex
          doc/_build/man

    - name: '๐Ÿ“ค Upload artifact: ghdl.1'
      if: github.event_name != 'pull_request'
      uses: actions/upload-artifact@v2
      with:
        path: doc/_build/man/ghdl.1

#
# pyGHDL
#

  fmt:
    runs-on: ubuntu-latest
    name: '๐Ÿ pyGHDL'
    steps:

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - name: '๐Ÿ Setup Python'
      uses: actions/setup-python@v2
      with:
        python-version: 3.8

    - name: Install dependencies
      run: |
        sudo apt update -qq
        sudo apt install -y gnat

    - name: Update Python bindings
      run: ./scripts/update_py_bindings.sh

    - name: Check if Python bindings changed
      run: |
        git diff --stat
        git diff --exit-code

#    - run: python -m pip install black
#
#    - run: python -m black --check pyGHDL

#
# GPL
#

  gpl:
    runs-on: ubuntu-latest
    name: '๐Ÿง GPL ยท mcode'
    steps:

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - run: TASK=buster+mcode ./scripts/ci-run.sh -c --gplcompat

#
# GNU/Linux
#

  lin:
    strategy:
      fail-fast: false
      max-parallel: 4
      matrix:
        include: [
          { os: 18, backend: mcode },
          { os: 20, backend: mcode },
          { os: 18, backend: llvm-5.0 },
          { os: 20, backend: llvm-10 },
          { os: 18, backend: gcc-8.3.0 },
          { os: 20, backend: gcc-9.3.0 }
        ]
    name: '๐Ÿง Ubuntu ${{ matrix.os }} ยท ${{ matrix.backend }}'
    runs-on: ubuntu-${{ matrix.os }}.04
    steps:

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - name: '๐Ÿ›ณ๏ธ Build and test GHDL in containers'
      run: |
        TASK=ubuntu${{ matrix.os }}+${{ matrix.backend }} ./scripts/ci-run.sh -c
        mv ghdl-*-ubuntu${{ matrix.os }}-*.tgz ghdl-gha-ubuntu-${{ matrix.os }}.04-$(echo ${{ matrix.backend }} | sed 's#-.*##g').tgz

    - name: '๐Ÿ“ค Upload artifact: package'
      uses: actions/upload-artifact@v2
      with:
        path: ghdl-gha-ubuntu-*.tgz

#
# MacOS
#

  osx:
    strategy:
      fail-fast: false
      max-parallel: 2
      matrix:
        backend:
        - mcode
        - llvm
    runs-on: macOS-latest
    name: '๐ŸŽ macOS ยท ${{ matrix.backend }}'
    steps:

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - name: '๐Ÿ’พ Cache gnat'
      id: cache-gnat
      uses: actions/cache@v2
      with:
        path: gnat
        key: ${{ runner.os }}-gnat

    # Although we cache this, we let the script run to check if the cache is valid (without conditions)
    - name: 'โš™๏ธ Dependencies (brew)'
      run: ./scripts/macosx/install-ada.sh

    - name: '๐Ÿšง Build and test GHDL'
      run: |
        PATH=$PWD/gnat/bin:$PATH
        ./scripts/ci-run.sh -c
        mv ghdl-*.tgz ghdl-osx-${{ matrix.backend }}.tgz
      env:
        TASK: macosx+${{ matrix.backend }}
        GITHUB_OS: ${{ runner.os }}

    - name: '๐Ÿ“ค Upload artifact: package'
      uses: actions/upload-artifact@v2
      with:
        path: ghdl-osx-${{ matrix.backend }}.tgz

#
# Windows Build
#

  win-build:
    runs-on: windows-latest
    strategy:
      fail-fast: false
      max-parallel: 2
      matrix:
        include: [
          {icon: '๐ŸŸฆ', installs: 'MINGW32', arch: i686,   pkg: 'mcode' },
          #{icon: '๐ŸŸฆ', installs: "MINGW32", arch: i686,   pkg: "llvm"  }, ! Not yet functional
          #{icon: '๐ŸŸช', installs: "MINGW64", arch: x86_64, pkg: "mcode" }, ! mcode is not yet supported on win64
          {icon: '๐ŸŸช', installs: 'MINGW64', arch: x86_64, pkg: 'llvm'  },
        ]
    name: '${{ matrix.icon }} Build ยท ${{ matrix.installs }} ยท ${{ matrix.pkg }}'
    env:
      MINGW_INSTALLS: ${{ matrix.installs }}
    defaults:
      run:
        shell: msys2 {0}
    steps:

    - name: '${{ matrix.icon }} Setup MSYS2'
      uses: msys2/setup-msys2@v2
      with:
        msystem: MSYS
        update: true
        install: >
          base-devel
          git
          mingw-w64-${{ matrix.arch }}-toolchain

    - name: 'โš™๏ธ git config'
      run: git config --global core.autocrlf input
      shell: bash

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2
      with:
        # The command 'git describe' (used for version) needs the history.
        fetch-depth: 0

    - name: '๐Ÿšง Build package'
      run: |
        cd scripts/msys2-${{ matrix.pkg }}
        makepkg-mingw --noconfirm --noprogressbar -sCLf

    - name: '๐Ÿ“ค Upload artifact: builddir'
      uses: actions/upload-artifact@v2
      with:
        name: ${{ matrix.installs }}-${{ matrix.pkg }}-builddir
        path: |
          scripts/msys2-${{ matrix.pkg }}/src/
          scripts/msys2-${{ matrix.pkg }}/pkg/

    - name: '๐Ÿ“ค Upload artifact: package'
      uses: actions/upload-artifact@v2
      with:
        path: scripts/msys2-${{ matrix.pkg }}/mingw-*ghdl*.pkg.tar.zst

#
# Windows Test
#

  win-test:
    needs: win-build
    runs-on: windows-latest
    strategy:
      fail-fast: false
      max-parallel: 8
      matrix:
        sys: [
          {icon: '๐ŸŸฆ', installs: 'MINGW32', arch: i686,   pkg: 'mcode' },
          #{icon: '๐ŸŸฆ', installs: "MINGW32", arch: i686,   pkg: "llvm"  }, ! Not yet functional
          #{icon: '๐ŸŸช', installs: "MINGW64", arch: x86_64, pkg: "mcode" }, ! mcode is not yet supported on win64
          {icon: '๐ŸŸช', installs: 'MINGW64', arch: x86_64, pkg: 'llvm'  },
        ]
        suite: [
          'sanity pyunit vpi',
          'gna',
          'vests',
          'synth',
        ]
    name: '${{ matrix.sys.icon }} Test ยท ${{ matrix.sys.installs }} ยท ${{ matrix.sys.pkg }} ยท ${{ matrix.suite }}'
    defaults:
      run:
        shell: msys2 {0}
    steps:

    - name: '${{ matrix.sys.icon }} Setup MSYS2'
      uses: msys2/setup-msys2@v2
      with:
        msystem: ${{ matrix.sys.installs }}
        update: true
        install: >
          mingw-w64-${{ matrix.sys.arch }}-diffutils
          mingw-w64-${{ matrix.sys.arch }}-gcc
          mingw-w64-${{ matrix.sys.arch }}-python-pip

    - name: 'โš™๏ธ git config'
      run: git config --global core.autocrlf input
      shell: bash

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - name: '๐Ÿ“ฅ Download artifact: package'
      uses: actions/download-artifact@v2

    - name: '๐Ÿšง Install package and Python dependencies'
      run: |
        pacman --noconfirm -U artifact/mingw-w64-${{ matrix.sys.arch }}-ghdl-${{ matrix.sys.pkg }}-*.zst
        pip3 install -r testsuite/requirements.txt

    - name: '๐Ÿšง Test package'
      run: GHDL=ghdl ./testsuite/testsuite.sh ${{ matrix.suite }}

#
# Release
#

  Release:
    if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/'))
    needs: [ doc, lin, osx, win-test ]
    runs-on: ubuntu-latest
    name: '๐Ÿ“ฆ Release'
    steps:

    - name: '๐Ÿ“ฅ Download artifacts'
      if: "!contains(github.ref, 'refs/tags/')"
      uses: actions/download-artifact@v2

    # Do not upload assets to tagged releases
    - name: Set list of files for uploading
      id: files
      run: |
        case '${{ github.ref }}' in
          'refs/tags/'*) _list='none' ;;
          *)             _list='artifact/*' ;;
        esac
        echo "::set-output name=list::${_list}"

    # Tagged: create a pre-release or a release (semver)
    # Untagged: update the assets of pre-release 'nightly'
    - uses: eine/tip@master
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        tag: 'nightly'
        files: ${{ steps.files.outputs.list }}

    - run: |
        curl -X POST https://api.github.com/repos/ghdl/docker/dispatches \
        -H "Content-Type: application/json" \
        -H 'Accept: application/vnd.github.everest-preview+json' \
        -H "Authorization: token ${{ secrets.GHDL_BOT }}" \
        --data '{"event_type": "ghdl"}'

#
# Coverage (MINGW64)
#

  coverage:
    needs: win-build
    runs-on: windows-latest
    name: '๐Ÿ“ˆ Coverage'
    defaults:
      run:
        shell: msys2 {0}
    steps:

    - name: '๐ŸŸช Setup MSYS2'
      uses: msys2/setup-msys2@v2
      with:
        msystem: MINGW64
        update: true
        install: mingw-w64-x86_64-python-pip

    - name: 'โš™๏ธ git config'
      run: git config --global core.autocrlf input
      shell: bash

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - name: '๐Ÿ“ฅ Download artifact: package'
      uses: actions/download-artifact@v2

    - name: '๐Ÿšง Install package and Python dependencies'
      run: |
        pacman --noconfirm -U artifact/mingw-w64-x86_64-ghdl-llvm-*.zst
        pip3 install -r testsuite/requirements.txt

    - name: '๐Ÿšง Run tests to generate coverage report'
      run: PYTHONPATH=$(pwd) python3 -m pytest -rA --cov=.. --cov-config=.coveragerc testsuite/pyunit

    - name: Generate XML coverage report
      if: always()
      run: coverage xml

    - name: '๐Ÿ“ค Upload artifact: coverage report'
      if: always()
      uses: actions/upload-artifact@v2
      with:
        name: coverage
        path: coverage.xml

#
# Coverage Publish (Ubuntu)
#

  coverage-publish:
    needs: coverage
    if: always() && github.repository == 'ghdl/ghdl' && github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    name: '๐Ÿ“ฎ Publish coverage report'
    steps:

    - name: '๐Ÿงฐ Checkout'
      uses: actions/checkout@v2

    - name: '๐Ÿ“ฅ Download artifact: coverage report'
      uses: actions/download-artifact@v2
      with:
        name: coverage

    - name: CodeCov
      uses: codecov/codecov-action@v1
      with:
        file: coverage.xml
        flags: unittests

    - name: Codacy
      uses: codacy/codacy-coverage-reporter-action@master
      with:
        project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
        coverage-reports: coverage.xml

#---

# TODO:
# - Re-package a MINGW/MSYS2 package to provide a 'standalone' tarball/zipfile.
#  - https://github.com/ghdl/ghdl/issues/318#issuecomment-286246287
#
# - Add GNAT GPL 32-bit build job with mcode backend