diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 73905948..bc41e328 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,26 +2,26 @@ name: Cargo & Clippy Test on: push: - branches: [master] - paths: - - src/** - - test_files/** - - .cargo/** - - Cargo.toml - - Cargo.lock - - rust-toolchain.toml - - flake.nix - - flake.lock - pull_request: - paths: - - src/** - - test_files/** - - .cargo/** - - Cargo.toml - - Cargo.lock - - rust-toolchain.toml - - flake.nix - - flake.lock + # branches: [master] + # paths: + # - src/** + # - test_files/** + # - .cargo/** + # - Cargo.toml + # - Cargo.lock + # - rust-toolchain.toml + # - flake.nix + # - flake.lock + # pull_request: + # paths: + # - src/** + # - test_files/** + # - .cargo/** + # - Cargo.toml + # - Cargo.lock + # - rust-toolchain.toml + # - flake.nix + # - flake.lock env: CARGO_TERM_COLOR: always @@ -72,10 +72,10 @@ jobs: # - "bash:4.0" # - "bash:3.2" sed: - - GNU sed + - GNU_sed # Uncomment the next matrix when https://github.com/amber-lang/amber/issues/617 is resolved # include: - # - sed: BusyBox sed + # - sed: BusyBox_sed # bash_version: "bash:latest" steps: - uses: actions/checkout@v4 @@ -111,8 +111,12 @@ jobs: if [ -f "~/docker-images/${{ matrix.bash_docker_image }}-${{ matrix.sed }}" ]; then docker load -i "~/docker-images/${{ matrix.bash_docker_image }}-${{ matrix.sed }}" else - docker build --tag testbash - docker save -o "~/docker-images/${{ matrix.bash_docker_image }}-${{ matrix.sed }}" + docker build --tag testenv -f TestEnvDockerfile \ + --build-arg "BASE_BASH_IMAGE=${{ matrix.bash_docker_image }}" \ + --build-arg "INSTALL_GNU_SED=${{ matrix.sed }}" \ + . + mkdir ~/docker-images + docker save -o "~/docker-images/${{ matrix.bash_docker_image }}-${{ matrix.sed }}" testenv fi - name: Run cargo tests env: @@ -122,7 +126,7 @@ jobs: test_container bash run: | - docker run --network host --detach --name test_container testbash + docker run --network host --detach --name test_container testenv cargo test --all-targets --all-features docker stop test_container -t 0 docker rm --force test_container diff --git a/TestEnvDockerfile b/TestEnvDockerfile index 8b3841ad..da248a14 100644 --- a/TestEnvDockerfile +++ b/TestEnvDockerfile @@ -1,22 +1,20 @@ -LABEL description="Used to test the compiled bash script for various environment." - ARG BASE_BASE_IMAGE=bash:5.2 ARG INSTALL_GNU_SED FROM $BASE_BASE_IMAGE -# A non-root user(guest) is required by is_root() test -RUN useradd -m appuser -USER appuser -WORKDIR /home/appuser - RUN apk add \ curl \ # Includes mktemp coreutils \ ; - -RUN if [ -n "$INSTALL_GNU_SED" ]; then \ - apk add sed \ +RUN if [ "$INSTALL_GNU_SED" == "GNU_sed" ]; \ + then apk add sed; \ fi +# A non-root user(guest) is required by is_root() test +RUN adduser -D appuser +USER appuser +WORKDIR /home/appuser + CMD ["sleep", "infinity"] +LABEL description="Used to test the compiled bash script for various environment."