summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yaml
blob: 5702fe2699165648d650ccbb115d94f186214e26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: CI

on:
  pull_request:
    branches:
    - '*'
  push:
    branches:
    - master

defaults:
  run:
    shell: bash

jobs:
  lint:
    runs-on: ubuntu-latest

    env:
      RUSTFLAGS: --deny warnings

    steps:
    - uses: actions/checkout@v4

    - uses: Swatinem/rust-cache@v2

    - name: Clippy
      run: cargo clippy --all --all-targets

    - name: Format
      run: cargo fmt --all -- --check

    - name: Completion Scripts
      run: |
        ./bin/generate-completions
        git diff --no-ext-diff --quiet --exit-code
        ./tests/completions/just.bash

    - name: Install Dependencies
      run: |
        sudo apt-get update
        sudo apt-get install ripgrep shellcheck

    - name: Check for Forbidden Words
      run: ./bin/forbid

    - name: Check Install Script
      run: shellcheck www/install.sh

  pages:
    runs-on: ubuntu-latest
    permissions:
      contents: write

    env:
      RUSTFLAGS: --deny warnings

    steps:
    - uses: actions/checkout@v4

    - uses: Swatinem/rust-cache@v2

    - name: Install `mdbook`
      run: cargo install mdbook

    - name: Install `mdbook-linkcheck`
      run: |
        mkdir -p mdbook-linkcheck
        cd mdbook-linkcheck
        wget https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/latest/download/mdbook-linkcheck.x86_64-unknown-linux-gnu.zip
        unzip mdbook-linkcheck.x86_64-unknown-linux-gnu.zip
        chmod +x mdbook-linkcheck
        pwd >> $GITHUB_PATH

    - name: Build book
      run: |
        cargo run --package generate-book
        mdbook build book/en
        mdbook build book/zh

    - name: Deploy Pages
      uses: peaceiris/actions-gh-pages@v3
      if: github.ref == 'refs/heads/master'
      with:
        github_token: ${{secrets.GITHUB_TOKEN}}
        publish_branch: gh-pages
        publish_dir: www
  test:
    strategy:
      matrix:
        os:
        - ubuntu-latest
        - macos-latest
        - windows-latest

    runs-on: ${{matrix.os}}

    env:
      RUSTFLAGS: --deny warnings

    steps:
    - uses: actions/checkout@v4

    - name: Remove Broken WSL bash executable
      if: ${{ matrix.os == 'windows-latest' }}
      shell: cmd
      run: |
        takeown /F C:\Windows\System32\bash.exe
        icacls C:\Windows\System32\bash.exe /grant administrators:F
        del C:\Windows\System32\bash.exe

    - uses: Swatinem/rust-cache@v2

    - name: Test
      run: cargo test --all

    - name: Test install.sh
      run: |
        bash www/install.sh --to /tmp --tag 1.25.0
        /tmp/just --version