Skip to content

Commit

Permalink
needs test
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed Dec 17, 2024
1 parent 86557db commit 40ecb08
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,37 @@ env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
build:
name: Rust build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies installed with cargo
uses: actions/cache@v4
with:
path: |
./target/deps
~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build binary
# the target directory will be used by the next cargo test job
run: |
cargo build --all-targets --all-features
cargo test --no-run --all-targets --all-features
- name: Compress before uploading artifact to preserve permissions # https://github.com/actions/upload-artifact/tree/v4.4.3#permission-loss
run: tar -cvzf target.tgz target/
- uses: actions/upload-artifact@v4
with:
include-hidden-files: true
name: target
path: target.tgz
retention-days: 1
test:
name: Rust tests
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -68,18 +96,21 @@ jobs:
~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build binary
# the binary will be used by the next cargo test step
run: cargo build
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: target
path: artifact
- run: tar -xvzf artifact/target.tgz && rm artifact/target.tgz
- name: Run cargo tests
env:
AMBER_TEST_STRATEGY: docker
AMBER_TEST_ARGS:
# 405 is a non-root user(guest) for is_root() test
exec
--user 405
test_container
bash
AMBER_TEST_STRATEGY: docker
AMBER_TEST_ARGS:
# 405 is a non-root user(guest) for is_root() test
exec
--user 405
test_container
bash
run: |
echo "FROM ${{ matrix.bash_docker_image }}" > Dockerfile
# coreutils includes mktemp
Expand All @@ -91,6 +122,9 @@ jobs:
docker build -t testbash .
docker run --network host --detach --name test_container testbash sleep infinity
ls target/
ls target/debug/
chmod +x target/debug/amber # File permissions are not maintained during artifact upload
cargo test --all-targets --all-features
docker stop test_container -t 0
docker rm --force test_container
Expand Down

0 comments on commit 40ecb08

Please sign in to comment.