|
| 1 | +## %CopyrightBegin% |
| 2 | +## |
| 3 | +## SPDX-License-Identifier: Apache-2.0 |
| 4 | +## |
| 5 | +## Copyright Ericsson AB 2024-2026. All Rights Reserved. |
| 6 | +## |
| 7 | +## Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +## you may not use this file except in compliance with the License. |
| 9 | +## You may obtain a copy of the License at |
| 10 | +## |
| 11 | +## http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +## |
| 13 | +## Unless required by applicable law or agreed to in writing, software |
| 14 | +## distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +## See the License for the specific language governing permissions and |
| 17 | +## limitations under the License. |
| 18 | +## |
| 19 | +## %CopyrightEnd% |
| 20 | + |
| 21 | +name: Build and check Erlang/OTP 27 (reusable) |
| 22 | + |
| 23 | +on: |
| 24 | + workflow_call: |
| 25 | + secrets: |
| 26 | + TRIGGER_ERLANG_ORG_BUILD: |
| 27 | + description: 'Token to trigger erlang.org rebuild' |
| 28 | + required: false |
| 29 | + |
| 30 | +## concurrency and env cannot be set in a reusable workflow called via workflow_call; |
| 31 | +## they must be set in the caller workflow. |
| 32 | + |
| 33 | +permissions: |
| 34 | + contents: read |
| 35 | + |
| 36 | +jobs: |
| 37 | + |
| 38 | + setup: |
| 39 | + uses: ./.github/workflows/reusable-setup.yaml |
| 40 | + ## no 'with:' needed - reusable-setup derives everything from github context |
| 41 | + |
| 42 | + pack: |
| 43 | + name: Build Erlang/OTP (64-bit) |
| 44 | + needs: setup |
| 45 | + permissions: |
| 46 | + contents: read |
| 47 | + actions: write |
| 48 | + uses: ./.github/workflows/reusable-pack.yaml |
| 49 | + with: |
| 50 | + base_branch: ${{ needs.setup.outputs.base_branch }} |
| 51 | + full_build_and_check: ${{ needs.setup.outputs.full_build_and_check }} |
| 52 | + bypass_erlang_repo: false |
| 53 | + |
| 54 | + build-macos: |
| 55 | + name: Build Erlang/OTP (macOS) |
| 56 | + needs: pack |
| 57 | + permissions: |
| 58 | + contents: read |
| 59 | + actions: write |
| 60 | + if: needs.pack.outputs.build-c-code == 'true' |
| 61 | + uses: ./.github/workflows/reusable-build-macos.yaml |
| 62 | + with: |
| 63 | + base_branch: ${{ needs.pack.outputs.base_branch }} |
| 64 | + |
| 65 | + build-ios: |
| 66 | + name: Build Erlang/OTP (iOS) |
| 67 | + needs: pack |
| 68 | + if: needs.pack.outputs.build-c-code == 'true' |
| 69 | + permissions: |
| 70 | + contents: read |
| 71 | + actions: write |
| 72 | + uses: ./.github/workflows/reusable-build-ios.yaml |
| 73 | + with: |
| 74 | + base_branch: ${{ needs.pack.outputs.base_branch }} |
| 75 | + |
| 76 | + build-windows: |
| 77 | + name: Build Erlang/OTP (Windows) |
| 78 | + needs: pack |
| 79 | + if: needs.pack.outputs.build-c-code == 'true' |
| 80 | + permissions: |
| 81 | + contents: read |
| 82 | + actions: writ |
| 83 | + uses: ./.github/workflows/reusable-build-windows.yaml |
| 84 | + with: |
| 85 | + base_branch: ${{ needs.pack.outputs.base_branch }} |
| 86 | + |
| 87 | + build-flavors: |
| 88 | + name: Build Erlang/OTP (Types and Flavors) |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: pack |
| 91 | + if: needs.pack.outputs.c-code-changes |
| 92 | + permissions: |
| 93 | + contents: read |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 96 | + - uses: ./.github/actions/build-base-image |
| 97 | + with: |
| 98 | + BASE_BRANCH: ${{ env.BASE_BRANCH }} |
| 99 | + - name: Build Erlang/OTP flavors and types |
| 100 | + run: | |
| 101 | + TYPES="opt debug lcnt" |
| 102 | + FLAVORS="emu jit" |
| 103 | + for TYPE in ${TYPES}; do |
| 104 | + for FLAVOR in ${FLAVORS}; do |
| 105 | + echo "::group::{TYPE=$TYPE FLAVOR=$FLAVOR}" |
| 106 | + docker run otp "make TYPE=$TYPE FLAVOR=$FLAVOR" |
| 107 | + echo "::endgroup::" |
| 108 | + done |
| 109 | + done |
| 110 | +
|
| 111 | + build: |
| 112 | + name: Build Erlang/OTP |
| 113 | + needs: |
| 114 | + - pack |
| 115 | + if: needs.pack.outputs.build-c-code == 'true' |
| 116 | + permissions: |
| 117 | + contents: read |
| 118 | + uses: ./.github/workflows/reusable-build-otp.yaml |
| 119 | + with: |
| 120 | + base_branch: ${{ needs.setup.outputs.base_branch }} |
| 121 | + |
| 122 | + # keep documentation before overhaul (OTP-27) |
| 123 | + documentation: |
| 124 | + name: Build and check documentation |
| 125 | + runs-on: ubuntu-latest |
| 126 | + needs: |
| 127 | + - setup |
| 128 | + - pack |
| 129 | + permissions: |
| 130 | + contents: read |
| 131 | + actions: write |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 134 | + with: |
| 135 | + persist-credentials: false |
| 136 | + - uses: ./.github/actions/build-base-image |
| 137 | + with: |
| 138 | + ## BASE_BRANCH env var is not available here; compute inline |
| 139 | + BASE_BRANCH: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }} |
| 140 | + |
| 141 | + ## Build all the documentation |
| 142 | + - name: Build documentation |
| 143 | + env: |
| 144 | + BASE_URL: ${{ github.event_name == 'pull_request' && |
| 145 | + format('{0}/blob/{1}/',github.event.pull_request.head.repo.full_name,github.event.pull_request.head.ref) || |
| 146 | + format('{0}/blob/{1}/',github.repository,github.ref_name) |
| 147 | + }} |
| 148 | + run: | |
| 149 | + docker build --build-arg BASE_URL="$BASE_URL" -t otp - <<EOF |
| 150 | + FROM otp |
| 151 | + ENV BASE_URL=$BASE_URL |
| 152 | + RUN ./otp_build download_ex_doc |
| 153 | + RUN make release docs release_docs && sudo make install-docs |
| 154 | + EOF |
| 155 | + - name: Release docs to publish |
| 156 | + run: .github/scripts/release-docs.sh |
| 157 | + - name: Upload html documentation archive |
| 158 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 159 | + with: |
| 160 | + name: otp_doc_html |
| 161 | + path: otp_doc_html.tar.gz |
| 162 | + - name: Upload man documentation archive |
| 163 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 164 | + with: |
| 165 | + name: otp_doc_man |
| 166 | + path: otp_doc_man.tar.gz |
| 167 | + - name: Trigger rebuild of erlang.org/docs/ |
| 168 | + if: github.ref_name == 'master' && github.repository == 'erlang/otp' |
| 169 | + env: |
| 170 | + GITHUB_TOKEN: ${{ secrets.TRIGGER_ERLANG_ORG_BUILD }} |
| 171 | + run: | |
| 172 | + curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/erlang/erlang-org/actions/workflows/update-gh-cache.yaml/dispatches" -d '{"ref":"master"}' |
| 173 | + - name: Run html link check |
| 174 | + run: docker run -v $PWD/:/github otp "cd /github/docs && /github/scripts/otp_check_html_links.exs" |
| 175 | + |
| 176 | + static: |
| 177 | + name: Run static analysis |
| 178 | + runs-on: ubuntu-latest |
| 179 | + needs: |
| 180 | + - setup |
| 181 | + - pack |
| 182 | + permissions: |
| 183 | + contents: read |
| 184 | + steps: |
| 185 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 186 | + - uses: ./.github/actions/build-base-image |
| 187 | + with: |
| 188 | + BASE_BRANCH: ${{ env.BASE_BRANCH }} |
| 189 | + - name: Install clang-format |
| 190 | + run: | |
| 191 | + docker build -t otp - <<EOF |
| 192 | + FROM otp |
| 193 | + RUN sudo apt-get install -y clang-format |
| 194 | + EOF |
| 195 | + ## Check formatting of cpp code |
| 196 | + - name: Check format |
| 197 | + run: docker run otp "make format-check" |
| 198 | + ## Run dialyzer |
| 199 | + - name: Run dialyzer |
| 200 | + run: docker run -v $PWD/:/github otp '/github/scripts/run-dialyzer' |
| 201 | + |
| 202 | + # different way to build make prevents us from using reusable-test. |
| 203 | + test: |
| 204 | + name: Test Erlang/OTP |
| 205 | + runs-on: ubuntu-latest |
| 206 | + needs: pack |
| 207 | + if: needs.pack.outputs.changes != '[]' |
| 208 | + permissions: |
| 209 | + contents: read |
| 210 | + actions: write |
| 211 | + strategy: |
| 212 | + matrix: |
| 213 | + type: ${{ fromJson(needs.pack.outputs.changes) }} |
| 214 | + fail-fast: false |
| 215 | + steps: |
| 216 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 217 | + with: |
| 218 | + persist-credentials: false |
| 219 | + - uses: ./.github/actions/build-base-image |
| 220 | + with: |
| 221 | + ## BASE_BRANCH env var is not available here; compute inline |
| 222 | + BASE_BRANCH: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }} |
| 223 | + - name: Run tests |
| 224 | + id: run-tests |
| 225 | + env: |
| 226 | + MATRIX_TYPE: ${{ matrix.type }} |
| 227 | + run: | |
| 228 | + set -x |
| 229 | + mkdir $PWD/make_test_dir |
| 230 | + APP="${MATRIX_TYPE}" |
| 231 | + ## Need to specialize for epmd, emulator and debug |
| 232 | + case "${APP}" in |
| 233 | + emulator) DIR=erts/emulator/ ;; |
| 234 | + epmd) DIR=erts/epmd ;; |
| 235 | + debug) DIR=lib/os_mon; APP=os_mon; TYPE=debug ;; |
| 236 | + *) DIR=lib/${MATRIX_TYPE} ;; |
| 237 | + esac |
| 238 | + ## Remove systemd-coredump |
| 239 | + ! sudo apt remove systemd-coredump |
| 240 | + ## Removing systemd-coredump, caused apport to be installed instead, so we disable it |
| 241 | + ! sudo service apport stop |
| 242 | + sudo bash -c "echo 'core.%p' > /proc/sys/kernel/core_pattern" |
| 243 | + docker run --ulimit core=-1 --ulimit nofile=5000:5000 --pids-limit 1024 \ |
| 244 | + -e CTRUN_TIMEOUT=90 -e SPEC_POSTFIX=gh \ |
| 245 | + -e TEST_NEEDS_RELEASE=true -e "RELEASE_ROOT=/buildroot/otp/Erlang ∅⊤ℝ" \ |
| 246 | + -e EXTRA_ARGS="-ct_hooks cth_surefire [{path,\"/buildroot/otp/$DIR/make_test_dir/${MATRIX_TYPE}_junit.xml\"}]" \ |
| 247 | + -v "$PWD/make_test_dir:/buildroot/otp/$DIR/make_test_dir" \ |
| 248 | + -v "$PWD/scripts:/buildroot/otp/scripts" \ |
| 249 | + otp "make TYPE=${TYPE} && make ${APP}_test TYPE=${TYPE}" |
| 250 | + ## Rename os_mon to debug for debug build |
| 251 | + if [ "$APP" != "${MATRIX_TYPE}" ]; then |
| 252 | + mv make_test_dir/${APP}_test "make_test_dir/${MATRIX_TYPE}_test" |
| 253 | + fi |
| 254 | + - name: Cleanup tests |
| 255 | + if: ${{ !cancelled() }} |
| 256 | + env: |
| 257 | + MATRIX_TYPE: ${{ matrix.type }} |
| 258 | + run: | |
| 259 | + rm -rf make_test_dir/otp || true |
| 260 | + sudo bash -c "chown -R `whoami` make_test_dir && chmod -R +r make_test_dir" |
| 261 | + tar czf ${MATRIX_TYPE}_test_results.tar.gz make_test_dir |
| 262 | + - name: Upload test results |
| 263 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 264 | + if: ${{ !cancelled() }} |
| 265 | + with: |
| 266 | + name: ${{ matrix.type }}_test_results |
| 267 | + path: ${{ matrix.type }}_test_results.tar.gz |
| 268 | + |
| 269 | + system-test: |
| 270 | + name: Test Erlang/OTP (system) |
| 271 | + if: ${{ !cancelled() && needs.pack.result == 'success' }} # Run even if the need has failed |
| 272 | + permissions: |
| 273 | + contents: read |
| 274 | + actions: write |
| 275 | + needs: |
| 276 | + - pack |
| 277 | + - test |
| 278 | + uses: ./.github/workflows/reusable-system-test.yaml |
| 279 | + with: |
| 280 | + base_branch: ${{ needs.pack.outputs.base_branch }} |
| 281 | + |
| 282 | + |
| 283 | + ## If this is an "OTP-*" tag that has been pushed, create a release |
| 284 | + release: |
| 285 | + name: Release Erlang/OTP |
| 286 | + needs: |
| 287 | + - setup |
| 288 | + - documentation |
| 289 | + permissions: |
| 290 | + contents: write |
| 291 | + attestations: write |
| 292 | + id-token: write |
| 293 | + actions: write |
| 294 | + if: startsWith(github.ref, 'refs/tags/OTP-') && github.repository == 'erlang/otp' |
| 295 | + uses: ./.github/workflows/reusable-release.yaml |
| 296 | + with: |
| 297 | + otp_branch: ${{ needs.setup.outputs.otp_version }} |
| 298 | + otp_sbom_version: '' |
| 299 | + tag: ${{ needs.setup.outputs.tag }} |
| 300 | + vsn: ${{ needs.setup.outputs.vsn }} |
| 301 | + secrets: |
| 302 | + TRIGGER_ERLANG_ORG_BUILD: ${{ secrets.TRIGGER_ERLANG_ORG_BUILD }} |
| 303 | + # GITHUB_TOKEN is already available in called workflow. |
| 304 | + |
| 305 | + event_file: |
| 306 | + name: "Event File" |
| 307 | + runs-on: ubuntu-latest |
| 308 | + permissions: |
| 309 | + contents: read |
| 310 | + steps: |
| 311 | + - name: Upload |
| 312 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 313 | + with: |
| 314 | + name: Event File |
| 315 | + path: ${{ github.event_path }} |
0 commit comments