build: add nix flake #56
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: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_call: | |
| env: | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| name: Test Suite | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install jj | |
| run: cargo install --locked jj-cli | |
| - name: Run unit tests | |
| run: cargo test --lib | |
| - name: Run integration tests | |
| run: cargo test --test '*' | |
| - name: Run doc tests | |
| run: cargo test --doc | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Clippy | |
| run: cargo clippy --all-targets -- -D warnings | |
| build: | |
| name: Build Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build | |
| run: cargo build --release | |
| nix: | |
| name: Nix Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check for Nix-relevant changes | |
| uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| nix: | |
| - 'flake.nix' | |
| - 'flake.lock' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'src/**' | |
| - 'tests/**' | |
| - name: Install Nix | |
| if: steps.filter.outputs.nix == 'true' | |
| uses: DeterminateSystems/determinate-nix-action@v3 | |
| - name: Setup Nix cache | |
| if: steps.filter.outputs.nix == 'true' | |
| uses: DeterminateSystems/magic-nix-cache-action@v8 | |
| with: | |
| use-flakehub: false | |
| - name: Check flake | |
| if: steps.filter.outputs.nix == 'true' | |
| run: nix flake check | |
| # E2E tests run only on main branch with secrets | |
| e2e: | |
| name: E2E Tests | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| needs: [test, lint] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install jj | |
| run: cargo install --locked jj-cli | |
| - name: Run E2E tests | |
| env: | |
| JJ_RYU_E2E_TESTS: "1" | |
| JJ_RYU_TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} | |
| JJ_RYU_TEST_REPO: ${{ secrets.TEST_REPO }} | |
| run: cargo test --test e2e_tests -- --ignored | |
| continue-on-error: true # E2E tests may fail if secrets not configured |