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

Publish scout #35

Merged
merged 21 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
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
30 changes: 11 additions & 19 deletions .github/workflows/general-rust.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
name: General Rust CI
name: General Rust

on:
push:
branches:
- main
paths:
- "apps/cargo-scout-audit/**"
pull_request:
paths:
- "apps/cargo-scout-audit/**"
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
format:
Expand All @@ -30,7 +21,8 @@ jobs:
run: rustup component add rustfmt

- name: Check Formatting
run: cd apps/cargo-scout-audit && cargo fmt -- --check
working-directory: apps/cargo-scout-audit
run: cargo fmt --all --check

clippy:
name: Lint with Clippy
Expand All @@ -44,10 +36,9 @@ jobs:
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo
./apps/cargo-scout-audit/target
key: ${{ runner.os }}-cargo-${{ hashFiles('apps/cargo-scout-audit/Cargo.lock') }}
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('apps/cargo-scout-audit/Cargo.lock') }}

- name: Update Rust Toolchain
run: rustup update
Expand All @@ -56,7 +47,8 @@ jobs:
run: rustup component add clippy

- name: Lint Code
run: cd apps/cargo-scout-audit && cargo clippy --all-targets --all-features -- -D warnings
working-directory: apps/cargo-scout-audit
run: cargo clippy --all-targets --all-features -- -D warnings

udeps:
name: Check Unused Dependencies with cargo-udeps
Expand All @@ -70,10 +62,9 @@ jobs:
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo
./apps/cargo-scout-audit/target
key: ${{ runner.os }}-cargo-${{ hashFiles('apps/cargo-scout-audit/Cargo.lock') }}
key: ${{ runner.os }}-cargo-udeps-${{ hashFiles('apps/cargo-scout-audit/Cargo.lock') }}

- name: Update Rust Toolchain
run: rustup update
Expand All @@ -82,4 +73,5 @@ jobs:
run: cargo install cargo-udeps

- name: Check Unused Dependencies
run: cd apps/cargo-scout-audit && cargo udeps --all-targets
working-directory: apps/cargo-scout-audit
run: cargo udeps --all-targets
63 changes: 57 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,72 @@ name: Release

on:
push:
tags:
- "v*.*.*"
branches:
- main

env:
CARGO_TERM_COLOR: always
PYTHONUNBUFFERED: 1

jobs:
filter-paths:
name: Filter modified paths by PR
runs-on: ubuntu-latest
outputs:
scout-audit: ${{ steps.filter.outputs.scout_audit }}
dylint-linting: ${{ steps.filter.outputs.dylint_linting }}
clippy-utils: ${{ steps.filter.outputs.clippy_utils }}
clippy-config: ${{ steps.filter.outputs.clippy_config }}
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Filter Paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
scout_audit:
- 'apps/cargo-scout-audit/**'
dylint_linting:
- 'scout-audit-dylint-linting/**'
clippy_utils:
- 'scout-audit-clippy-utils/**'
clippy_config:
- 'scout-audit-clippy-config/**'

release:
name: Release
needs: filter-paths
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests toml

- name: Login to crates.io
run: echo ${{ secrets.CRATES_TOKEN }} | cargo login

- name: Publish to crates.io
run: python scripts/publish-to-crates-io.py
- name: Publish Scout Audit
if: ${{ needs.filter-paths.outputs.scout-audit == 'true' }}
run: python scripts/publish-to-crates-io.py --crate-path apps/cargo-scout-audit

- name: Publish Dylint Linting
if: ${{ needs.filter-paths.outputs.dylint-linting == 'true' }}
run: python scripts/publish-to-crates-io.py --crate-path scout-audit-dylint-linting

- name: Publish Clippy Utils
if: ${{ needs.filter-paths.outputs.clippy-utils == 'true' }}
run: python scripts/publish-to-crates-io.py --crate-path scout-audit-clippy-linting

- name: Publish Clippy Config
if: ${{ needs.filter-paths.outputs.clippy-config == 'true' }}
run: python scripts/publish-to-crates-io.py --crate-path scout-audit-clippy-config
121 changes: 121 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Test Release

on:
pull_request:
branches:
- main
paths:
- "apps/cargo-scout-audit/**"
- "scout-audit-dylint-linting/**"
- "scout-audit-clippy-utils/**"
- "scout-audit-clippy-config/**"

env:
PYTHONUNBUFFERED: 1

jobs:
filter-paths:
name: Filter modified paths by PR
runs-on: ubuntu-latest
outputs:
scout-audit: ${{ steps.filter.outputs.scout_audit }}
dylint-linting: ${{ steps.filter.outputs.dylint_linting }}
clippy-utils: ${{ steps.filter.outputs.clippy_utils }}
clippy-config: ${{ steps.filter.outputs.clippy_config }}
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Filter Paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
scout_audit:
- 'apps/cargo-scout-audit/**'
dylint_linting:
- 'scout-audit-dylint-linting/**'
clippy_utils:
- 'scout-audit-clippy-utils/**'
clippy_config:
- 'scout-audit-clippy-config/**'

test-release:
name: Test dry-run release
needs: filter-paths
runs-on: ubuntu-latest
outputs:
scout-audit: ${{ steps.scout-audit.outputs.result }}
dylint-linting: ${{ steps.dylint-linting.outputs.result }}
clippy-utils: ${{ steps.clippy-utils.outputs.result }}
clippy-config: ${{ steps.clippy-config.outputs.result }}
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests toml

