Skip to content

Structure improvement functional tests #976

Structure improvement functional tests

Structure improvement functional tests #976

Workflow file for this run

name: Rust
on:
push:
pull_request:
branches: ["master"]
env:
CARGO_TERM_COLOR: always
jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- name: Run cargo fmt
run: cargo +nightly fmt --all --check
- name: Run cargo clippy
run: cargo +nightly clippy --all-targets
cross-testing:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.74.1 # The version in our `rust-toolchain.toml`
with:
components: rustfmt, clippy
- uses: taiki-e/install-action@cargo-hack
# Bi-weekly numbers to refresh caches every two weeks, ensuring recent project changes are cached
- name: Set bi-weekly cache key
run: |
YEAR=$(date +%Y)
BIWEEK=$(( ($(date +%U) + 1) / 2 ))
echo "CACHE_VERSION=${YEAR}(${BIWEEK})" >> $GITHUB_ENV
shell: bash
# Restore cached dependencies and build artifacts
- name: Restore Rust cache
id: cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/release/
# Cache key depends on the bi-week we are on (cache version)
key: ${{ runner.os }}-cargo-${{ env.CACHE_VERSION }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-${{ env.CACHE_VERSION }}-
${{ runner.os }}-cargo-
# Build only the binaries
- name: Build binaries
run: cargo build --release --bins --verbose
# Run the feature testing script
- name: Run feature tests
run: ./contrib/test_features.sh --verbose
shell: bash # Ensure the script runs using bash on all platforms
# Save cache only if the previous steps succeeded and there was not an exact cache key match
# This happens everytime we modify any `cargo.lock` or `cargo.toml`, or each two weeks (caching recent changes)
- name: Save Rust cache
if: success() && steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/release/
key: ${{ steps.cache.outputs.cache-primary-key }}
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ hashFiles('Dockerfile') }}
- name: Build Docker image
run: |
docker buildx build --cache-to=type=local,dest=/tmp/.buildx-cache --cache-from=type=local,src=/tmp/.buildx-cache -t dlsz/floresta:latest .