Merge branch 'main' of https://github.com/Gmin2/cups-rs #2
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: CI/CD | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| name: Test and lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Cache cargo dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install CUPS | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cups cups-client libcups2-dev pkg-config | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Run unit tests | |
| run: cargo test --lib | |
| - name: Build examples | |
| run: cargo build --examples | |
| integration-test: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install and setup CUPS | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cups cups-client cups-bsd libcups2-dev pkg-config | |
| # Start CUPS | |
| sudo systemctl start cups | |
| # Wait for CUPS to be ready | |
| timeout 30 bash -c 'until curl -s http://localhost:631/ > /dev/null; do sleep 1; done' | |
| # Create test printer | |
| sudo lpadmin -p TestPDF -E -v file:///tmp/cups-pdf/ -m everywhere | |
| sudo cupsaccept TestPDF | |
| sudo cupsenable TestPDF | |
| # Create output directory | |
| sudo mkdir -p /tmp/cups-pdf | |
| sudo chmod 777 /tmp/cups-pdf | |
| # Verify setup | |
| lpstat -p | |
| - name: Run integration tests | |
| run: cargo test --test integration_tests | |
| env: | |
| RUST_TEST_THREADS: 1 | |
| publish: | |
| name: Publish to crates.io | |
| runs-on: ubuntu-latest | |
| needs: [test, integration-test] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install CUPS dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libcups2-dev pkg-config | |
| - name: Verify version matches tag | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') | |
| if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then | |
| echo "Tag version ($TAG_VERSION) doesn't match Cargo.toml version ($CARGO_VERSION)" | |
| exit 1 | |
| fi | |
| - name: Publish to crates.io | |
| run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} |