Skip to content
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
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, beta]
exclude:
# Reduce CI load - only test beta on Ubuntu
- os: windows-latest
rust: beta
- os: macos-latest
rust: beta

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy

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

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

- name: Run doc tests
run: cargo test --doc

coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: true

security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install cargo-audit
uses: taiki-e/install-action@cargo-audit

- name: Run security audit
run: cargo audit
55 changes: 55 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deploy Docs

on:
push:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

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

- name: Build Documentation
run: cargo doc --no-deps --workspace --document-private-items

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./target/doc

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
116 changes: 116 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

env:
CARGO_TERM_COLOR: always

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update CHANGELOG.md
uses: orhun/git-cliff-action@v2
with:
args: --latest --prepend CHANGELOG.md
version: ${{ github.ref_name }}
git-commit: true
git-push: true
git-commit-message: "chore: update changelog for ${{ github.ref_name }}"
git-user-name: "github-actions[bot]"
git-user-email: "github-actions[bot]@users.noreply.github.com"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Determine if prerelease
run: |
if [[ "${{ github.ref_name }}" == *"-"* ]]; then
echo "prerelease=true" >> $GITHUB_ENV
else
echo "prerelease=false" >> $GITHUB_ENV
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: ${{ env.prerelease }}

build-release:
name: Build Release
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: ".exe"
- os: macos-latest
target: x86_64-apple-darwin
suffix: ""
- os: macos-latest
target: aarch64-apple-darwin
suffix: ""

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}

- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}

- name: Create archive
shell: bash
run: |
binary_name="code-guardian-cli${{ matrix.suffix }}"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
archive_name="code-guardian-${{ matrix.target }}.zip"
cp "target/${{ matrix.target }}/release/${binary_name}" .
7z a "${archive_name}" "${binary_name}" README.md
else
archive_name="code-guardian-${{ matrix.target }}.tar.gz"
cp "target/${{ matrix.target }}/release/${binary_name}" .
tar czf "${archive_name}" "${binary_name}" README.md
fi
echo "ARCHIVE_NAME=${archive_name}" >> $GITHUB_ENV
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ env.ARCHIVE_NAME }}
asset_name: ${{ env.ARCHIVE_NAME }}
asset_content_type: application/octet-stream
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target
debug
target

# These are backup files generated by rustfmt
**/*.rs.bk
Expand All @@ -19,3 +19,15 @@ target
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Database files
*.db

# Environment files
.env

# node.js
node_modules

# Archived plans
/plans/archive
16 changes: 16 additions & 0 deletions .opencode/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: ['@typescript-eslint'],
env: {
node: true,
es6: true,
jest: true,
},
rules: {
// Add any custom rules here
},
};
51 changes: 51 additions & 0 deletions .opencode/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
with:
path: code-guardian
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
code-guardian/target
key: ${{ runner.os }}-cargo-${{ hashFiles('code-guardian/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check
run: cargo check --workspace
working-directory: code-guardian
- name: Test
run: cargo test --workspace
working-directory: code-guardian
- name: Clippy
run: cargo clippy --workspace -- -D warnings
working-directory: code-guardian
- name: Format
run: cargo fmt --all -- --check
working-directory: code-guardian
- name: Build release
run: cargo build --release --workspace
working-directory: code-guardian
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: binaries-${{ matrix.os }}
path: code-guardian/target/release/
Loading
Loading