- name: Test Scout Audit
id: scout-audit
if: ${{ needs.filter-paths.outputs.scout-audit == 'true' }}
run: |
python scripts/publish-to-crates-io.py --crate-path apps/cargo-scout-audit --dry-run
echo "result=success" >> $GITHUB_OUTPUT

- name: Test Dylint Linting
id: dylint-linting
if: ${{ needs.filter-paths.outputs.dylint-linting == 'true' }}
run: |
python scripts/publish-to-crates-io.py --crate-path scout-audit-dylint-linting --dry-run
echo "result=success" >> $GITHUB_OUTPUT

- name: Test Clippy Utils
id: clippy-utils
if: ${{ needs.filter-paths.outputs.clippy-utils == 'true' }}
run: |
python scripts/publish-to-crates-io.py --crate-path scout-audit-clippy-linting --dry-run
echo "result=success" >> $GITHUB_OUTPUT

- name: Test Clippy Config
id: clippy-config
if: ${{ needs.filter-paths.outputs.clippy-config == 'true' }}
run: |
python scripts/publish-to-crates-io.py --crate-path scout-audit-clippy-config --dry-run
echo "result=success" >> $GITHUB_OUTPUT

comment-on-pr:
name: Comment on PR about release status
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [filter-paths, test-release]
steps:
- name: Find existing comment
id: find_comment
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "🚀 Release Dry-Run Summary"

- name: Create or Update PR Comment
uses: peter-evans/create-or-update-comment@v4.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
edit-mode: replace
issue-number: ${{ github.event.pull_request.number }}
body: |
## 🚀 Release Dry-Run Summary
| Crate | Release Status | Dry Run Status |
| --- | --- | --- |
| [cargo-scout-audit](https://crates.io/crates/cargo-scout-audit) | ${{ needs.filter-paths.outputs.scout-audit == 'true' && '🟢 Releasing' || '🔴 Not Releasing' }} | ${{ needs.filter-paths.outputs.scout-audit == 'true' && (needs.test-release.outputs.scout-audit == 'success' && '✅ Successful' || '❌ Failed') || 'N/A' }} |
| [scout-audit-dylint-linting](https://crates.io/crates/scout-audit-dylint-linting) | ${{ needs.filter-paths.outputs.dylint-linting == 'true' && '🟢 Releasing' || '🔴 Not Releasing' }} | ${{ needs.filter-paths.outputs.dylint-linting == 'true' && (needs.test-release.outputs.dylint-linting == 'success' && '✅ Successful' || '❌ Failed') || 'N/A' }} |
| [scout-audit-clippy-utils](https://crates.io/crates/scout-audit-clippy-utils) | ${{ needs.filter-paths.outputs.clippy-utils == 'true' && '🟢 Releasing' || '🔴 Not Releasing' }} | ${{ needs.filter-paths.outputs.clippy-utils == 'true' && (needs.test-release.outputs.clippy-utils == 'success' && '✅ Successful' || '❌ Failed') || 'N/A' }} |
| [scout-audit-clippy-config](https://crates.io/crates/scout-audit-clippy-config) | ${{ needs.filter-paths.outputs.clippy-config == 'true' && '🟢 Releasing' || '🔴 Not Releasing' }} | ${{ needs.filter-paths.outputs.clippy-config == 'true' && (needs.test-release.outputs.clippy-config == 'success' && '✅ Successful' || '❌ Failed') || 'N/A' }} |
2 changes: 1 addition & 1 deletion apps/cargo-scout-audit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ regex = { version = "1.5", features = ["unicode"] }
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0"
tempfile = "3.8"
toml = { version = "0.8.0" }
tera = {version = "=1.19.1", features=["builtins"]}
toml = { version = "0.8.0" }
webbrowser = "=0.8.12"
2 changes: 1 addition & 1 deletion apps/cargo-scout-audit/src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub fn run_scout(mut opts: Scout) -> Result<()> {
.context("Failed to get detectors configuration")?,
};

// Misc configurations
// Miscellaneous configurations
// If there is a need to exclude or filter by detector, the dylint tool needs to be recompiled.
// TODO: improve detector system so that doing this isn't necessary.
/*if opts.exclude.is_some() || opts.filter.is_some() {
Expand Down
28 changes: 21 additions & 7 deletions apps/scout-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,27 @@ export async function activate(_context: vscode.ExtensionContext) {
// Check if scout is installed
if (!(await checkAndInstallScout())) return;

// Update settings to change rust-analyzer config
await config.update(RUST_ANALYZER_CONFIG, [
"cargo",
"scout-audit",
"--",
"--message-format=json",
]);
if(sdk == "ink" || sdk == "soroban-sdk") {
console.log("scout-audit")
try {
await commandExists("cargo-scout-audit");
} catch (err) {
console.error("cargo-scout-audit is not installed");
await vscode.window.showErrorMessage(
"cargo-scout-audit must be installed in order for scout to work"
);
return false;
}

// Update settings to change rust-analyzer config
await config.update(RUST_ANALYZER_CONFIG, [
"cargo",
"scout-audit",
"-p vscode",
"--",
"--message-format=json",
]);
}
}

export function deactivate() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 0 additions & 25 deletions scripts/check-ci-detectors-to-test.py

This file was deleted.

Loading
Loading