Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04

# install gnu coreutils test dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
attr \
autoconf \
automake \
autopoint \
bison \
g++ \
gcc \
gdb \
gperf \
jq \
libacl1-dev \
libattr1-dev \
libcap-dev \
libexpect-perl \
libselinux1-dev \
python3-pyinotify \
quilt \
texinfo \
valgrind \
&& rm -rf /var/lib/apt/lists/*

# install dependencies for uutils
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
clang \
gdb \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

# pre-commit
RUN pip3 install --break-system-packages pre-commit
50 changes: 50 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "uutils-devcontainer",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/rust:1":
{
"version": "latest",
"profile": "default",
"components": "llvm-tools-preview"
}
},
"onCreateCommand": {
"install pre-commit hooks": "pre-commit install",
"update permissions for gnu coreutils volume": "sudo chown vscode:vscode ${containerWorkspaceFolder}/../gnu"
},
"mounts": [
{
"source": "devcontainer-gnu-coreutils-${devcontainerId}",
"target": "${containerWorkspaceFolder}/../gnu",
"type": "volume"
}
],
"customizations": {
"vscode": {
"extensions": [
"streetsidesoftware.code-spell-checker",
"foxundermoon.shell-format",
"ms-vscode.cpptools"
],
"settings": {
"rust-analyzer.check.command": "clippy",
"rust-analyzer.debug.engine": "ms-vscode.cpptools",
"rust-analyzer.debug.engineSettings": {
"cppdbg": {
"miDebuggerPath": "rust-gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
]
}
}
}
}
}
}
34 changes: 34 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Devcontainer

# spell-checker:ignore devcontainers nextest

on:
pull_request:
push:
branches:
- '*'

permissions:
contents: read # to fetch code (actions/checkout)

# End the current execution if there is a new changeset in the PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
test:
name: Verify devcontainer
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Run test in devcontainer
uses: devcontainers/ci@v0.3
with:
push: never
runCmd: |
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
cargo nextest run --hide-progress-bar --profile ci
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ repos:
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-json
exclude: '.vscode/cSpell\.json' # cSpell.json uses comments
- id: check-shebang-scripts-are-executable
exclude: '.+\.rs' # would be triggered by #![some_attribute]
- id: check-symlinks
Expand Down
3 changes: 2 additions & 1 deletion .vscode/cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"vendor/**",
"**/*.svg",
"src/uu/*/locales/*.ftl",
"src/uucore/locales/*.ftl"
"src/uucore/locales/*.ftl",
".devcontainer/**"
],

"enableGlobDot": true,
Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{ "cSpell.import": [".vscode/cspell.json"] }
{
"cSpell.import": [
"./.vscode/cSpell.json"
]
}
3 changes: 3 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ This section will explain how to install and configure these tools.
We also have an extensive CI that uses these tools and will check your code before it can be merged.
The next section [Testing](#testing) will explain how to run those checks locally to avoid waiting for the CI.

As an alternative to host installation of the tools, you can open the project with the provided development container configuration.
For more information about development containers, see the [Visual Studio Code Dev Containers documentation](https://code.visualstudio.com/docs/devcontainers/containers).

### Rust toolchain

[Install Rust](https://www.rust-lang.org/tools/install)
Expand Down
8 changes: 6 additions & 2 deletions tests/by-util/test_dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,9 @@ fn test_skip_past_dev() {
// NOTE: This test intends to trigger code which can only be reached with root permissions.
let ts = TestScenario::new(util_name!());

if let Ok(result) = run_ucmd_as_root_with_stdin_stdout(
if !ts.fixtures.file_exists("/dev/sda1") {
print!("Test skipped; no /dev/sda1 device found");
} else if let Ok(result) = run_ucmd_as_root_with_stdin_stdout(
&ts,
&["bs=1", "skip=10000000000000000", "count=0", "status=noxfer"],
Some("/dev/sda1"),
Expand All @@ -1581,7 +1583,9 @@ fn test_seek_past_dev() {
// NOTE: This test intends to trigger code which can only be reached with root permissions.
let ts = TestScenario::new(util_name!());

if let Ok(result) = run_ucmd_as_root_with_stdin_stdout(
if !ts.fixtures.file_exists("/dev/sda1") {
print!("Test skipped; no /dev/sda1 device found");
} else if let Ok(result) = run_ucmd_as_root_with_stdin_stdout(
&ts,
&["bs=1", "seek=10000000000000000", "count=0", "status=noxfer"],
None,
Expand Down
6 changes: 4 additions & 2 deletions util/build-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ fi

release_tag_GNU="v9.7"

if test ! -d "${path_GNU}"; then
# check if the GNU coreutils has been cloned, if not print instructions
# note: the ${path_GNU} might already exist, so we check for the .git directory
if test ! -d "${path_GNU}/.git"; then
echo "Could not find GNU coreutils (expected at '${path_GNU}')"
echo "Run the following to download into the expected path:"
echo "git clone --recurse-submodules https://github.com/coreutils/coreutils.git \"${path_GNU}\""
Expand Down Expand Up @@ -136,7 +138,7 @@ cd -
touch g
echo "stat with selinux support"
./target/debug/stat -c%C g || true

rm g

cp "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target
# Create *sum binaries
Expand Down
Loading