mirror of
https://github.com/tsirysndr/music-player.git
synced 2026-01-10 05:37:57 -05:00
ci: fix rust clippy
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import pipeline from "./pipeline.ts";
|
||||
import { build, test } from "./jobs.ts";
|
||||
import { clippy, build, test } from "./jobs.ts";
|
||||
|
||||
export { pipeline, build, test };
|
||||
export { pipeline, clippy, build, test };
|
||||
|
||||
@@ -1,12 +1,53 @@
|
||||
import Client, { connect } from "../../deps.ts";
|
||||
|
||||
export enum Job {
|
||||
clippy = "clippy",
|
||||
test = "test",
|
||||
build = "build",
|
||||
}
|
||||
|
||||
export const exclude = ["target", ".git", ".devbox", ".fluentci"];
|
||||
|
||||
export const clippy = async (src = ".") => {
|
||||
await connect(async (client: Client) => {
|
||||
const context = client.host().directory(src);
|
||||
const ctr = client
|
||||
.pipeline(Job.test)
|
||||
.container()
|
||||
.from("rust:1.73-bookworm")
|
||||
.withExec(["apt-get", "update"])
|
||||
.withExec([
|
||||
"apt-get",
|
||||
"install",
|
||||
"-y",
|
||||
"build-essential",
|
||||
"libasound2-dev",
|
||||
"protobuf-compiler",
|
||||
"pkg-config",
|
||||
])
|
||||
.withExec(["rustup", "component", "add", "clippy"])
|
||||
.withExec(["cargo", "install", "clippy-sarif", "--version", "0.3.0"])
|
||||
.withExec(["cargo", "install", "sarif-fmt", "--version", "0.3.0"])
|
||||
.withDirectory("/app", context, { exclude })
|
||||
.withWorkdir("/app")
|
||||
.withMountedCache("/app/target", client.cacheVolume("target"))
|
||||
.withMountedCache("/root/cargo/registry", client.cacheVolume("registry"))
|
||||
.withExec([
|
||||
"sh",
|
||||
"-c",
|
||||
"cargo clippy \
|
||||
--all-features \
|
||||
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt",
|
||||
]);
|
||||
|
||||
await ctr
|
||||
.file("/app/rust-clippy-results.sarif")
|
||||
.export("./rust-clippy-results.sarif");
|
||||
await ctr.stdout();
|
||||
});
|
||||
return "Done";
|
||||
};
|
||||
|
||||
export const test = async (src = ".") => {
|
||||
await connect(async (client: Client) => {
|
||||
const context = client.host().directory(src);
|
||||
@@ -23,6 +64,7 @@ export const test = async (src = ".") => {
|
||||
"libasound2-dev",
|
||||
"protobuf-compiler",
|
||||
"wget",
|
||||
"pkg-config",
|
||||
])
|
||||
.withExec([
|
||||
"wget",
|
||||
@@ -89,6 +131,7 @@ export const build = async (src = ".") => {
|
||||
"-y",
|
||||
"build-essential",
|
||||
"libasound2-dev",
|
||||
"pkg-config",
|
||||
])
|
||||
.withDirectory("/app", context, { exclude })
|
||||
.withWorkdir("/app/webui/musicplayer")
|
||||
@@ -130,11 +173,13 @@ export type JobExec = (src?: string) =>
|
||||
) => Promise<string>);
|
||||
|
||||
export const runnableJobs: Record<Job, JobExec> = {
|
||||
[Job.clippy]: clippy,
|
||||
[Job.test]: test,
|
||||
[Job.build]: build,
|
||||
};
|
||||
|
||||
export const jobDescriptions: Record<Job, string> = {
|
||||
[Job.clippy]: "Run Rust clippy",
|
||||
[Job.test]: "Run tests",
|
||||
[Job.build]: "Build the project",
|
||||
};
|
||||
|
||||
24
.github/workflows/rust-clippy.yml
vendored
24
.github/workflows/rust-clippy.yml
vendored
@@ -29,27 +29,23 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1
|
||||
- uses: denoland/setup-deno@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
components: clippy
|
||||
override: true
|
||||
|
||||
- name: Install required cargo
|
||||
deno-version: v1.37
|
||||
- name: Setup Fluent CI CLI
|
||||
run: deno install -A -r https://cli.fluentci.io -n fluentci
|
||||
- name: Setup Dagger
|
||||
run: |
|
||||
cargo install clippy-sarif --version 0.3.0
|
||||
cargo install sarif-fmt --version 0.3.0
|
||||
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.8 sh
|
||||
sudo mv bin/dagger /usr/local/bin
|
||||
dagger version
|
||||
|
||||
- name: Run rust-clippy
|
||||
run: cargo clippy
|
||||
--all-features
|
||||
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
|
||||
run: fluentci run . clippy
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload analysis results to GitHub
|
||||
uses: github/codeql-action/upload-sarif@v1
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
with:
|
||||
sarif_file: rust-clippy-results.sarif
|
||||
wait-for-processing: true
|
||||
|
||||
Reference in New Issue
Block a user