diff --git a/.github/workflows/build_docs/action.yml b/.github/workflows/build_docs/action.yml new file mode 100644 index 00000000000..d44c26f088b --- /dev/null +++ b/.github/workflows/build_docs/action.yml @@ -0,0 +1,94 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2021 The Elixir Team + +name: Build Elixir Documentation +description: Builds ExDoc and generates Elixir documentation + +permissions: + contents: read + +inputs: + otp_version: + description: The exact OTP version (major.minor[.patch]) + required: true + + ex_doc_version: + description: ExDoc version (main or latest_stable) + required: true + + warnings_as_errors: + description: Fails if ExDoc generates warnings + default: "false" + + zip: + description: Whether to zip the docs + default: "false" + +runs: + using: "composite" + steps: + - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 + with: + otp-version: ${{ inputs.otp_version }} + version-type: strict + + - name: Compile Elixir + shell: bash + run: | + make compile + echo "$PWD/bin" >> $GITHUB_PATH + + - name: Build info + shell: bash + run: bin/elixir --version + + - name: Get ExDoc reference + shell: bash + run: | + if [ "${{ inputs.ex_doc_version }}" = "main" ]; then + ref=main + else + ref=v$(curl -s https://hex.pm/api/packages/ex_doc | jq --raw-output '.latest_stable_version') + fi + + echo "EX_DOC_REF=$ref" >> $GITHUB_ENV + + - name: Checkout ExDoc + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + repository: elixir-lang/ex_doc + ref: ${{ env.EX_DOC_REF }} + path: ex_doc + + - name: Compile ExDoc + shell: bash + env: + LANG: C.UTF-8 + run: | + mv ex_doc ../ex_doc + cd ../ex_doc + ../elixir/bin/mix do local.rebar --force + local.hex --force + deps.get + compile && \ + echo "ExDoc successfully built." + + - name: Set DOCS_OPTIONS + shell: bash + run: | + if [[ "${{ inputs.warnings_as_errors }}" == "true" ]]; then + echo "DOCS_OPTIONS=--warnings-as-errors" >> $GITHUB_ENV + else + echo "DOCS_OPTIONS=" >> $GITHUB_ENV + fi + + - name: Build docs + shell: bash + env: + LANG: C.UTF-8 + run: | + cd ../elixir + git fetch --tags + make ${{ inputs.zip == 'true' && 'Docs.zip' || 'docs' }} && \ + if [[ "${{ inputs.warnings_as_errors }}" == "true" ]]; then + echo "Docs successfully generated without warnings." + else + echo "Docs successfully generated." + fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 816ba87aaf0..f3acc4c4d2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,15 +2,27 @@ # SPDX-FileCopyrightText: 2021 The Elixir Team # SPDX-FileCopyrightText: 2012 Plataformatec -name: CI +name: Elixir Building and Testing on: push: - paths-ignore: - - "lib/**/*.md" + paths: &paths-filter + - .github/workflows/ci.yml + - lib/*/test/fixtures/**/**.md + + # Ignore + - "!*.{md,yml,jsonc}" + - "!.git*" + - "!.github/workflows/**/*" + - "!.ort/**/*" + - "!lib/*/pages/**/*.md" + - "!LICENSES/*" + - "!man/*" + pull_request: - paths-ignore: - - "lib/**/*.md" + paths: *paths-filter + + workflow_dispatch: env: ELIXIR_ASSERT_TIMEOUT: 2000 @@ -27,23 +39,35 @@ jobs: strategy: fail-fast: false + matrix: include: + # NOTE: When updating latest Erlang/OTP version, also update it in + # .github/workflows/documentation.yml - otp_version: "28.1" + erlc_opts: "warnings_as_errors" deterministic: true + skip_tests: true + - otp_version: "28.1" erlc_opts: "warnings_as_errors" coverage: true + skip_tests: true + - otp_version: "28.1" - otp_latest: true erlc_opts: "warnings_as_errors" + - otp_version: "27.3" erlc_opts: "warnings_as_errors" + - otp_version: "27.0" erlc_opts: "warnings_as_errors" + - otp_version: "26.0" + - otp_version: master development: true + - otp_version: maint development: true @@ -51,55 +75,58 @@ jobs: # when using warnings_as_errors. So we only set ERLC_OPTS # from Erlang/OTP 27+. env: - ERLC_OPTS: ${{ matrix.erlc_opts || '' }} + ERLC_OPTS: ${{ matrix.erlc_opts }} + steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - fetch-depth: 50 - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 with: otp-version: ${{ matrix.otp_version }} + - name: Set ERL_COMPILER_OPTIONS if: ${{ matrix.deterministic }} run: echo "ERL_COMPILER_OPTIONS=deterministic" >> $GITHUB_ENV + - name: Compile Elixir run: | make compile echo "$PWD/bin" >> $GITHUB_PATH + - name: Build info run: bin/elixir --version + - name: Check format - run: make test_formatted && echo "All Elixir source code files are properly formatted." + if: ${{ !matrix.skip_tests }} + run: | + make test_formatted && \ + echo "All Elixir source code files are properly formatted." + - name: Erlang test suite + if: ${{ !matrix.skip_tests }} run: make test_erlang - continue-on-error: ${{ matrix.development }} + continue-on-error: ${{ matrix.development == true }} + - name: Elixir test suite + if: ${{ matrix.coverage || !matrix.skip_tests }} run: make test_elixir - continue-on-error: ${{ matrix.development }} + continue-on-error: ${{ matrix.development == true }} env: - COVER: "${{ matrix.coverage }}" - - name: "Calculate Coverage" - run: make cover | tee "$GITHUB_STEP_SUMMARY" - if: "${{ matrix.coverage }}" - - name: Build docs (ExDoc main) - if: ${{ matrix.otp_latest }} - run: | - cd .. - git clone https://github.com/elixir-lang/ex_doc.git --depth 1 - cd ex_doc - ../elixir/bin/mix do local.rebar --force + local.hex --force + deps.get + compile - cd ../elixir/ - git fetch --tags - DOCS_OPTIONS="--warnings-as-errors" make docs + COVER: ${{ matrix.coverage }} + - name: Check reproducible builds if: ${{ matrix.deterministic }} run: | rm -rf .git + # Recompile System without .git cd lib/elixir && ../../bin/elixirc -o ebin lib/system.ex && cd - taskset 1 make check_reproducible - - name: "Upload Coverage Artifact" - if: "${{ matrix.coverage }}" + + - name: Calculate Coverage + if: ${{ matrix.coverage }} + run: make cover | tee "$GITHUB_STEP_SUMMARY" + + - name: Upload Coverage Artifact + if: ${{ matrix.coverage }} uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: name: TestCoverage @@ -119,22 +146,29 @@ jobs: steps: - name: Configure Git run: git config --global core.autocrlf input + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - fetch-depth: 50 + - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 with: otp-version: ${{ matrix.otp_version }} + - name: Compile Elixir run: | Remove-Item -Recurse -Force '.git' make compile + - name: Build info run: bin/elixir --version + - name: Check format - run: make test_formatted && echo "All Elixir source code files are properly formatted." + run: | + make test_formatted && \ + echo "All Elixir source code files are properly formatted." + - name: Erlang test suite run: make test_erlang + - name: Elixir test suite run: | Remove-Item 'c:/Windows/System32/drivers/etc/hosts' diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 00000000000..e1855e2ef04 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2021 The Elixir Team + +name: Elixir Documentation + +on: + push: + paths: &paths-filter + - .github/workflows/documentation.yml + - .github/workflows/build_docs/**/* + - CHANGELOG.md + - Makefile + - VERSION + - lib/**/* + + # Ignore + - "!lib/*/test/**/*" + + pull_request: + paths: *paths-filter + + workflow_dispatch: + +permissions: + contents: read + +jobs: + build_docs: + name: Build docs + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + + - name: Build docs + uses: ./.github/workflows/build_docs + with: + otp_version: "28.1" + ex_doc_version: "main" + warnings_as_errors: true diff --git a/.github/workflows/release_pre_built/action.yml b/.github/workflows/release_pre_built/action.yml index a055fe0bf0f..ba960a9c7f4 100644 --- a/.github/workflows/release_pre_built/action.yml +++ b/.github/workflows/release_pre_built/action.yml @@ -13,6 +13,8 @@ inputs: runs: using: "composite" steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + - uses: erlef/setup-beam@5304e04ea2b355f03681464e683d92e3b2f18451 # v1.18.2 with: otp-version: ${{ inputs.otp_version }} @@ -35,33 +37,11 @@ runs: export ELIXIR_ZIP=$PWD/elixir-otp-${{ inputs.otp }}.zip (cd lib/elixir/scripts/windows_installer && ./build.sh) mv lib/elixir/scripts/windows_installer/tmp/elixir-otp-${{ inputs.otp }}.exe . - - name: Get ExDoc ref - if: ${{ inputs.build_docs }} - shell: bash - run: | - if [ "${{ github.ref_name }}" = "main" ]; then - ref=main - else - ref=v$(curl -s https://hex.pm/api/packages/ex_doc | jq --raw-output '.latest_stable_version') - fi - echo "EX_DOC_REF=$ref" >> $GITHUB_ENV - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - if: ${{ inputs.build_docs }} - with: - repository: elixir-lang/ex_doc - ref: ${{ env.EX_DOC_REF }} - path: ex_doc - - name: Build ex_doc - if: ${{ inputs.build_docs }} - shell: bash - run: | - mv ex_doc ../ex_doc - cd ../ex_doc - ../elixir/bin/mix do local.rebar --force + local.hex --force + deps.get + compile - cd ../elixir + - name: Build Docs - if: ${{ inputs.build_docs }} - shell: bash - run: | - git fetch --tags - make Docs.zip + if: inputs.build_docs + uses: ./.github/workflows/build_docs + with: + otp_version: ${{ inputs.otp_version }} + ex_doc_version: ${{ github.ref_name == 'main' && 'main' || 'latest_stable' }} + zip: true