Skip to content

Commit 9d44a32

Browse files
committed
move shellcheck
1 parent 3f91dd3 commit 9d44a32

File tree

9 files changed

+68
-218
lines changed

9 files changed

+68
-218
lines changed

.github/actions/lint_code/action.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ description: "Run lints checks for project"
33
runs:
44
using: composite
55
steps:
6+
- uses: cachix/install-nix-action@v27
7+
with:
8+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
69
- name: Install runner
710
uses: ./.github/actions/install_runner
811
- run: source venv/bin/activate
912
shell: bash
10-
- name: Black, pylint and tailing whitespaces checks
13+
14+
- name: All checks + pylint checks
1115
shell: bash
1216
run: ./format.sh --check
1317
- if: ${{ failure() }}
@@ -18,12 +22,6 @@ runs:
1822
exit 1
1923
2024
'
21-
- name: 'Install shellcheck'
22-
shell: bash
23-
run: sudo apt-get install -y shellcheck
24-
- name: 'Run shellcheck'
25-
shell: bash
26-
run: ./utils/scripts/shellcheck.sh
2725
- name: Install node
2826
uses: actions/setup-node@v4
2927
with:

.github/workflows/nix-github-actions.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.shellcheck

Lines changed: 0 additions & 37 deletions
This file was deleted.

.shellcheckrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

flake.nix

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,11 @@
3636

3737
treefmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
3838

39-
lints = pkgs.stdenv.mkDerivation {
40-
name = "lint-check";
41-
src = ./.;
42-
doCheck = true;
43-
nativeBuildInputs = with pkgs; [pylint];
44-
checkPhase = ''
45-
pylint utils
46-
'';
47-
};
48-
4939
python = pkgs.python39;
5040
in {
5141
packages = {
52-
default = black;
53-
inherit black lints;
42+
default = treefmt.config.build.wrapper;
43+
inherit black treefmt;
5444
};
5545
devShells.default =
5646
pkgs.mkShell
@@ -65,12 +55,11 @@
6555

6656
treefmt.config.build.wrapper
6757
python
68-
python.pkgs.venvShellHook
6958

7059
pkgs.ruff
7160
];
7261

73-
# buildInputs = [python.pkgs.venvShellHook];
62+
buildInputs = [python.pkgs.venvShellHook];
7463
venvDir = "./venv";
7564

7665
postVenvCreation = ''

format.sh

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,23 @@ while [[ "$#" -gt 0 ]]; do
2929
shift
3030
done
3131

32+
echo "Running treefmt-nix ..."
33+
if [ "$COMMAND" == "fix" ]; then
34+
nix fmt
35+
36+
37+
else
38+
nix flake check
39+
fi
40+
3241
if [ ! -d "venv/" ]; then
3342
echo "Runner is not installed, installing it (ETA 60s)"
3443
./build.sh -i runner
3544
fi
3645

46+
# shellcheck source=/dev/null
3747
source venv/bin/activate
3848

39-
echo "Checking Python files..."
40-
if [ "$COMMAND" == "fix" ]; then
41-
black .
42-
else
43-
black --check --diff .
44-
fi
4549
pylint utils # pylint does not have a fix mode
4650

47-
# not py, as it's handled by black
48-
INCLUDE_EXTENSIONS=("*.md" "*.yml" "*.yaml" "*.sh" "*.cs" "*.Dockerfile" "*.java" "*.sql" "*.ts" "*.js" "*.php")
49-
EXCLUDE_DIRS=("logs*" "*/node_modules/*" "./venv/*" "./manifests/*" "./utils/build/virtual_machine/*")
50-
51-
INCLUDE_ARGS=()
52-
for ext in "${INCLUDE_EXTENSIONS[@]}"; do
53-
INCLUDE_ARGS+=(-name "$ext" -o)
54-
done
55-
unset 'INCLUDE_ARGS[${#INCLUDE_ARGS[@]}-1]' # remove last -o
56-
57-
EXCLUDE_ARGS=()
58-
for dir in "${EXCLUDE_DIRS[@]}"; do
59-
EXCLUDE_ARGS+=(-not -path "$dir")
60-
done
61-
62-
echo "Checking tailing whitespaces..."
63-
FILES=$(find . "${EXCLUDE_ARGS[@]}" \( "${INCLUDE_ARGS[@]}" \) -exec grep -l " $" {} \;)
64-
if [ "$COMMAND" == "fix" ]; then
65-
echo "$FILES" | xargs -I {} sed -i '' -r 's/ +$//g' {}
66-
else
67-
if [ -n "$FILES" ]; then
68-
echo "Some tailing white spaces has been found, please fix them 💥 💔 💥"
69-
echo "$FILES"
70-
exit 1
71-
fi
72-
fi
73-
7451
echo "All good, the system-tests CI will be happy! ✨ 🍰 ✨"

