Skip to content

Commit 38fe5b9

Browse files
committed
CI: Create docs composite action and rely on it
1 parent e2c4c07 commit 38fe5b9

File tree

4 files changed

+147
-39
lines changed

4 files changed

+147
-39
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: 2021 The Elixir Team
3+
4+
name: Build Elixir Documentation
5+
description: Builds ExDoc and generates Elixir documentation
6+
7+
permissions:
8+
contents: read
9+
10+
inputs:
11+
otp_version:
12+
description: The exact OTP version (major.minor[.patch])
13+
required: true
14+
15+
ex_doc_version:
16+
description: ExDoc version (main or latest_stable)
17+
required: true
18+
19+
warnings_as_errors:
20+
description: Fails if ExDoc generates warnings
21+
default: "false"
22+
23+
zip:
24+
description: Whether to zip the docs
25+
default: "false"
26+
27+
runs:
28+
using: "composite"
29+
steps:
30+
- uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4
31+
with:
32+
otp-version: ${{ inputs.otp_version }}
33+
version-type: strict
34+
35+
- name: Compile Elixir
36+
shell: bash
37+
run: |
38+
make compile
39+
echo "$PWD/bin" >> $GITHUB_PATH
40+
41+
- name: Build info
42+
shell: bash
43+
run: bin/elixir --version
44+
45+
- name: Get ExDoc reference
46+
shell: bash
47+
run: |
48+
if [ "${{ inputs.ex_doc_version }}" = "main" ]; then
49+
ref=main
50+
else
51+
ref=v$(curl -s https://hex.pm/api/packages/ex_doc | jq --raw-output '.latest_stable_version')
52+
fi
53+
54+
echo "EX_DOC_REF=$ref" >> $GITHUB_ENV
55+
56+
- name: Checkout ExDoc
57+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
58+
with:
59+
repository: elixir-lang/ex_doc
60+
ref: ${{ env.EX_DOC_REF }}
61+
path: ex_doc
62+
63+
- name: Compile ExDoc
64+
shell: bash
65+
env:
66+
LANG: C.UTF-8
67+
run: |
68+
mv ex_doc ../ex_doc
69+
cd ../ex_doc
70+
../elixir/bin/mix do local.rebar --force + local.hex --force + deps.get + compile && \
71+
echo "ExDoc successfully built."
72+
73+
- name: Set DOCS_OPTIONS
74+
shell: bash
75+
run: |
76+
if [[ "${{ inputs.warnings_as_errors }}" == "true" ]]; then
77+
echo "DOCS_OPTIONS=--warnings-as-errors" >> $GITHUB_ENV
78+
else
79+
echo "DOCS_OPTIONS=" >> $GITHUB_ENV
80+
fi
81+
82+
- name: Build docs
83+
shell: bash
84+
env:
85+
LANG: C.UTF-8
86+
run: |
87+
cd ../elixir
88+
git fetch --tags
89+
make ${{ inputs.zip == 'true' && 'Docs.zip' || 'docs' }} && \
90+
if [[ "${{ inputs.warnings_as_errors }}" == "true" ]]; then
91+
echo "Docs successfully generated without warnings."
92+
else
93+
echo "Docs successfully generated."
94+
fi

.github/workflows/ci.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
fail-fast: false
3030
matrix:
3131
include:
32+
# NOTE: When updating latest Erlang/OTP version, also update it in
33+
# .github/workflows/documentation.yml
3234
- otp_version: "28.1"
3335
deterministic: true
3436
- otp_version: "28.1"
@@ -78,19 +80,11 @@ jobs:
7880
continue-on-error: ${{ matrix.development }}
7981
env:
8082
COVER: "${{ matrix.coverage }}"
83+
8184
- name: "Calculate Coverage"
8285
run: make cover | tee "$GITHUB_STEP_SUMMARY"
8386
if: "${{ matrix.coverage }}"
84-
- name: Build docs (ExDoc main)
85-
if: ${{ matrix.otp_latest }}
86-
run: |
87-
cd ..
88-
git clone https://github.com/elixir-lang/ex_doc.git --depth 1
89-
cd ex_doc
90-
../elixir/bin/mix do local.rebar --force + local.hex --force + deps.get + compile
91-
cd ../elixir/
92-
git fetch --tags
93-
DOCS_OPTIONS="--warnings-as-errors" make docs
87+
9488
- name: Check reproducible builds
9589
if: ${{ matrix.deterministic }}
9690
run: |
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: 2021 The Elixir Team
3+
4+
name: Elixir Documentation
5+
6+
on:
7+
push:
8+
paths: &paths-filter
9+
- .github/workflows/documentation.yml
10+
- .github/workflows/build_docs/**/*
11+
- CHANGELOG.md
12+
- Makefile
13+
- VERSION
14+
- lib/**/*
15+
16+
# Ignore
17+
- "!lib/*/test/**/*"
18+
19+
pull_request:
20+
paths: *paths-filter
21+
22+
workflow_dispatch:
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
build_docs:
29+
name: Build docs
30+
runs-on: ubuntu-24.04
31+
32+
steps:
33+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
34+
35+
- name: Build docs
36+
uses: ./.github/workflows/build_docs
37+
with:
38+
otp_version: "28.1"
39+
ex_doc_version: "main"
40+
warnings_as_errors: true

.github/workflows/release_pre_built/action.yml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ inputs:
1313
runs:
1414
using: "composite"
1515
steps:
16+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
17+
1618
- uses: erlef/setup-beam@5304e04ea2b355f03681464e683d92e3b2f18451 # v1.18.2
1719
with:
1820
otp-version: ${{ inputs.otp_version }}
@@ -35,33 +37,11 @@ runs:
3537
export ELIXIR_ZIP=$PWD/elixir-otp-${{ inputs.otp }}.zip
3638
(cd lib/elixir/scripts/windows_installer && ./build.sh)
3739
mv lib/elixir/scripts/windows_installer/tmp/elixir-otp-${{ inputs.otp }}.exe .
38-
- name: Get ExDoc ref
39-
if: ${{ inputs.build_docs }}
40-
shell: bash
41-
run: |
42-
if [ "${{ github.ref_name }}" = "main" ]; then
43-
ref=main
44-
else
45-
ref=v$(curl -s https://hex.pm/api/packages/ex_doc | jq --raw-output '.latest_stable_version')
46-
fi
47-
echo "EX_DOC_REF=$ref" >> $GITHUB_ENV
48-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49-
if: ${{ inputs.build_docs }}
50-
with:
51-
repository: elixir-lang/ex_doc
52-
ref: ${{ env.EX_DOC_REF }}
53-
path: ex_doc
54-
- name: Build ex_doc
55-
if: ${{ inputs.build_docs }}
56-
shell: bash
57-
run: |
58-
mv ex_doc ../ex_doc
59-
cd ../ex_doc
60-
../elixir/bin/mix do local.rebar --force + local.hex --force + deps.get + compile
61-
cd ../elixir
40+
6241
- name: Build Docs
63-
if: ${{ inputs.build_docs }}
64-
shell: bash
65-
run: |
66-
git fetch --tags
67-
make Docs.zip
42+
if: inputs.build_docs
43+
uses: ./.github/workflows/build_docs
44+
with:
45+
otp_version: ${{ inputs.otp_version }}
46+
ex_doc_version: ${{ github.ref_name == 'main' && 'main' || 'latest_stable' }}
47+
zip: true

0 commit comments

Comments
 (0)