From da8d7aae121a83b74ecef931af7cd55f661b8ed1 Mon Sep 17 00:00:00 2001 From: Yuri Schimke Date: Sat, 10 Dec 2022 11:52:12 +0000 Subject: [PATCH] Run docs in CI (#7544) --- .github/workflows/docs.yml | 46 ++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ docs/features/https.md | 4 ++-- test_docs.sh | 48 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100755 test_docs.sh diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000000..88764c305707 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,46 @@ +name: build + +on: + push: + branches: + - master + pull_request: + types: [opened, labeled, unlabeled, synchronize] + +permissions: + contents: read + +env: + GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false" + +jobs: + test_docs: + permissions: + checks: write # for actions/upload-artifact + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 11 + + - uses: actions/setup-python@v4 + with: + python-version: 3.x + + - run: pip install mkdocs-material mkdocs-redirects + + - name: Generate Docs + run: ./test_docs.sh + + - uses: actions/upload-artifact@v3 + with: + name: docs + path: site/ diff --git a/.gitignore b/.gitignore index 4a5ee8f25207..511bd1bb7ab9 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ docs/index.md # jenv /.java-version +/site/ +/docs/changelogs/changelog.md diff --git a/docs/features/https.md b/docs/features/https.md index cad16f533ef8..ac9df0d7ce43 100644 --- a/docs/features/https.md +++ b/docs/features/https.md @@ -15,7 +15,7 @@ Specific security vs. connectivity decisions are implemented by [ConnectionSpec] * `COMPATIBLE_TLS` is a secure configuration that connects to secure–but not current–HTTPS servers. * `CLEARTEXT` is an insecure configuration that is used for `http://` URLs. -These loosely follow the model set in [Google Cloud Policies](https://cloud.google.com/load-balancing/docs/ssl-policies-concepts). We [track changes](tls_configuration_history.md) to this policy. +These loosely follow the model set in [Google Cloud Policies](https://cloud.google.com/load-balancing/docs/ssl-policies-concepts). We [track changes](../security/tls_configuration_history.md) to this policy. By default, OkHttp will attempt a `MODERN_TLS` connection. However by configuring the client connectionSpecs you can allow a fall back to `COMPATIBLE_TLS` connection if the modern configuration fails. @@ -58,7 +58,7 @@ Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7f27 ``` You can check a web server's configuration using [Qualys SSL Labs][qualys]. OkHttp's TLS -configuration history is [tracked here](tls_configuration_history.md). +configuration history is [tracked here](../features/tls_configuration_history.md). Applications expected to be installed on older Android devices should consider adopting the [Google Play Services’ ProviderInstaller][provider_installer]. This will increase security for users diff --git a/test_docs.sh b/test_docs.sh new file mode 100755 index 000000000000..95ef7ba6b056 --- /dev/null +++ b/test_docs.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# The website is built using MkDocs with the Material theme. +# https://squidfunk.github.io/mkdocs-material/ +# It requires Python to run. +# Install the packages with the following command: +# pip install mkdocs mkdocs-material mkdocs-redirects + +set -ex + +# Generate the API docs +./gradlew \ + :mockwebserver:dokkaGfm \ + :okhttp-brotli:dokkaGfm \ + :okhttp-dnsoverhttps:dokkaGfm \ + :logging-interceptor:dokkaGfm \ + :okhttp-sse:dokkaGfm \ + :okhttp-tls:dokkaGfm \ + :okhttp-urlconnection:dokkaGfm \ + :okhttp:dokkaGfm + +# Dokka filenames like `-http-url/index.md` don't work well with MkDocs tags. +# Assign metadata to the file's first Markdown heading. +# https://www.mkdocs.org/user-guide/writing-your-docs/#meta-data +title_markdown_file() { + TITLE_PATTERN="s/^[#]+ *(.*)/title: \1 - OkHttp/" + echo "---" > "$1.fixed" + cat $1 | sed -E "$TITLE_PATTERN" | grep "title: " | head -n 1 >> "$1.fixed" + echo "---" >> "$1.fixed" + echo >> "$1.fixed" + cat $1 >> "$1.fixed" + mv "$1.fixed" "$1" +} + +set +x +for MARKDOWN_FILE in $(find docs/4.x -name '*.md'); do + echo $MARKDOWN_FILE + title_markdown_file $MARKDOWN_FILE +done +set -x + +# Copy in special files that GitHub wants in the project root. +cat README.md | grep -v 'project website' > docs/index.md +cp CHANGELOG.md docs/changelogs/changelog.md +cp CONTRIBUTING.md docs/contribute/contributing.md + +# Build the site locally +mkdocs build