sqlite-hashes 0.10.8

Hashing functions for SQLite with aggregation support: MD5, SHA1, SHA256, SHA512, Blake3, FNV-1a, xxHash
Documentation
name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_dispatch:

defaults:
  run:
    shell: bash

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with: { tool: 'just,cargo-binstall' }
      - run: just ci-test

  test-msrv:
    name: Test MSRV
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with: { tool: 'just' }
      - name: Read MSRV
        id: msrv
        run: echo "value=$(just get-msrv)" >> $GITHUB_OUTPUT
      - name: Install MSRV Rust ${{ steps.msrv.outputs.value }}
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ steps.msrv.outputs.value }}
      - run: just ci_mode=0 ci-test-msrv  # Ignore warnings in MSRV

  coverage:
    name: Code Coverage
    if: github.event_name != 'release'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with: { tool: 'just,cargo-llvm-cov' }
      - name: Generate code coverage
        run: just ci-coverage
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: target/llvm-cov/codecov.info

  build:
    name: Build ${{ matrix.target }}
    needs: [ test ]
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: aarch64-apple-darwin
            file: libsqlite_hashes.dylib
            download: 'https://www.sqlite.org/2023/sqlite-tools-osx-x64-3440200.zip'
            os: macOS-latest
            sqlite3: ./sqlite3
          - target: x86_64-apple-darwin
            file: libsqlite_hashes.dylib
            download: 'https://www.sqlite.org/2023/sqlite-tools-osx-x64-3440200.zip'
            os: macOS-latest
            sqlite3: ./sqlite3
          - target: x86_64-pc-windows-msvc
            file: sqlite_hashes.dll
            download: 'https://www.sqlite.org/2023/sqlite-tools-win-x64-3440200.zip'
            os: windows-latest
            sqlite3: ./sqlite3.exe
          - target: x86_64-unknown-linux-gnu
            file: libsqlite_hashes.so
            os: ubuntu-latest
            sqlite3: sqlite3
    steps:
      - uses: actions/checkout@v5
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with: { tool: 'just' }
      - if: matrix.download
        name: Download SQLite
        uses: carlosperate/download-file-action@v2
        with:
          file-url: '${{ matrix.download }}'
          file-name: sqlite.zip
          location: ./tmp-downloads
      - if: matrix.download
        name: Install SQLite
        run: |
          cd tmp-downloads
          if [[ "${{ runner.os }}" == "Windows" ]]; then
            7z x sqlite.zip
          else
            unzip sqlite.zip
            chmod +x ${{ matrix.sqlite3 }}
          fi
          mv ${{ matrix.sqlite3 }} ../
          cd ..
          rm -rf ./tmp-downloads
      - name: SQLite Info
        run: |
          which ${{ matrix.sqlite3 }}
          ${{ matrix.sqlite3 }} --version
          ${{ matrix.sqlite3 }} <<EOF
          .help
          EOF
      - if: matrix.cross != 'true'
        name: Build
        run: |
          set -x
          rustup target add "${{ matrix.target }}"
          export RUSTFLAGS='-C strip=debuginfo'
          just build-ext --release --target ${{ matrix.target }}
          mkdir -p target/files
      - if: matrix.target != 'aarch64-apple-darwin'
        name: Test ${{ matrix.target }} extension
        env:
          EXTENSION_FILE: target/${{ matrix.target }}/release/examples/${{ matrix.file }}
          SQLITE3_BIN: ${{ matrix.sqlite3 }}
        run: ./tests/test-ext.sh
      # - if: matrix.target != 'aarch64-apple-darwin'
      #   name: Test ${{ matrix.target }} extension
      #   run: just sqlite3=${{ matrix.sqlite3 }} extension_file=target/${{ matrix.target }}/release/examples/${{ matrix.file }} test-ext
      - name: Package
        run: |
          pushd target/${{ matrix.target }}/release/examples
          if [[ "${{ runner.os }}" == "Windows" ]]; then
            7z a ../../../files/sqlite-hashes-${{ matrix.target }}.zip ${{ matrix.file }}
          else
            tar czvf ../../../files/sqlite-hashes-${{ matrix.target }}.tar.gz ${{ matrix.file }}
          fi
          popd
          ls -lR target/files
      - if: startsWith(github.ref, 'refs/tags/')
        name: Publish
        uses: softprops/action-gh-release@v2
        with:
          files: 'target/files/*'
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}

  cross-build:
    name: Cross-build
    needs: [ test ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with: { tool: 'just,cross' }
      - run: just cross-build-ext-aarch64
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
        with:
          platforms: linux/arm64
      - run: just cross-test-ext-aarch64
      - name: Package
        run: |
          mkdir -p target/files
          tar czvf target/files/sqlite-hashes-aarch64-unknown-linux-gnu.tar.gz -C ./target/aarch64-unknown-linux-gnu/release/examples libsqlite_hashes.so
      - run: ls -lR target/files
      - if: startsWith(github.ref, 'refs/tags/')
        name: Publish
        uses: softprops/action-gh-release@v2
        with:
          files: 'target/files/*'
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}

  # This job checks if any of the previous jobs failed or were canceled.
  # This approach also allows some jobs to be skipped if they are not needed.
  ci-passed:
    needs: [ test, test-msrv, build, cross-build ]
    if: always()
    runs-on: ubuntu-latest
    steps:
      - name: Result of the needed steps
        run: echo "${{ toJSON(needs) }}"
      - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
        run: exit 1

  # Release unpublished packages or create a PR with changes
  release-plz:
    needs: [ ci-passed ]
    if: |
      always()
      && needs.ci-passed.result == 'success'
      && github.event_name == 'push'
      && github.ref == 'refs/heads/main'
      && github.repository_owner == 'nyurik'
    runs-on: ubuntu-latest
    permissions:
      contents: write
      id-token: write
      pull-requests: write
    concurrency:
      group: release-plz-${{ github.ref }}
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@v5
        with: { fetch-depth: 0 }
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io if crate's version is newer
        uses: release-plz/action@v0.5
        id: release
        with: { command: release }
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
      - if: ${{ steps.release.outputs.releases_created == 'false' }}
        name: If version is the same, create a PR proposing new version and changelog for the next release
        uses: release-plz/action@v0.5
        with: { command: release-pr }
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}