Skip to content
This repository was archived by the owner on Jan 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
73 changes: 73 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CD

on:
push:
branches:
- master

jobs:
deploy:
name: Deploy to GitHub Pages

runs-on: ubuntu-latest

env:
TARGET_BRANCH: gh-pages
PUBLIC_DIR: .book
MDBOOK_VERSION: v0.3.5

steps:
- uses: actions/checkout@v1

- name: Cache rustup
uses: actions/cache@v1
with:
path: ~/.rustup
key: ${{ runner.os }}-rustup

- name: Cache cargo binaries
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }}
restore-key: |
${{ runner.os }}-cargo-bin-

- name: Install stable Rust
run: |
rustup set profile default
rustup update stable
rustup default stable

- name: Download mdBook
run: >
curl -L
"https://github.com/rust-lang/mdBook/releases/download/${MDBOOK_VERSION}/mdbook-${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
| tar zxv

- name: Setup worktree
run: |
rm -rf "${PUBLIC_DIR}"
mkdir "${PUBLIC_DIR}"
git worktree prune
rm -rf ".git/worktrees/${PUBLIC_DIR}/"
git worktree add -B "${TARGET_BRANCH}" "${PUBLIC_DIR}" "origin/${TARGET_BRANCH}"
rm -rf "${PUBLIC_DIR}/*"

- name: Build the book
run: |
./mdbook --version # Show version info
./mdbook build -d __tmp_book
cargo doc --lib --no-deps
mv "target/doc" __tmp_book/
cp -rp __tmp_book/* "${PUBLIC_DIR}/"
rm -rf __tmp_book

- name: Deploy to GitHug Page
run: |
cd "${PUBLIC_DIR}"
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add --all -v
git commit -v -m "Published on ${GITHUB_SHA:0:7} at $(date)" | tee
git push -v -f https://${GITHUB_ACTOR}:${{ secrets.ACCESS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git ${TARGET_BRANCH}
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on:
push:
branches:
- master
pull_request:

jobs:
test:
name: Test

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Before cache
run: |
echo "USER:" $USER

- name: Cache rustup
uses: actions/cache@v1
with:
path: ~/.rustup
key: ${{ runner.os }}-rustup

- name: Cache cargo binaries
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }}
restore-key: |
${{ runner.os }}-cargo-bin-

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

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

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

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

- name: Install stable Rust
run: |
rustup set profile default
rustup update stable
rustup default stable

- name: Test and build
run: |
cargo test --verbose
cargo build --verbose

- name: Lint
run: cargo fmt -- --check # TODO: add clippy
14 changes: 0 additions & 14 deletions .github/workflows/main.yml

This file was deleted.

61 changes: 0 additions & 61 deletions .travis.yml

This file was deleted.

87 changes: 87 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ You can find out more on the [Rust Algorithm Club][main-site] main site. Just pi
This project along with its source code are on [GitHub][source-code] and we are looking forward to your contributions.

[![Rust Edition](https://img.shields.io/badge/Rust_Edition-2018-green.svg)][edition-guide]
[![Build Status](https://travis-ci.com/weihanglo/rust-algorithm-club.svg?token=jBygxQ3kLkkfxSeAJnP2&branch=master)][ci-status]
[![Build Status](https://github.com/weihanglo/rust-algorithm-club/workflows/CI/badge.svg)][ci-status]
[![Documentation](https://img.shields.io/badge/doc-available-blue.svg)][generated-doc]

[swift-algorithm-club]: https://github.com/raywenderlich/swift-algorithm-club
[rust]: https://www.rust-lang.org/
[source-code]: https://github.com/weihanglo/rust-algorithm-club
[main-site]: https://rust-algo.club
[ci-status]: https://travis-ci.com/weihanglo/rust-algorithm-club
[ci-status]: https://github.com/weihanglo/rust-algorithm-club/actions?query=workflow%3ACI
[generated-doc]: https://rust-algo.club/doc/rust_algorithm_club/
[edition-guide]: https://rust-lang-nursery.github.io/edition-guide/rust-2018
[edition-guide]: https://rust-lang.github.io/edition-guide/rust-2018

## Important Links

Expand Down
13 changes: 0 additions & 13 deletions ci/before-deploy.sh

This file was deleted.

10 changes: 0 additions & 10 deletions ci/install.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ci/script.sh

This file was deleted.

10 changes: 6 additions & 4 deletions publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ echo "Removing existing files"
rm -rf "${PUBLIC_DIR}/*"

echo "Generating site"
mdbook build -d _tmp_book
cp -rp _tmp_book/* "${PUBLIC_DIR}/"
rm -rf _tmp_book
mdbook build -d __tmp_book
cargo doc --lib --no-deps
mv "target/doc" __tmp_book/
cp -rp __tmp_book/* "${PUBLIC_DIR}/"
rm -rf __tmp_book

echo "Updating branch ${TARGET_BRANCH}"
cd "${PUBLIC_DIR}" && git add --all && \
git commit -m "Publishing via publish.sh at $(date)" && \
git commit -m "Published via publish.sh at $(date)" && \
git push $1
Loading