Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub Actions #32

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 63 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,98 @@ on:
types: [tag-release]

jobs:
check-duplicate-runs:
name: Check Duplicate Runs
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- name: Debug
run: 'echo "${{ toJson(github) }}"'
- name: Skip Check
id: skip_check
# uses: fkirc/skip-duplicate-actions@v5 # FIXME: doesn't work?
run: |
if [[ "${{ github.event_name }}" != 'pull_request' || "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]]; then
echo "should_skip=false" >> $GITHUB_ENV
else
echo "should_skip=true" >> $GITHUB_ENV
fi

lint:
name: Lint
needs: [check-duplicate-runs]
if: needs.check-duplicate-runs.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: "true"
profile: minimal
components: rustfmt

- name: Set up cache
uses: Swatinem/rust-cache@v2

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check

test:
name: Test
name: Test (${{ matrix.name }})
needs: [check-duplicate-runs]
if: needs.check-duplicate-runs.outputs.should_skip != 'true'
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
include:
- name: Linux (x86_64)
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: macOS (x86_64)
os: macos-latest
target: x86_64-apple-darwin
- name: macOS (aarch64)
os: macos-latest
target: aarch64-apple-darwin
- name: Windows (x86_64)
os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: "true"
profile: minimal
targets: ${{ matrix.target }}
components: clippy

- name: Cache cargo files
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache cargo files
# uses: actions/cache@v2
# with:
# path: |
# ~/.cargo/bin/
# ~/.cargo/registry/index/
# ~/.cargo/registry/cache/
# ~/.cargo/git/db/
# target/
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Set up cache
uses: Swatinem/rust-cache@v2

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-targets
run: cargo check --all-targets

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: -- --nocapture
run: cargo test -- --nocapture

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
run: cargo clippy -- -D warnings

tag-release:
name: Tag Release
Expand All @@ -92,7 +114,7 @@ jobs:
run: 'echo "${{ toJson(github) }}"'

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}

Expand Down Expand Up @@ -157,7 +179,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ needs.tag-release.outputs.cargo-release-tag }}

Expand Down