Project sanity checks #101
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Project sanity checks | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| formatting: | |
| name: Check formatting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| components: rustfmt | |
| - name: Explicitly allow warnings | |
| run: echo "RUSTFLAGS=-A warnings" >> $GITHUB_ENV | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| audit: | |
| name: Check for vulnerabilities | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Explicitly allow warnings | |
| run: echo "RUSTFLAGS=-A warnings" >> $GITHUB_ENV | |
| - name: Install auditing tools | |
| run: cargo install cargo-auditable cargo-audit | |
| - name: Build with cargo auditable | |
| run: cargo auditable build | |
| - name: Audit binary | |
| run: cargo audit bin target/debug/git_sync | |
| test: | |
| runs-on: ubuntu-latest | |
| name: Build and test | |
| if: github.event_name != 'release' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Explicitly allow warnings | |
| run: echo "RUSTFLAGS=-A warnings" >> $GITHUB_ENV | |
| - name: Build | |
| run: cargo build --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| release-builds: | |
| name: Build binaries for release | |
| if: github.event_name == 'release' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| components: rustfmt | |
| target: ${{ matrix.target }} | |
| - name: Install musl tools for musl target | |
| if: matrix.target == 'x86_64-unknown-linux-musl' | |
| run: sudo apt update && sudo apt -y install musl-tools | |
| - name: Install cargo-audit | |
| run: cargo install cargo-auditable cargo-audit | |
| - name: Build release binary, manpages, shell completion | |
| run: | | |
| cargo auditable build --release --target ${{ matrix.target }} | |
| cargo test --release --verbose --target ${{ matrix.target }} | |
| mkdir -p man | |
| mkdir -p shell_completion | |
| cargo run -- generate --kind man --out man/ | |
| cargo run -- generate --kind bash --out shell_completion/ | |
| cargo run -- generate --kind fish --out shell_completion/ | |
| cargo run -- generate --kind zsh --out shell_completion/ | |
| - name: Package release assets | |
| run: | | |
| mkdir -p dist | |
| TARBALL="git_sync-${{ matrix.target }}.tar.gz" | |
| cp target/${{matrix.target}}/release/git_sync . | |
| tar -czvf dist/$TARBALL \ | |
| git_sync \ | |
| README.md \ | |
| LICENSE \ | |
| THIRDPARTY \ | |
| man \ | |
| shell_completion | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/git_sync-${{matrix.target}}.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |