summaryrefslogtreecommitdiff
path: root/.github/workflows/main.yaml
blob: e2289d8d03e46dd7618ba52be718c84810400d0a (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
##
## This workflow handles testing of pull requests and pushes.
## It also publishes some packages to any new Erlang/OTP release
##
## To speed this up it would be nice if one could share docker
## images inbetween different jobs, but at the moment this is
## not possible so we need to rebuild all of Erlang/OTP multiple
## times.
##
## Also once the windows runner supports WSL we should implement
## support for building Erlang/OTP here.
##
## When ghcr.io support using the GITHUB_TOKEN we should migrate
## over to use it instead as that should allow us to use the
## built-in caching mechanisms of docker/build-push-action@v2.
## However as things are now we use docker directly to make things
## work.
##

name: Build and check Erlang/OTP

on:
  push:
  pull_request:

jobs:

  pack:
    name: Pack the Erlang/OTP tar.gz
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Create initial pre-release tar 
        run: .github/scripts/init-pre-release.sh
      - name: Upload source tar archive
        uses: actions/upload-artifact@v2
        with:
          name: otp_git_archive
          path: otp_src.tar.gz


  build-windows:
    defaults:
      run:
        shell: wsl-bash {0}
    name: Build Erlang/OTP on Windows
    runs-on: windows-latest
    needs: pack
    steps:
      - uses: Vampire/setup-wsl@v1
        with:
          distribution: Ubuntu-18.04

      - name: Install WSL dependencies
        run: apt update && apt install -y g++-mingw-w64 gcc-mingw-w64 make autoconf unzip

      - name: Install openssl
        shell: cmd
        run: |
          choco install openssl
          move "c:\\Program Files\\OpenSSL-Win64" "c:\\OpenSSL-Win64"

      - name: Download wxWidgets
        run: |
          mkdir -p /mnt/c/opt/local64/pgm/
          cd /mnt/c/opt/local64/pgm/
          wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.4/wxWidgets-3.1.4.zip
          unzip wxWidgets-3.1.4.zip -d wxWidgets-3.1.4
          sed -i -r -e 's/wxUSE_POSTSCRIPT +0/wxUSE_POSTSCRIPT 1/' /mnt/c/opt/local64/pgm/wxWidgets-3.1.4/include/wx/msw/setup.h
          sed -i -r -e 's/wxUSE_WEBVIEW_EDGE +0/wxUSE_WEBVIEW_EDGE 1/' /mnt/c/opt/local64/pgm/wxWidgets-3.1.4/include/wx/msw/setup.h

      - name: Install WebView2
        shell: cmd
        run: |
          c:
          cd c:\\opt\\local64\\pgm\\wxWidgets-3.1.4\\3rdparty
          nuget install Microsoft.Web.WebView2 -Version 1.0.705.50
          rename Microsoft.Web.WebView2.1.0.705.50 webview2

      - name: Build wxWidgets
        shell: cmd
        run: |
          c:
          cd c:\\opt\\local64\\pgm\\wxWidgets-3.1.4\\build\\msw
          call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\Auxiliary\\Build\\vcvars64.bat"
          nmake TARGET_CPU=amd64 BUILD=release SHARED=0 DIR_SUFFIX_CPU= -f makefile.vc

      - name: Download source archive
        uses: actions/download-artifact@v2
        with:
          name: otp_git_archive

      - name: Compile Erlang
        run: |
          tar -xzf ./otp_src.tar.gz
          cd otp
          export ERL_TOP=`pwd`
          eval `./otp_build env_win32 x64`
          ./otp_build configure
          if cat erts/CONF_INFO || cat lib/*/CONF_INFO || cat lib/*/SKIP || cat lib/SKIP-APPLICATIONS; then exit 1; fi
          ./otp_build boot -a
          ./otp_build release -a
          cp /mnt/c/opt/local64/pgm/wxWidgets-3.1.4/3rdparty/webview2/runtimes/win-x64/native/WebView2Loader.dll $ERL_TOP/release/win32/erts-*/bin/
          ./otp_build installer_win32

      - name: Upload installer
        uses: actions/upload-artifact@v2
        with:
          name: otp_prebuilt_win32
          path: otp/release/win32/otp*.exe

  build:
    name: Build Erlang/OTP
    runs-on: ubuntu-latest
    needs: pack

    strategy:
      matrix:
        type: [64-bit,32-bit,cross-compile,documentation]
      fail-fast: false

    steps:
      - uses: actions/checkout@v2
      - name: Download source archive
        uses: actions/download-artifact@v2
        with:
          name: otp_git_archive
      - name: Docker login
        uses: docker/login-action@v1
        with:
          registry: docker.pkg.github.com
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Calculate BASE image
        id: base
        run: |
          BASE_TAG=$(grep "^FROM" .github/dockerfiles/Dockerfile.${{ matrix.type }} | head -1 | awk '{print $2}')
          echo "::set-output name=BASE_TAG::${BASE_TAG}"
          .github/scripts/base-tag "${BASE_TAG}"
      - name: Pull BASE image
        run: docker pull ${{ steps.base.outputs.BASE_TAG }}
      - name: Build BASE image
        run: |
          docker build --pull --tag ${{ steps.base.outputs.BASE_TAG }} \
            --cache-from ${{ steps.base.outputs.BASE_TAG }} \
            --file .github/dockerfiles/Dockerfile.${{ steps.base.outputs.BASE_TYPE }} \
            --build-arg BASE=${{ steps.base.outputs.BASE }} .
      - name: Build ${{ matrix.type }} image
        run: |
          docker build --tag otp --file .github/dockerfiles/Dockerfile.${{ matrix.type }} \
            --build-arg ARCHIVE=otp_src.tar.gz .

        ## Smoke build tests
      - if: matrix.type == '32-bit' || matrix.type == '64-bit' || matrix.type == 'cross-compile'
        name: Run smoke test
        run: docker run -v $PWD/scripts:/scripts otp "cd /tests && /scripts/run-smoke-tests"

        ## Documentation checks
      - if: matrix.type == 'documentation'
        name: Run xmllimt
        run: docker run otp "make xmllint"
      - if: matrix.type == 'documentation'
        name: Run html link check
        run: docker run -v $PWD/scripts:/scripts otp "/scripts/otp_html_check /otp doc/index.html"
      - if: matrix.type == 'documentation'
        name: Release docs to publish
        run: .github/scripts/release-docs.sh
      - if: matrix.type == 'documentation'
        name: Upload html documentation archive
        uses: actions/upload-artifact@v2
        with:
          name: otp_doc_html
          path: otp_doc_html.tar.gz
      - if: matrix.type == 'documentation'
        name: Upload man documentation archive
        uses: actions/upload-artifact@v2
        with:
          name: otp_doc_man
          path: otp_doc_man.tar.gz

        ## Check formatting of cpp code
      - if: matrix.type == '64-bit'
        name: Check format
        run: docker run -v $PWD/scripts:/scripts otp "make format-check"
        ## Run dialyzer
      - if: matrix.type == '64-bit'
        name: Run dialyzer
        run: docker run -v $PWD/scripts:/scripts otp "/scripts/run-dialyzer"

        ## Build pre-built tar archives
      - if: matrix.type == '32-bit'
        name: Build pre-built tar archives
        run: |
          docker run -v $PWD:/github otp \
          "scripts/build-otp-tar -o /github/otp_clean_src.tar.gz /github/otp_src.tar.gz -b /buildroot/otp/ /buildroot/otp.tar.gz"
      - if: matrix.type == '32-bit'
        name: Upload pre-built tar archive
        uses: actions/upload-artifact@v2
        with:
          name: otp_prebuilt
          path: otp_src.tar.gz

  ## If this is a tag that has been pushed we do some release work
  release:
    name: Release Erlang/OTP
    runs-on: ubuntu-latest
    needs: build
    if: startsWith(github.ref, 'refs/tags/') && github.repository == 'erlang/otp'
    steps:
      ## This step outputs the tag name and whether the tag is a release or patch
      ## (all releases have only two version identifiers, while patches have three
      ##  or more)
      - name: Get Tag Name
        id: tag
        run: |
          TAG=${GITHUB_REF#refs/tags/}
          IS_RELEASE=`$(echo $TAG | grep -E '^OTP-[0-9]+\.[0-9]+$' > /dev/null) \
            && echo "true" || echo "false"`
          echo "::set-output name=tag::${TAG}"
          echo "::set-output name=release::${IS_RELEASE}"
      
      - uses: actions/checkout@v2

      ## Publish the pre-built archive and docs
      - name: Download source archive
        uses: actions/download-artifact@v2
        with:
          name: otp_prebuilt
      - name: Download html docs
        uses: actions/download-artifact@v2
        with:
          name: otp_doc_html
      - name: Download man docs
        uses: actions/download-artifact@v2
        with:
          name: otp_doc_man

      ## We add the correct version name into the file names
      ## and create the hash files for all assets
      - name: Create pre-build and doc archives
        run: .github/scripts/create-artifacts.sh artifacts ${{ steps.tag.outputs.tag }}

      - name: Build OTP Bundle
        if: steps.tag.outputs.release == 'true'
        run: |
          scripts/bundle-otp ${{ steps.tag.outputs.tag }}

      ## Create hash files
      - name: Create pre-build and doc archives
        run: |
          shopt -s nullglob
          cd artifacts
          md5sum {*.tar.gz,*.txt} > MD5.txt
          sha256sum {*.tar.gz,*.txt} > SHA256.txt

      - name: Upload pre-built and doc tar archives
        uses: softprops/action-gh-release@v1
        with:
          name: OTP ${{ steps.tag.outputs.vsn }}
          files: |
            artifacts/*.tar.gz
            artifacts/*.txt
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}