Skip to content

Commit

Permalink
feat!: cargo-hack support (#123)
Browse files Browse the repository at this point in the history
* chore(ci): bind to specific ubuntu version

* fix: update `rs-actions-core` to 4.0.2, run `npm update`

* feat!: remove `use-cross` arg, replace with `tool`, add `cargo-hack` support

* chore: move to v4.0.0

* chore: improve error logging

* chore: update to `rs-actions-core` 5.0.0, fix issues, add tests

* chore: fix rebase

* chore: fix summary
  • Loading branch information
clechasseur authored Jan 12, 2025
1 parent 709aeb1 commit 6e8219f
Show file tree
Hide file tree
Showing 13 changed files with 521 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

jobs:
check-dist:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Create npm configuration
Expand Down
34 changes: 29 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

jobs:
main:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Create npm configuration
run: echo "//npm.pkg.github.com/:_authToken=${token}" >> ~/.npmrc
Expand All @@ -16,12 +16,18 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: 'npm'
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
components: clippy
matcher: false
rustflags: ""
target: x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
- run: npm ci
- run: npm run build
- run: npm run test

rust-tests-clippy-warnings:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
Expand All @@ -31,10 +37,11 @@ jobs:
rustflags: ""
- uses: ./
with:
args: --all-features
working-directory: rust_tests/clippy_warnings

rust-tests-cross:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
Expand All @@ -45,6 +52,23 @@ jobs:
rustflags: ""
- uses: ./
with:
args: --target aarch64-unknown-linux-gnu
use-cross: true
args: --target aarch64-unknown-linux-gnu --all-features
working-directory: rust_tests/clippy_warnings
tool: cross
cache-key: 'rs-clippy-check-tests'

rust-tests-cargo-hack:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
components: clippy
matcher: false
rustflags: ""
- uses: ./
with:
args: --feature-powerset
working-directory: rust_tests/clippy_warnings
tool: cargo-hack
cache-key: 'rs-clippy-check-tests'
46 changes: 46 additions & 0 deletions __tests__/run.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Input } from '../src/input';
import { run } from '../src/run';

const SECONDS = 1000;

describe('run', () => {
it.each([
{
name: 'rust-tests-clippy-warnings',
input: {
toolchain: 'stable',
args: ['--all-features'],
workingDirectory: 'rust_tests/clippy_warnings',
},
},
{
name: 'rust-tests-cross',
input: {
args: ['--target', 'aarch64-unknown-linux-gnu', '--all-features'],
workingDirectory: 'rust_tests/clippy_warnings',
tool: 'cross',
cacheKey: 'rs-clippy-check-tests',
},
},
{
name: 'rust-tests-cargo-hack',
input: {
args: ['--feature-powerset'],
workingDirectory: 'rust_tests/clippy_warnings',
tool: 'cargo-hack',
cacheKey: 'rs-clippy-check-tests',
},
},
])(
'$name',
async ({ input }: { input: Input }) => {
const inputWithoutCache: Input = {
...input,
...(!process.env.CI && { cacheKey: 'no-cache' }),
};

await expect(run(inputWithoutCache)).resolves.not.toThrow();
},
240 * SECONDS,
);
});
9 changes: 6 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ inputs:
args:
description: Arguments for the cargo clippy command
required: false
use-cross:
description: Use cross instead of cargo
default: false
working-directory:
description: Directory where to perform cargo clippy command
required: false
tool:
description: Tool to use instead of cargo ([`cross`, `cargo-hack`])
required: false
cache-key:
description: Cache key used when using a non-cargo tool
default: rs-clippy-check
runs:
using: 'node20'
main: 'dist/index.js'
Expand Down
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 6e8219f

Please sign in to comment.