diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..6005cc4 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,13 @@ +name: Security Audit + +on: [push, pull_request] + +jobs: + audit: + name: Audit + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - uses: rustsec/audit-check@v1.4.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1d8e710 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,124 @@ +name: CI + +on: [push, pull_request] + +jobs: + lint: + runs-on: ${{ matrix.os }} + strategy: + matrix: + rust: [stable] + os: [ubuntu-latest] + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Cache target + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.os }}-cargo--${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Install system packages + run: | + sudo apt-get update + sudo apt-get install -y libusb-1.0-0-dev libftdi1-dev libudev-dev + + - name: Install toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + toolchain: ${{ matrix.rust }} + + - name: Clippy + run: cargo clippy --all-features -- -W clippy::all -D warnings + + - name: Format + run: cargo fmt --all -- --check + + - name: Doc Generation + run: cargo doc --bins --examples --all-features --no-deps + + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + rust: [stable, nightly] + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install system packages (Linux) + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + sudo apt-get update + sudo apt-get install -y libusb-1.0-0-dev libftdi1-dev libudev-dev + + - name: Install system packages (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + vcpkg install libftdi1:x64-windows libusb:x64-windows + + - name: Cache target + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.os }}-cargo--${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Install toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + toolchain: ${{ matrix.rust }} + + - name: Build debug binary + run: cargo build + + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + rust: [stable, nightly] + os: [ubuntu-latest] + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install system packages (Linux) + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + sudo apt-get update + sudo apt-get install -y libusb-1.0-0-dev libftdi1-dev libudev-dev + + - name: Install system packages (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + vcpkg install libftdi1:x64-windows libusb:x64-windows + + - name: Cache target + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.os }}-cargo--${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Install toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + toolchain: ${{ matrix.rust }} + + - name: Test + run: cargo test --all-features -- --test-threads=1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e2e3409 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,154 @@ +name: Release + +# Push events to matching v*, i.e. v1.0, v20.15.10 +on: + push: + tags: + - 'v*' + +jobs: + check: + timeout-minutes: 30 + name: Check Signed Tag + runs-on: ubuntu-20.04 + outputs: + stringver: ${{ steps.contentrel.outputs.stringver }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + path: src/github.com/auxon/trace-recorder-rtt-proxy + + - name: Check signature + run: | + RELEASE_TAG=${{ github.ref }} + RELEASE_TAG="${RELEASE_TAG#refs/tags/}" + TAGCHECK=$(git tag -v ${RELEASE_TAG} 2>&1 >/dev/null) || + echo "${TAGCHECK}" | grep -q "error" && { + echo "::error::tag ${RELEASE_TAG} is not a signed tag. Failing release process." + exit 1 + } || { + echo "Tag ${RELEASE_TAG} is signed." + exit 0 + } + working-directory: src/github.com/auxon/trace-recorder-rtt-proxy + + linux_package: + name: Build Release Package (Linux) + timeout-minutes: 30 + runs-on: ubuntu-22.04 + needs: [check] + steps: + - name: Print version + run: | + RELEASE_TAG=${{ github.ref }} + RELEASE_TAG="${RELEASE_TAG#refs/tags/}" + RELEASE_VERSION="${RELEASE_TAG#v}" + echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + echo "Release tag: $RELEASE_TAG" + echo "Release version: $RELEASE_VERSION" + + - name: Install system packages + run: | + sudo apt-get update + sudo apt-get install -y libusb-1.0-0-dev libftdi1-dev libudev-dev lintian dpkg dpkg-dev liblzma-dev + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Fetch dependencies + run: | + cargo install cargo-deb + cargo fetch + + - name: Build release binaries + run: cargo build --release + + - name: Build example release binaries + run: cargo build --release --examples + + - name: Build debian package + run: cargo deb -v --deb-version ${{ env.RELEASE_VERSION }}+22.04 + + - name: Create github release + id: create_release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + draft: false + prerelease: false + name: Release ${{ env.RELEASE_VERSION }} + fail_on_unmatched_files: true + files: | + target/release/trc-rtt-proxy + target/release/examples/trc-rtt-proxy-client + target/debian/trace-recorder-rtt-proxy_${{ env.RELEASE_VERSION }}+22.04_amd64.deb + + mac_package: + name: Build Release Package (Mac) + timeout-minutes: 30 + runs-on: macos-latest + needs: [check] + steps: + - name: Print version + run: | + RELEASE_TAG=${{ github.ref }} + RELEASE_TAG="${RELEASE_TAG#refs/tags/}" + RELEASE_VERSION="${RELEASE_TAG#v}" + echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + echo "Release tag: $RELEASE_TAG" + echo "Release version: $RELEASE_VERSION" + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install rust toolchains (x86, arm) + run: | + rustup target add x86_64-apple-darwin + rustup target add aarch64-apple-darwin + + - name: Build packages (intel) + shell: bash + run: | + cargo build --release --target x86_64-apple-darwin + cargo build --release --examples --target x86_64-apple-darwin + mkdir -p target/package/x86_64-apple-darwin + cp target/x86_64-apple-darwin/release/trc-rtt-proxy target/package/x86_64-apple-darwin/ + cp target/x86_64-apple-darwin/release/examples/trc-rtt-proxy-client target/package/x86_64-apple-darwin/ + cd target/package/x86_64-apple-darwin/ + tar -czf trace-recorder-rtt-proxy_${{ env.RELEASE_VERSION }}+mac.amd64.tar.gz trc-rtt-proxy trc-rtt-proxy-client + + - name: Build packages (arm) + shell: bash + run: | + cargo build --release --target aarch64-apple-darwin + cargo build --release --examples --target aarch64-apple-darwin + mkdir -p target/package/aarch64-apple-darwin + cp target/aarch64-apple-darwin/release/trc-rtt-proxy target/package/aarch64-apple-darwin/ + cp target/aarch64-apple-darwin/release/examples/trc-rtt-proxy-client target/package/aarch64-apple-darwin/ + cd target/package/aarch64-apple-darwin/ + tar -czf trace-recorder-rtt-proxy_${{ env.RELEASE_VERSION }}+mac.arm64.tar.gz trc-rtt-proxy trc-rtt-proxy-client + + - name: Create github release + id: create_release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + draft: false + prerelease: false + name: Release ${{ env.RELEASE_VERSION }} + fail_on_unmatched_files: true + files: | + target/package/x86_64-apple-darwin/trace-recorder-rtt-proxy_${{ env.RELEASE_VERSION }}+mac.amd64.tar.gz + target/package/aarch64-apple-darwin/trace-recorder-rtt-proxy_${{ env.RELEASE_VERSION }}+mac.arm64.tar.gz diff --git a/README.md b/README.md index 13de4f9..a29b75b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # trace-recorder-rtt-proxy -Proxy debug-probe operations and RTT data over the network +Proxy debug-probe operations and trace recorder RTT data over the network.