treefmt.nix

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,53 @@
1212
programs.black.enable = true;
1313
# Format .sh scripts
1414
# programs.shfmt.enable = true;
15-
settings.global.excludes = ["tests/fuzzer/**" "tests/appsec/waf/blocked*" "utils/parametric/protos/*.py"];
15+
16+
programs.shellcheck.enable = true;
17+
18+
settings.formatter.shellcheck = {
19+
excludes = [
20+
# TODO: scripts to fix
21+
"utils/scripts/load-binary.sh"
22+
"utils/scripts/install_mitm_certificate.sh"
23+
"utils/scripts/update_dashboard_CI_visibility.sh"
24+
"utils/scripts/slack/report.sh"
25+
"utils/scripts/docker_base_image.sh"
26+
"utils/scripts/upload_results_CI_visibility.sh"
27+
"utils/build/docker/postgres-init-db.sh"
28+
"utils/build/docker/nodejs/app.sh"
29+
"utils/build/docker/nodejs/install_ddtrace.sh"
30+
"utils/build/docker/set-uds-transport.sh"
31+
"utils/build/docker/python/flask/app.sh"
32+
"utils/build/docker/python/install_ddtrace.sh"
33+
"utils/build/docker/python/django/app.sh"
34+
"utils/build/docker/golang/app.sh"
35+
"utils/build/docker/golang/install_ddtrace.sh"
36+
"utils/build/docker/weblog-cmd.sh"
37+
"utils/build/docker/java/app.sh"
38+
"utils/build/docker/java/install_ddtrace.sh"
39+
"utils/build/docker/java/spring-boot/app.sh"
40+
"utils/build/docker/php/apache-mod/build.sh"
41+
"utils/build/docker/php/apache-mod/entrypoint.sh"
42+
"utils/build/docker/php/php-fpm/build.sh"
43+
"utils/build/docker/php/php-fpm/entrypoint.sh"
44+
"utils/build/docker/php/common/install_ddtrace.sh"
45+
"utils/build/docker/dotnet/app.sh"
46+
"utils/build/docker/dotnet/install_ddtrace.sh"
47+
"utils/build/docker/cpp/install_ddprof.sh"
48+
"utils/build/docker/cpp/nginx/app.sh"
49+
"utils/build/docker/cpp/nginx/install_ddtrace.sh"
50+
"utils/build/docker/ruby/install_ddtrace.sh"
51+
"utils/build/build.sh"
52+
"utils/interfaces/schemas/serve.sh"
53+
"build.sh"
54+
# "format.sh"
55+
56+
# ignored paths
57+
"tests/perfs/*.sh"
58+
"parametric/*.sh"
59+
"lib-injection/*.sh"
60+
];
61+
};
1662

1763
settings.formatter.whitespace = {
1864
command = "${pkgs.bash}/bin/bash";
@@ -28,4 +74,6 @@
2874

2975
settings.global.excludes = ["./venv/*" "*/node_modules/*" "tests/appsec/waf/blocked*" "utils/parametric/protos/*.py"];
3076
};
77+
78+
settings.global.excludes = ["tests/fuzzer/**" "tests/appsec/waf/blocked*" "utils/parametric/protos/*.py"];
3179
}

utils/build/virtual_machine/provisions/auto-inject/repositories/autoinstall/execute_install_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [ -z "$INSTALLER_URL" ]; then
66
INSTALLER_URL="https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh"
77
fi
88

9-
curl -L $INSTALLER_URL --output install_script_agent7.sh
9+
curl -L "$INSTALLER_URL" --output install_script_agent7.sh
1010
chmod 755 install_script_agent7.sh
1111
# shellcheck disable=SC2154
1212
sed "s/\"7\"/\"$DD_injection_major_version\"/g" install_script_agent7.sh > install_script_agent7_autoinject_temp.sh

utils/scripts/shellcheck.sh

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)