From 7ef3eabba58795f3df68c1f8f6a418e31a7fbf84 Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Mon, 21 Oct 2024 16:14:52 +0200 Subject: [PATCH] Prepare for release --- .github/workflows/documentation.yml | 20 ++++++----------- .github/workflows/unittest.yml | 27 ++++++++++++----------- src/PairwiseMappingFormat.jl | 34 ++++++++++++++--------------- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 4c7bd84..bee37bc 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -8,22 +8,16 @@ on: pull_request: jobs: - build: - permissions: - contents: write - pull-requests: read - statuses: write + Documenter: + name: Documentation runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 with: - version: 'nightly' - - uses: julia-actions/cache@v1 - - name: Install dependencies - run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - - name: Build and deploy + version: '1' + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-docdeploy@latest env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key - run: julia --project=docs/ docs/make.jl + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 03206a0..031c8cb 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -8,38 +8,39 @@ on: jobs: test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} strategy: + fail-fast: false matrix: - julia-version: - - 'nightly' - os: [ ubuntu-latest, windows-latest ] - arch: [ x64 ] + julia-version: ['1', '1.11'] + os: [ubuntu-latest, macOS-latest, windows-latest] + experimental: [false] include: + # Include nightly, but experimental, so it's allowed to fail without + # failing CI. - julia-version: nightly - julia-arch: x86 os: ubuntu-latest experimental: true - # - julia-version: 1 - # os: macOS-latest - # experimental: false + fail_ci_if_error: false + steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Julia - uses: julia-actions/setup-julia@v1 + uses: julia-actions/setup-julia@latest with: version: ${{ matrix.julia-version }} - name: Run Tests uses: julia-actions/julia-runtest@latest - name: Create CodeCov - uses: julia-actions/julia-processcoverage@v1 + uses: julia-actions/julia-processcoverage@latest - name: Upload CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: file: ./lcov.info flags: unittests name: codecov-umbrella fail_ci_if_error: false token: ${{ secrets.CODECOV_TOKEN }} + diff --git a/src/PairwiseMappingFormat.jl b/src/PairwiseMappingFormat.jl index 02c16c8..30315c9 100644 --- a/src/PairwiseMappingFormat.jl +++ b/src/PairwiseMappingFormat.jl @@ -749,6 +749,8 @@ function read_buffer!(reader::PAFReader)::Int remaining = length(mem) - reader.filled end end + + @assert !iszero(remaining) # This part annoys me a lot. Julia has no efficient API to read bytes # into a byte buffer. How on Earth can that be true? # * read! will throw EOF if the memory is too short, and there is no @@ -759,26 +761,22 @@ function read_buffer!(reader::PAFReader)::Int # It uses bytesavailable to check how many bytes to read and avoid buffer overflows etc, # and when there are zero bytes available, it reads a single byte, hoping that # more bytes will be available. - if !iszero(remaining) - n_available = bytesavailable(reader.io) + n_available = bytesavailable(reader.io) + if iszero(n_available) && !eof(reader.io) # Read one byte and hope more bytes become available - if iszero(n_available) && !eof(reader.io) - byte = read(reader.io, UInt8) - @inbounds mem[reader.filled + 1] = byte - reader.filled += 1 - remaining -= 1 - n_available = bytesavailable(reader.io) - end - # Read with unsafe_read - n_bytes = min(n_available, remaining) - if !iszero(n_bytes) - GC.@preserve mem unsafe_read(reader.io, pointer(mem, reader.filled + 1), n_bytes) - reader.filled += n_bytes - end - return n_bytes - else - return 0 + byte = read(reader.io, UInt8) + @inbounds mem[reader.filled + 1] = byte + reader.filled += 1 + remaining -= 1 + n_available = bytesavailable(reader.io) + end + # Read with unsafe_read + n_bytes = min(n_available, remaining) + if !iszero(n_bytes) + GC.@preserve mem unsafe_read(reader.io, pointer(mem, reader.filled + 1), n_bytes) + reader.filled += n_bytes end + return n_bytes end """