|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + tags: [ 'v*.*.*' ] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: "Test (${{ matrix.os }} | features: ${{ matrix.features }})" |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 17 | + features: ["", "oxigraph", "oxigraph,mmap", "zstd", "oxigraph,zstd", "oxigraph,mmap,zstd"] |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Install Rust |
| 23 | + uses: dtolnay/rust-toolchain@stable |
| 24 | + |
| 25 | + - name: Cache cargo |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: | |
| 29 | + ~/.cargo/registry |
| 30 | + ~/.cargo/git |
| 31 | + target |
| 32 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 33 | + restore-keys: | |
| 34 | + ${{ runner.os }}-cargo- |
| 35 | +
|
| 36 | + - name: Build |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + if [ -z "${{ matrix.features }}" ]; then |
| 40 | + cargo build --all-targets --locked |
| 41 | + else |
| 42 | + cargo build --all-targets --locked --features "${{ matrix.features }}" |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Test |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + if [ -z "${{ matrix.features }}" ]; then |
| 49 | + cargo test --locked |
| 50 | + else |
| 51 | + cargo test --locked --features "${{ matrix.features }}" |
| 52 | + fi |
| 53 | +
|
| 54 | + lint: |
| 55 | + name: Lint (clippy + fmt) |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Install Rust (components) |
| 62 | + uses: dtolnay/rust-toolchain@stable |
| 63 | + with: |
| 64 | + components: clippy, rustfmt |
| 65 | + |
| 66 | + - name: Cache cargo |
| 67 | + uses: actions/cache@v4 |
| 68 | + with: |
| 69 | + path: | |
| 70 | + ~/.cargo/registry |
| 71 | + ~/.cargo/git |
| 72 | + target |
| 73 | + key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }} |
| 74 | + restore-keys: | |
| 75 | + ${{ runner.os }}-cargo- |
| 76 | +
|
| 77 | + - name: cargo fmt --check |
| 78 | + run: cargo fmt --all -- --check |
| 79 | + |
| 80 | + - name: cargo clippy |
| 81 | + run: cargo clippy --all-targets -- -D warnings |
| 82 | + |
| 83 | + publish: |
| 84 | + name: Publish (crates.io) |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: [test, lint] |
| 87 | + if: startsWith(github.ref, 'refs/tags/v') |
| 88 | + steps: |
| 89 | + - name: Checkout |
| 90 | + uses: actions/checkout@v4 |
| 91 | + |
| 92 | + - name: Install Rust |
| 93 | + uses: dtolnay/rust-toolchain@stable |
| 94 | + |
| 95 | + - name: Publish crate |
| 96 | + env: |
| 97 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} |
| 98 | + run: | |
| 99 | + cargo publish --locked |
| 100 | +
|
| 101 | + build-cli: |
| 102 | + name: Build CLI Artifacts (${{ matrix.os }}) |
| 103 | + runs-on: ${{ matrix.os }} |
| 104 | + needs: [test] |
| 105 | + if: startsWith(github.ref, 'refs/tags/v') |
| 106 | + strategy: |
| 107 | + matrix: |
| 108 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 109 | + steps: |
| 110 | + - name: Checkout |
| 111 | + uses: actions/checkout@v4 |
| 112 | + |
| 113 | + - name: Install Rust |
| 114 | + uses: dtolnay/rust-toolchain@stable |
| 115 | + |
| 116 | + - name: Build CLI (release) |
| 117 | + run: cargo build --release --bin r5tu --features "oxigraph,mmap" --locked |
| 118 | + |
| 119 | + - name: Upload artifact |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: r5tu-${{ matrix.os }} |
| 123 | + path: | |
| 124 | + target/release/r5tu* |
| 125 | +
|
| 126 | + release: |
| 127 | + name: GitHub Release |
| 128 | + runs-on: ubuntu-latest |
| 129 | + needs: [test, lint, build-cli] |
| 130 | + if: startsWith(github.ref, 'refs/tags/v') |
| 131 | + steps: |
| 132 | + - name: Checkout |
| 133 | + uses: actions/checkout@v4 |
| 134 | + |
| 135 | + - name: Extract tag |
| 136 | + id: vars |
| 137 | + run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 138 | + |
| 139 | + - name: Download artifacts |
| 140 | + uses: actions/download-artifact@v4 |
| 141 | + with: |
| 142 | + path: artifacts |
| 143 | + |
| 144 | + - name: Create GitHub Release |
| 145 | + uses: softprops/action-gh-release@v2 |
| 146 | + with: |
| 147 | + tag_name: ${{ steps.vars.outputs.tag }} |
| 148 | + name: ${{ steps.vars.outputs.tag }} |
| 149 | + draft: false |
| 150 | + prerelease: ${{ contains(steps.vars.outputs.tag, '-') }} |
| 151 | + files: | |
| 152 | + artifacts/** |
| 153 | + env: |
| 154 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments