-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,56 @@ | ||
name: Basic | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
pull_request: | ||
branches: | ||
- main | ||
- main | ||
push: | ||
branches: | ||
- main | ||
- main | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
prepare: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
cache-key: ${{ steps.cache-key.outputs.key }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Generate cache key | ||
id: cache-key | ||
run: echo "::set-output name=key::${{ runner.os }}-$(date +%Y-%m-%d)-$(git rev-parse --short HEAD)" | ||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
key: ${{ steps.cache-key.outputs.key }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ github.event.pull_request.head.repo.default_branch }}- | ||
${{ runner.os }}- | ||
fmt: | ||
needs: prepare | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Rust environment | ||
run: | | ||
source $HOME/.cargo/env | ||
rustup default nightly | ||
- name: Cargo fmt | ||
run: cargo fmt --all -- --check | ||
- uses: actions/checkout@v4 | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: ./.github/actions/setup | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Use Git CLI for Cargo | ||
run: echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV | ||
|
||
- name: Cargo fmt | ||
run: cargo +nightly fmt --all -- --check | ||
|
||
lint-and-check: | ||
needs: prepare | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Rust environment | ||
run: | | ||
source $HOME/.cargo/env | ||
rustup default nightly | ||
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV | ||
- name: Cargo clippy | ||
run: cargo clippy -- -D warnings | ||
- name: Check Code | ||
run: cargo check | ||
- uses: actions/checkout@v4 | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: ./.github/actions/setup | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Use Git CLI for Cargo | ||
run: echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV | ||
|
||
- name: Cargo clippy | ||
run: cargo +nightly clippy -- -D warnings | ||
|
||
- name: Check Code | ||
run: cargo check |