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 a5e7761
Showing 1 changed file with 90 additions and 49 deletions.
139 changes: 90 additions & 49 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,54 @@ env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
build:
name: Rust build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: bc shfmt
# version: 1.0
# - name: Install bshchk
# run: |
# sudo curl https://github.com/b1ek/bshchk/releases/download/1.1/bshchk.linux.amd64 -L -o /usr/bin/bshchk
# sudo chmod +x /usr/bin/bshchk
- 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 binary will be used by the next cargo test job
run: |
cargo build --all-targets --all-features
cargo test --no-run --all-targets --all-features
- 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:
bash_docker_image:
- "bash:5.2"
- "bash:5.1"
- "bash:5.0"
- "bash:4.4"
- "bash:4.3"
- "bash:4.2"
# - "bash:5.1"
# - "bash:5.0"
# - "bash:4.4"
# - "bash:4.3"
# - "bash:4.2"
# - "bash:4.1"
# - "bash:4.0"
# - "bash:3.2"
Expand Down Expand Up @@ -68,49 +103,55 @@ 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
# 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
run: |
echo "FROM ${{ matrix.bash_docker_image }}" > Dockerfile
# coreutils includes mktemp
apks="coreutils curl"
if [ "${{ matrix.sed }}" == "GNU sed" ]; then
apks="$apks sed"
fi
echo "RUN apk add $apks" >> Dockerfile
# echo "FROM ${{ matrix.bash_docker_image }}" > Dockerfile
# # coreutils includes mktemp
# apks="coreutils curl"
# if [ "${{ matrix.sed }}" == "GNU sed" ]; then
# apks="$apks sed"
# fi
# echo "RUN apk add $apks" >> Dockerfile
docker build -t testbash .
docker run --network host --detach --name test_container testbash sleep infinity
cargo test --all-targets --all-features
docker stop test_container -t 0
docker rm --force test_container
clippy:
name: Clippy tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: bc shfmt
version: 1.0
- 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: Run clippy check
run: cargo clippy --all-targets --all-features -- -D warnings
# 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 -v
# docker stop test_container -t 0
# docker rm --force test_container
# clippy:
# name: Clippy tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: bc shfmt
# version: 1.0
# - 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: Run clippy check
# run: cargo clippy --all-targets --all-features -- -D warnings

0 comments on commit a5e7761

Please sign in to comment.