| 1 |
name: main |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
pull_request: |
| 8 |
branches: |
| 9 |
- main |
| 10 |
|
| 11 |
jobs: |
| 12 |
|
| 13 |
skip-commit: |
| 14 |
name: Conditionally skip ci |
| 15 |
runs-on: ubuntu-latest |
| 16 |
steps: |
| 17 |
- if: "contains(github.event.head_commit.message, '[skip-ci]') |
| 18 |
|| contains(github.event.head_commit.message, '[skip ci]') |
| 19 |
|| contains(github.event.head_commit.message, '[ci-skip]') |
| 20 |
|| contains(github.event.head_commit.message, '[ci skip]')" |
| 21 |
run: exit 78 |
| 22 |
|
| 23 |
|
| 24 |
cargo-audit: |
| 25 |
name: Run cargo audit |
| 26 |
needs: [skip-commit] |
| 27 |
runs-on: ubuntu-latest |
| 28 |
steps: |
| 29 |
- uses: actions/checkout@v2 |
| 30 |
- name: Fetch latest release version of cargo-audit |
| 31 |
run: | |
| 32 |
mkdir -p .github/caching |
| 33 |
cargo search cargo-audit | grep '^cargo-audit' | awk '{gsub(/"/,"",$3); print $3}' > .github/caching/cargo-audit.lock |
| 34 |
- name: Cache cargo-audit/bin |
| 35 |
id: cache-cargo-audit |
| 36 |
uses: actions/cache@v1 |
| 37 |
with: |
| 38 |
path: ${{ runner.tool_cache }}/cargo-audit/bin |
| 39 |
key: cargo-audit-bin-${{ hashFiles('.github/caching/cargo-audit.lock') }} |
| 40 |
- name: Install cargo-audit |
| 41 |
if: "steps.cache-cargo-audit.outputs.cache-hit != 'true'" |
| 42 |
uses: actions-rs/cargo@v1 |
| 43 |
with: |
| 44 |
command: install |
| 45 |
args: --root ${{ runner.tool_cache }}/cargo-audit --force cargo-audit |
| 46 |
- run: echo "${{ runner.tool_cache }}/cargo-audit/bin" >> $GITHUB_PATH |
| 47 |
- run: cargo audit |
| 48 |
|
| 49 |
|
| 50 |
cargo-clippy: |
| 51 |
name: Run cargo clippy |
| 52 |
needs: [skip-commit] |
| 53 |
runs-on: ubuntu-latest |
| 54 |
env: |
| 55 |
RUST_TOOLCHAIN: stable |
| 56 |
steps: |
| 57 |
- uses: actions/checkout@v2 |
| 58 |
- name: Install Rust toolchain |
| 59 |
uses: actions-rs/toolchain@v1 |
| 60 |
with: |
| 61 |
profile: minimal |
| 62 |
components: clippy |
| 63 |
toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 64 |
override: true |
| 65 |
- name: Run cargo clippy |
| 66 |
uses: actions-rs/clippy-check@v1 |
| 67 |
with: |
| 68 |
token: ${{ secrets.GITHUB_TOKEN }} |
| 69 |
args: --all-features --all-targets --workspace -- -D warnings |
| 70 |
|
| 71 |
|
| 72 |
cargo-docs: |
| 73 |
name: Run cargo docs |
| 74 |
needs: [skip-commit] |
| 75 |
runs-on: ubuntu-latest |
| 76 |
env: |
| 77 |
RUST_TOOLCHAIN: nightly |
| 78 |
steps: |
| 79 |
- uses: actions/checkout@v2 |
| 80 |
- name: Install Rust toolchain |
| 81 |
uses: actions-rs/toolchain@v1 |
| 82 |
with: |
| 83 |
profile: minimal |
| 84 |
toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 85 |
override: true |
| 86 |
- name: Run cargo doc |
| 87 |
uses: actions-rs/cargo@v1 |
| 88 |
with: |
| 89 |
command: doc |
| 90 |
args: --all-features --no-deps |
| 91 |
- uses: peaceiris/actions-gh-pages@v3 |
| 92 |
with: |
| 93 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 94 |
publish_dir: ./target/doc |
| 95 |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 96 |
|
| 97 |
|
| 98 |
cargo-fmt: |
| 99 |
name: Run cargo fmt |
| 100 |
needs: [skip-commit] |
| 101 |
runs-on: ubuntu-latest |
| 102 |
env: |
| 103 |
RUST_TOOLCHAIN: nightly |
| 104 |
steps: |
| 105 |
- uses: actions/checkout@v2 |
| 106 |
- name: Install Rust toolchain |
| 107 |
uses: actions-rs/toolchain@v1 |
| 108 |
with: |
| 109 |
profile: minimal |
| 110 |
components: rustfmt |
| 111 |
toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 112 |
override: true |
| 113 |
- name: Run cargo fmt |
| 114 |
uses: actions-rs/cargo@v1 |
| 115 |
with: |
| 116 |
toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 117 |
command: fmt |
| 118 |
args: --all -- --check |
| 119 |
|
| 120 |
|
| 121 |
cargo-test-coverage: |
| 122 |
name: Run cargo tarpaulin |
| 123 |
needs: [skip-commit] |
| 124 |
runs-on: ubuntu-latest |
| 125 |
env: |
| 126 |
RUST_TOOLCHAIN: nightly |
| 127 |
steps: |
| 128 |
- uses: actions/checkout@v2 |
| 129 |
- name: Install Rust toolchain |
| 130 |
uses: actions-rs/toolchain@v1 |
| 131 |
with: |
| 132 |
profile: minimal |
| 133 |
toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 134 |
override: true |
| 135 |
- name: Fetch latest release version of cargo-tarpaulin |
| 136 |
run: | |
| 137 |
mkdir -p .github/caching |
| 138 |
curl -sL https://api.github.com/repos/xd009642/tarpaulin/releases/latest | jq -r '.name' > .github/caching/cargo-tarpaulin.lock |
| 139 |
- name: Cache cargo-tarpaulin/bin |
| 140 |
id: cache-cargo-tarpaulin |
| 141 |
uses: actions/cache@v1 |
| 142 |
with: |
| 143 |
path: ${{ runner.tool_cache }}/cargo-tarpaulin/bin |
| 144 |
key: cargo-tarpaulin-bin-${{ hashFiles('.github/caching/cargo-tarpaulin.lock') }} |
| 145 |
- name: Install cargo-tarpaulin |
| 146 |
if: "steps.cache-cargo-tarpaulin.outputs.cache-hit != 'true'" |
| 147 |
uses: actions-rs/cargo@v1 |
| 148 |
with: |
| 149 |
command: install |
| 150 |
args: --root ${{ runner.tool_cache }}/cargo-tarpaulin --force cargo-tarpaulin |
| 151 |
- run: echo "${{ runner.tool_cache }}/cargo-tarpaulin/bin" >> $GITHUB_PATH |
| 152 |
- name: Run cargo tarpaulin |
| 153 |
uses: actions-rs/cargo@v1 |
| 154 |
with: |
| 155 |
command: tarpaulin |
| 156 |
args: --all-features |
| 157 |
- name: Upload to codecov.io |
| 158 |
uses: codecov/codecov-action@v1 |
| 159 |
with: |
| 160 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 161 |
fail_ci_if_error: true |
| 162 |
|
| 163 |
|
| 164 |
cargo-test: |
| 165 |
name: Run cargo test |
| 166 |
needs: [skip-commit] |
| 167 |
strategy: |
| 168 |
matrix: |
| 169 |
os: [macos-latest, ubuntu-latest, windows-latest] |
| 170 |
runs-on: ${{ matrix.os }} |
| 171 |
env: |
| 172 |
RUST_TOOLCHAIN: stable |
| 173 |
steps: |
| 174 |
- uses: actions/checkout@v2 |
| 175 |
- name: Install Rust toolchain |
| 176 |
uses: actions-rs/toolchain@v1 |
| 177 |
with: |
| 178 |
profile: minimal |
| 179 |
toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 180 |
override: yes |
| 181 |
- name: Run cargo test |
| 182 |
uses: actions-rs/cargo@v1 |
| 183 |
with: |
| 184 |
command: test |
| 185 |
args: --all-features |
| 186 |
|