Skip to content

Commit

Permalink
ci: cache rustup and cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
binhtran432k committed Mar 23, 2024
1 parent da45ec9 commit 7eec398
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches:
- main

env:
CARGO_INCREMENTAL: 0

jobs:
build_and_test:
env:
Expand All @@ -22,31 +19,29 @@ jobs:
- name: Checkout respository
uses: actions/checkout@v4

- name: Cache all bin of Cargo
- name: Cache Cargo and Rustup
uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/
~/.rustup/
# The cache should be OS-specific
key: ${{ runner.os }}-website-cargo-bins-$PERSEUS_VERSION

- name: Setup Rust
if: steps.cache.outputs.cache-hit != 'true'
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}

# Only install the binaries if the cache doesn't have them
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install perseus-cli --version $PERSEUS_VERSION

# Also cache all the other Cargo files, since plenty of CI runs won't involve different dependencies
- name: Cache other files Cargo
- name: Cache local build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
dist/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/gh-page.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: Build GitHub Pages

on:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
name: Build Static Site Generation
Expand All @@ -25,45 +29,44 @@ jobs:
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Cache all bin of Cargo
- name: Cache Cargo and Rustup
uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/
~/.rustup/
# The cache should be OS-specific
key: ${{ runner.os }}-website-cargo-bins-$PERSEUS_VERSION

- name: Setup Rust
if: steps.cache.outputs.cache-hit != 'true'
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}

# Only install the binaries if the cache doesn't have them
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install perseus-cli --version $PERSEUS_VERSION

# Also cache all the other Cargo files, since plenty of CI runs won't involve different dependencies
- name: Cache other files Cargo
- name: Cache local build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
dist/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}

- name: Build using Perseus
run: perseus export --release

- name: Hack Browser Router for Github Page
- name: Setup Not Found Page
run: perseus export-error-page -c 404 -o dist/exported/404.html

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./dist/exported/

deploy:
name: Deploy Github Pages
runs-on: ubuntu-latest
Expand Down

0 comments on commit 7eec398

Please sign in to comment.