From 24593d81184ee076f8174380cae439264b2da2f3 Mon Sep 17 00:00:00 2001
From: Chris Wong <lambda.fairy@gmail.com>
Date: Wed, 23 Dec 2020 19:20:58 +1300
Subject: [PATCH] Switch to GitHub Actions (#244)

Closes #243
---
 .github/workflows/ci.yml | 124 +++++++++++++++++++++++++++++++++++++++
 .travis.yml              |  53 -----------------
 2 files changed, 124 insertions(+), 53 deletions(-)
 create mode 100644 .github/workflows/ci.yml
 delete mode 100644 .travis.yml

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..e1d5d7b
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,124 @@
+name: CI
+
+on:
+  pull_request:
+  push:
+    branches:
+    - master
+  schedule:
+  - cron: '0 1 * * *'
+
+jobs:
+  main:
+    name: Main
+    runs-on: ubuntu-latest
+
+    steps:
+
+    - name: Check out repository
+      uses: actions/checkout@v2
+
+    - name: Install Rust
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: nightly
+        profile: minimal
+        override: true
+        components: clippy
+
+    - name: Run tests
+      run: cargo test --workspace
+
+    - name: Check Clippy
+      # TODO(#209): Use `--all-targets`
+      run: cargo clippy --workspace -- -D warnings
+
+  # Optional features (i.e. web framework integrations) take a long time to
+  # build and rarely break. Speed up CI by checking them separately.
+  all-features:
+    name: All features
+    runs-on: ubuntu-latest
+
+    steps:
+
+    - name: Check out repository
+      uses: actions/checkout@v2
+
+    - name: Install Rust
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: nightly
+        profile: minimal
+        override: true
+
+    - name: Check build
+      run: cargo check --workspace --all-features --all-targets
+
+  benchmarks:
+    name: Benchmarks
+    runs-on: ubuntu-latest
+
+    steps:
+
+    - name: Check out repository
+      uses: actions/checkout@v2
+
+    - name: Install Rust
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: nightly
+        profile: minimal
+        override: true
+
+    - name: Run benchmarks
+      run: cd benchmarks && cargo test --benches --locked
+
+  documentation:
+    name: Documentation
+    runs-on: ubuntu-latest
+
+    steps:
+
+    - name: Check out repository
+      uses: actions/checkout@v2
+      with:
+        # Documentation build uses `git describe` which requires history
+        fetch-depth: 0
+
+    - name: Install Rust
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: nightly
+        profile: minimal
+        override: true
+
+    - name: Build documentation
+      run: cd docs && make -j$(nproc)
+
+  rustfmt:
+    name: Rustfmt
+    runs-on: ubuntu-latest
+
+    steps:
+
+    - name: Check out repository
+      uses: actions/checkout@v2
+
+    - name: Install Rust
+      uses: actions-rs/toolchain@v1
+      with:
+        # rustfmt is often missing on nightly. Since there's little benefit to
+        # using the nightly version, use the more reliable stable build instead.
+        toolchain: stable
+        profile: minimal
+        override: true
+        components: rustfmt
+
+    - name: Check formatting
+      run: |
+        cargo fmt -- --check
+        (cd benchmarks && cargo fmt -- --check)
+        (cd docs && cargo fmt -- --check)
+        # trybuild harnesses are technically not part of the Cargo project, so
+        # need to be checked separately
+        rustfmt --check maud/tests/warnings/*.rs
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1419cbb..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,53 +0,0 @@
-language: rust
-rust: nightly
-virt: lxd
-
-jobs:
-  include:
-    - name: "Main"
-      script:
-        - |
-          RUN_CLIPPY=true
-          rustup component add clippy --toolchain=nightly || RUN_CLIPPY=false
-        - cargo test --workspace
-        - |
-          if $RUN_CLIPPY; then
-            CLIPPY_STATUS=0
-            for package in maud_htmlescape maud_macros maud; do
-              (cd $package && cargo clippy -- -D warnings) || CLIPPY_STATUS=$?
-            done
-            (exit $CLIPPY_STATUS)
-          fi
-    # Optional features (i.e. web framework integrations) take a long time to
-    # build and rarely break. Speed up CI by checking them separately.
-    - name: "All features"
-      script:
-        - cargo check --workspace --all-features --all-targets
-    - name: "Benchmarks"
-      script:
-        - (cd benchmarks && cargo test --benches --locked)
-    - name: "Documentation"
-      script:
-        - (cd docs && make -j$(nproc))
-      deploy:
-        provider: pages
-        edge: true
-        token: $GITHUB_TOKEN
-        fqdn: maud.lambda.xyz
-        local_dir: docs/site
-        keep_history: false
-        on:
-          tags: true
-    - name: "Format"
-      # rustfmt is often missing on nightly. Since there's little benefit to
-      # using the nightly version, use the more reliable stable build instead.
-      rust: stable
-      before_script:
-        - rustup component add rustfmt
-      script:
-        - cargo fmt -- --check
-        - (cd benchmarks && cargo fmt -- --check)
-        - (cd docs && cargo fmt -- --check)
-        # trybuild harnesses are technically not part of the Cargo project, so
-        # need to be checked separately
-        - rustfmt --check maud/tests/warnings/*.rs