Add PAR2 creation support #114
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: Rust | |
| "on": | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # Disable incremental compilation for CI (not reused). | |
| CARGO_INCREMENTAL: 0 | |
| # Disable debug info in dev builds (faster compile). | |
| CARGO_PROFILE_DEV_DEBUG: 0 | |
| PAR2_TURBO_VERSION: "1.4.0" | |
| PAR2_TURBO_CACHE_KEY: par2cmdline-turbo-1.4.0 | |
| PAR2_TURBO_SHA256: >- | |
| 0be495172b4b8aeabda39c493e47de652813fab88ae745c8633e901c05494281 | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@nightly | |
| - name: Setup Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: "test" | |
| cache-on-failure: true | |
| - name: Cache par2cmdline | |
| id: cache-par2 | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/bin/par2 | |
| key: ${{ runner.os }}-${{ env.PAR2_TURBO_CACHE_KEY }} | |
| - name: Install par2cmdline-turbo | |
| if: steps.cache-par2.outputs.cache-hit != 'true' | |
| run: | | |
| archive="par2cmdline-turbo-${PAR2_TURBO_VERSION}-linux-amd64.zip" | |
| release_url="https://github.com/animetosho/par2cmdline-turbo" | |
| curl -fsSLO \ | |
| "${release_url}/releases/download/v${PAR2_TURBO_VERSION}/${archive}" | |
| echo "${PAR2_TURBO_SHA256} ${archive}" | sha256sum -c - | |
| python3 -m zipfile -e "${archive}" par2cmdline-turbo | |
| par2_bin="$(find par2cmdline-turbo -type f -name par2 -print -quit)" | |
| test -n "${par2_bin}" | |
| mkdir -p ~/bin | |
| install -m 0755 "${par2_bin}" ~/bin/par2 | |
| - name: Add par2 to PATH | |
| run: echo "$HOME/bin" >> $GITHUB_PATH | |
| - name: Check PAR2 reference tool | |
| run: par2 --version | |
| - name: Run tests | |
| run: cargo test --all-features --workspace | |
| coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: llvm-tools-preview | |
| - name: Setup Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: "coverage" | |
| cache-on-failure: true | |
| - name: Cache par2cmdline | |
| id: cache-par2-coverage | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/bin/par2 | |
| key: ${{ runner.os }}-${{ env.PAR2_TURBO_CACHE_KEY }} | |
| - name: Install par2cmdline-turbo | |
| if: steps.cache-par2-coverage.outputs.cache-hit != 'true' | |
| run: | | |
| archive="par2cmdline-turbo-${PAR2_TURBO_VERSION}-linux-amd64.zip" | |
| release_url="https://github.com/animetosho/par2cmdline-turbo" | |
| curl -fsSLO \ | |
| "${release_url}/releases/download/v${PAR2_TURBO_VERSION}/${archive}" | |
| echo "${PAR2_TURBO_SHA256} ${archive}" | sha256sum -c - | |
| python3 -m zipfile -e "${archive}" par2cmdline-turbo | |
| par2_bin="$(find par2cmdline-turbo -type f -name par2 -print -quit)" | |
| test -n "${par2_bin}" | |
| mkdir -p ~/bin | |
| install -m 0755 "${par2_bin}" ~/bin/par2 | |
| - name: Add par2 to PATH | |
| run: echo "$HOME/bin" >> $GITHUB_PATH | |
| - name: Check PAR2 reference tool | |
| run: par2 --version | |
| - name: Cache cargo-llvm-cov binary | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/bin/cargo-llvm-cov | |
| key: ${{ runner.os }}-cargo-llvm-cov-0.6.14 | |
| - name: Install cargo-llvm-cov | |
| run: | | |
| if ! command -v cargo-llvm-cov &> /dev/null; then | |
| cargo install cargo-llvm-cov --version 0.6.14 --locked | |
| fi | |
| - name: Generate coverage report | |
| run: | | |
| cargo llvm-cov \ | |
| --all-features \ | |
| --workspace \ | |
| --lcov \ | |
| --output-path lcov.info | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: lcov.info | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| verbose: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Archive coverage results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: lcov.info |