Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI job to add docs to Github pages #160

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 84 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches: '*'

jobs:

# Build job

build:

strategy:
Expand All @@ -24,7 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v2

## Cache steps
# Build job > Cache steps

- name: Cache cargo registry
uses: actions/cache@v1
Expand All @@ -44,24 +47,27 @@ jobs:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}

## Build and run steps
# Build job > Build and run steps

- name: Build
run: cargo build ${{ matrix.feature-set }} --verbose

- name: Test
run: cargo test ${{ matrix.feature-set }} --verbose

# Formatting job

format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Rust linter
# make this command fail if cargo fmt had to make changes
- name: Rust formatter
## make this command fail if cargo fmt had to make changes
run: cargo fmt && git diff-index --exit-code HEAD


# Linting job (cargo-clippy) - completes and puts warnings inline in PR

lint:
Expand All @@ -81,3 +87,77 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings

# Doc-GH-Pages job

doc_gh_pages:
runs-on: ubuntu-latest

needs: [build, format]

## Only create docs for merges/pushes to master (skip PRs).
## Multiple unfinished PRs should not clobber docs from approved code.
if: github.event_name == 'push' && github.ref == 'refs/heads/master'

steps:
- uses: actions/checkout@v2

# Doc-GH-Pages job > Cache steps

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}

# Doc-GH-Pages job > Generate `cargo doc` step

- name: Cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --release --all-features --no-deps

# Doc-GH-Pages job > Generate dummy root index.html to redirect to `icu4x` crate

- name: Create doc /index.html
run: |
mkdir -p target/doc
cat > target/doc/index.html <<EOL
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0;url=./icu4x" />
<title>ICU4X Developer Docs</title>
</head>
<body>
<p><a href="./icu4x">Redirect to icu4x crate doc</a></p>
</body>
</html>
EOL

# Doc-GH-Pages job > Commit docs on GH Pages branch step

- name: Doc -> Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
# Setup for publishing to an external repo:
# https://github.com/marketplace/actions/github-pages-action#%EF%B8%8F-deploy-to-external-repository
# https://github.com/marketplace/actions/github-pages-action#%EF%B8%8F-create-ssh-deploy-key
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: unicode-org/icu4x-docs
publish_branch: gh-pages
publish_dir: ./target/doc