Skip to content

test: fix test script docs #113

test: fix test script docs

test: fix test script docs #113

Workflow file for this run

name: Test
on:
push:
branches: [ "release/**" ]
pull_request:
branches: [ "develop" ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# lints
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checking for whitespace errors (PRs only)
if: github.event.pull_request.base.sha
run: |
git diff --check "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" || {
echo >&2 "Your pull request introduces whitespace errors,";
echo >&2 "which is not allowed. Please run:";
echo >&2;
echo >&2 " git rebase --whitespace=fix";
echo >&2 " git push -f";
echo >&2;
echo >&2 "to correct and resubmit.";
exit 1;
}
- name: Checking for cargo-fmt errors
run: |
cargo fmt --check || { \
echo >&2 "Your pull request does not conform to cargo-fmt";
echo >&2 "Rust format, which is not allowed. Please run:";
echo >&2;
echo >&2 " cargo fmt";
echo >&2 " git commit -a --amend";
echo >&2 " git push -f";
echo >&2;
echo >&2 "to correct and resubmit. If \`cargo fmt\` touches";
echo >&2 "code which is not part of your MR, please let us";
echo >&2 "know in the comments.";
exit 1;
}
# run `cargo vendor` and cache it
vendor_sources:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v4
name: Update crate cargo-vendor cache
id: vendor_cache
with:
path: |
.cargo
vendor
key: cargo-vendor-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-vendor
enableCrossOsArchive: true
- uses: actions/cache@v4
name: Update cargo registry cache
if: steps.vendor_cache.outputs.cache-hit != 'true'
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-cache
- name: Vendor sources
if: steps.vendor_cache.outputs.cache-hit != 'true'
run: |
mkdir -p .cargo
mkdir -p vendor
cargo vendor --versioned-dirs --locked >.cargo/config.toml
- name: Check compiler lints
run: cargo check --workspace
continue-on-error: true
test_sameold:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
features: ['', 'chrono']
runs-on: ${{ matrix.os }}
needs: vendor_sources
env:
CARGO_NET_OFFLINE: "true"
steps:
- uses: actions/checkout@v3
- name: Record environment
shell: bash
run: cargo version
- uses: actions/cache/restore@v4
name: Restore crate cargo-vendor cache
with:
path: |
.cargo
vendor
key: cargo-vendor-${{ hashFiles('**/Cargo.lock') }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Build and test sameold
shell: bash
run: |
cargo test --frozen -p sameold --verbose --no-default-features --features "${{ matrix.features }}"
test_samedec:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
needs: vendor_sources
env:
CARGO_NET_OFFLINE: "true"
steps:
- uses: actions/checkout@v3
- name: Record environment
shell: bash
run: cargo version
- uses: actions/cache/restore@v4
name: Restore crate cargo-vendor cache
with:
path: |
.cargo
vendor
key: cargo-vendor-${{ hashFiles('**/Cargo.lock') }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Build and unit-test samedec
shell: bash
run: |
cargo test --frozen -p samedec --verbose
- name: Run integration tests
shell: bash
run: |
pushd sample
./test.sh
popd
# Linux builds within our containerized release environment
test_samedec_containerized:
runs-on: ubuntu-latest
needs: vendor_sources
container:
image: ghcr.io/cbs228/sameold/builder/x86_64-unknown-linux-gnu:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
CARGO_NET_OFFLINE: "true"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v4
name: Restore crate cargo-vendor cache
with:
path: |
.cargo
vendor
key: cargo-vendor-${{ hashFiles('**/Cargo.lock') }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Cross-compile and cross-test
run: cargo test --frozen --verbose
- name: Run integration tests on debug-mode build
run: |
cargo run -p samedec -- --version &&
cd sample && ./test.sh