Skip to content

Commit

Permalink
ci: fix rust clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Nov 1, 2023
1 parent 1bf66b3 commit 643aeff
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .fluentci/src/dagger/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
45 changes: 45 additions & 0 deletions .fluentci/src/dagger/jobs.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -23,6 +64,7 @@ export const test = async (src = ".") => {
"libasound2-dev",
"protobuf-compiler",
"wget",
"pkg-config",
])
.withExec([
"wget",
Expand Down Expand Up @@ -89,6 +131,7 @@ export const build = async (src = ".") => {
"-y",
"build-essential",
"libasound2-dev",
"pkg-config",
])
.withDirectory("/app", context, { exclude })
.withWorkdir("/app/webui/musicplayer")
Expand Down Expand Up @@ -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 changes: 10 additions & 14 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 643aeff

Please sign in to comment.