|
| 1 | +## |
| 2 | +## This workflow handles testing of pull requests and pushes. |
| 3 | +## It also publishes some packages to any new Erlang/OTP release |
| 4 | +## |
| 5 | +## To speed this up it would be nice if one could share docker |
| 6 | +## images inbetween different jobs, but at the moment this is |
| 7 | +## not possible so we need to rebuild all of Erlang/OTP multiple |
| 8 | +## times. |
| 9 | +## |
| 10 | +## Also once the windows runner supports WSL we should implement |
| 11 | +## support for building Erlang/OTP here. |
| 12 | +## |
| 13 | + |
| 14 | +name: Build, verify and possibly release Erlang/OTP |
| 15 | + |
| 16 | +on: |
| 17 | + push: |
| 18 | + pull_request: |
| 19 | + |
| 20 | +jobs: |
| 21 | + |
| 22 | + pack: |
| 23 | + name: Pack the Erlang/OTP tar.gz |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v2 |
| 27 | + - name: Commit autoconf files |
| 28 | + ## We first commit the autoconf generate so that they |
| 29 | + ## are kept in the pre-built achive |
| 30 | + run: | |
| 31 | + ./otp_build autoconf |
| 32 | + find . -name aclocal.m4 | xargs git add -f |
| 33 | + find . -name configure | xargs git add -f |
| 34 | + find . -name config.h.in | xargs git add -f |
| 35 | + find . -name config.guess | xargs git add -f |
| 36 | + find . -name config.sub | xargs git add -f |
| 37 | + find . -name install-sh | xargs git add -f |
| 38 | + git config --global user.email "[email protected]" |
| 39 | + git config --global user.name "Your Name" |
| 40 | + git commit --no-verify -m 'Add generated configure files' |
| 41 | + - name: Archive git repository |
| 42 | + run: git archive --prefix otp/ -o otp_src.tar.gz HEAD |
| 43 | + - name: Upload source tar archive |
| 44 | + uses: actions/upload-artifact@v2 |
| 45 | + with: |
| 46 | + name: otp_git_archive |
| 47 | + path: otp_src.tar.gz |
| 48 | + |
| 49 | + build: |
| 50 | + name: Build Erlang/OTP |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: pack |
| 53 | + |
| 54 | + strategy: |
| 55 | + matrix: |
| 56 | + type: [64-bit,32-bit,cross-compile,documentation] |
| 57 | + fail-fast: false |
| 58 | + |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v2 |
| 61 | + - name: Download source archive |
| 62 | + uses: actions/download-artifact@v2 |
| 63 | + with: |
| 64 | + name: otp_git_archive |
| 65 | + ## We need to login to the package registry in order to pull |
| 66 | + ## the base debian image. |
| 67 | + - name: Docker login |
| 68 | + run: docker login https://docker.pkg.github.com -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} |
| 69 | + - name: Build ${{ matrix.type }} image |
| 70 | + run: | |
| 71 | + docker build -t otp --build-arg ARCHIVE=otp_src.tar.gz \ |
| 72 | + -f .github/dockerfiles/Dockerfile.${{ matrix.type }} . |
| 73 | +
|
| 74 | + ## Smoke build tests |
| 75 | + - if: matrix.type == '32-bit' || matrix.type == '64-bit' || matrix.type == 'cross-compile' |
| 76 | + name: Run smoke test |
| 77 | + run: | |
| 78 | + docker run -v $PWD/scripts:/scripts otp "cd /tests && /scripts/run-smoke-tests" |
| 79 | +
|
| 80 | + ## Documentation checks |
| 81 | + - if: matrix.type == 'documentation' |
| 82 | + name: Run xmllimt |
| 83 | + run: docker run otp "make xmllint" |
| 84 | + - if: matrix.type == 'documentation' |
| 85 | + name: Run html link check |
| 86 | + run: docker run -v $PWD/scripts:/scripts otp "/scripts/otp_html_check /otp doc/index.html" |
| 87 | + - if: matrix.type == 'documentation' |
| 88 | + name: Run html link check |
| 89 | + run: docker run otp "erlc lib/stdlib/test/shell_docs_SUITE.erl && ct_run -noshell -no_auto_compile -suite shell_docs_SUITE -case render" |
| 90 | + |
| 91 | + ## Run dialyzer |
| 92 | + - if: matrix.type == '64-bit' |
| 93 | + name: Run dialyzer |
| 94 | + run: docker run -v $PWD/scripts:/scripts otp "/scripts/run-dialyzer" |
| 95 | + |
| 96 | + ## Build pre-built tar archives |
| 97 | + - if: matrix.type == '32-bit' |
| 98 | + name: Build pre-built tar archives |
| 99 | + run: | |
| 100 | + docker run -v $PWD:/github otp \ |
| 101 | + "scripts/build-otp-tar -o /github/otp_clean_src.tar.gz /github/otp_src.tar.gz -b /buildroot/otp/ /buildroot/otp.tar.gz" |
| 102 | + - if: matrix.type == '32-bit' |
| 103 | + name: Upload pre-built tar archive |
| 104 | + uses: actions/upload-artifact@v2 |
| 105 | + with: |
| 106 | + name: otp_prebuilt |
| 107 | + path: otp_src.tar.gz |
| 108 | + |
| 109 | + ## If this is a tag that has been pushed we do some release work |
| 110 | + release: |
| 111 | + name: Release Erlang/OTP |
| 112 | + runs-on: ubuntu-latest |
| 113 | + needs: build |
| 114 | + if: startsWith(github.ref, 'refs/tags/') && github.repository == 'garazdawi/otp' |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v2 |
| 117 | + |
| 118 | + ## This step outputs the tag name and whether the tag is a release or patch |
| 119 | + ## (all releases have only two version identifiers, while patches have three |
| 120 | + ## or more) |
| 121 | + - name: Get Tag Name |
| 122 | + id: tag |
| 123 | + run: | |
| 124 | + TAG=${GITHUB_REF#refs/tags/} |
| 125 | + IS_RELEASE=`$(echo $TAG | grep -E '^OTP-[0-9]+\.[0-9]+$' > /dev/null) \ |
| 126 | + && echo "true" || echo "false"` |
| 127 | + echo "::set-output name=tag::$TAG" |
| 128 | + echo "::set-output name=release::${IS_RELEASE}" |
| 129 | +
|
| 130 | + ## Publish the pre-built archive |
| 131 | + - name: Download source archive |
| 132 | + uses: actions/download-artifact@v2 |
| 133 | + with: |
| 134 | + name: otp_prebuilt |
| 135 | + - run: mv otp_src.tar.gz ${{ steps.tag.outputs.tag }}.tar.gz |
| 136 | + - name: Upload pre-built tar archive |
| 137 | + uses: softprops/action-gh-release@v1 |
| 138 | + with: |
| 139 | + files: ${{ steps.tag.outputs.tag }}.tar.gz |
| 140 | + env: |
| 141 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 142 | + |
| 143 | + ## Publish the Erlang/OTP bundle |
| 144 | + - name: Build OTP Bundle |
| 145 | + run: scripts/bundle-otp ${{ steps.tag.outputs.tag }} |
| 146 | + - name: Upload OTP Bundle |
| 147 | + uses: softprops/action-gh-release@v1 |
| 148 | + ## Only provide bundle at major and minor releases |
| 149 | + if: steps.tag.outputs.release == 'true' |
| 150 | + with: |
| 151 | + files: | |
| 152 | + ${{ steps.tag.outputs.tag }}.0-bundle.txt |
| 153 | + ${{ steps.tag.outputs.tag }}.0-bundle.tar.gz |
| 154 | + env: |
| 155 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments