From 7b49b69a974f421b6d56b0f1a548b68f1f9387e7 Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Sun, 7 Mar 2021 21:47:48 +0000 Subject: [PATCH 1/2] First go at using GHA to build and publish the book. --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 20 -------------------- CNAME | 1 - ci/after-success.sh | 17 ----------------- ci/install.sh | 18 ------------------ ci/script.sh | 19 ------------------- 6 files changed, 39 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 CNAME delete mode 100644 ci/after-success.sh delete mode 100644 ci/install.sh delete mode 100644 ci/script.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..93f26644 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + branches: [ staging, trying, master ] + pull_request: + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - uses: actions-rs/install@v0.1 + with: + crate: mdbook + version: latest + use-tool-cache: true + - name: Install Python dependencies + run: | + pip3 install --user python-dateutil linkchecker + - name: Put pip binary directory into path + run: echo "~/.local/bin" >> $GITHUB_PATH + - name: Build book + run: mdbook build + - name: Test book + run: mdbook test + - name: Check links + run: linkchecker book + - name: Deploy book + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: book + force_orphan: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 99e54d8d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: rust - -install: - - bash ci/install.sh - -script: - - bash ci/script.sh - -after_success: - - bash ci/after-success.sh - -branches: - only: - - master - - staging - - trying - -notifications: - email: - on_success: never diff --git a/CNAME b/CNAME deleted file mode 100644 index 6d8b1d16..00000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -book.rust-embedded.org \ No newline at end of file diff --git a/ci/after-success.sh b/ci/after-success.sh deleted file mode 100644 index 6a08497b..00000000 --- a/ci/after-success.sh +++ /dev/null @@ -1,17 +0,0 @@ -set -euxo pipefail - -main() { - mkdir ghp-import - curl -Ls https://github.com/davisp/ghp-import/archive/master.tar.gz | - tar --strip-components 1 -C ghp-import -xz - - ./ghp-import/ghp_import.py book - - # NOTE(+x) don't print $GH_TOKEN to the console! - set +x - git push -fq https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git gh-pages && echo OK -} - -if [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ]; then - main -fi diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100644 index 71daa32a..00000000 --- a/ci/install.sh +++ /dev/null @@ -1,18 +0,0 @@ -set -euxo pipefail - -main() { - local tag=$(git ls-remote --tags --refs --exit-code \ - https://github.com/rust-lang/mdbook \ - | cut -d/ -f3 \ - | grep -E '^v[0-9\.]+$' \ - | sort --version-sort \ - | tail -n1) - - curl -LSfs https://japaric.github.io/trust/install.sh | \ - sh -s -- --git rust-lang/mdbook --tag $tag - - pip install python-dateutil --user - pip install linkchecker --user -} - -main diff --git a/ci/script.sh b/ci/script.sh deleted file mode 100644 index 6d9cad34..00000000 --- a/ci/script.sh +++ /dev/null @@ -1,19 +0,0 @@ -set -euxo pipefail - -main() { - mdbook build - mdbook test - - linkchecker book - - # now check this as a directory of the bookshelf - rm -rf shelf - mkdir shelf - mv book shelf - linkchecker shelf - - mv shelf/book . - rmdir shelf -} - -main From 07a9857c48c6714ab31adab00e816e0880668f2a Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Sun, 7 Mar 2021 22:09:59 +0000 Subject: [PATCH 2/2] Cache mdbook build as it takes 5min --- .github/workflows/ci.yml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93f26644..b1e3d552 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,22 +14,40 @@ jobs: with: profile: minimal toolchain: stable - - uses: actions-rs/install@v0.1 - with: - crate: mdbook - version: latest - use-tool-cache: true + - name: Install Python dependencies run: | pip3 install --user python-dateutil linkchecker - name: Put pip binary directory into path run: echo "~/.local/bin" >> $GITHUB_PATH + + - name: Cache Cargo installed binaries + uses: actions/cache@v1 + id: cache-cargo + with: + path: ~/cargo-bin + key: cache-cargo + - name: Install mdbook + if: steps.cache-cargo.outputs.cache-hit != 'true' + uses: actions-rs/install@v0.1 + with: + crate: mdbook + version: latest + - name: Copy mdbook to cache directory + if: steps.cache-cargo.outputs.cache-hit != 'true' + run: | + mkdir ~/cargo-bin + cp ~/.cargo/bin/mdbook ~/cargo-bin + - name: Put new cargo binary directory into path + run: echo "~/cargo-bin" >> $GITHUB_PATH + - name: Build book run: mdbook build - name: Test book run: mdbook test - name: Check links run: linkchecker book + - name: Deploy book if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: peaceiris/actions-gh-pages@v3