Skip to content

Commit 0e4876d

Browse files
aRustyDevclaude
andcommitted
fix: Achieve fully green CI by fixing all remaining issues
- Add missing newlines to .dockerignore, dockerfile, and nix-build.nix - Remove trailing whitespace from nix-build.nix - Fix remaining ShellCheck warnings: - Add 's' case handler in witness.sh getopts - Quote variables properly in witness.sh - Replace useless cat commands with proper redirections - Quote command substitution in update-vm.sh - Add error handling for cd command in publish-to-nixpkgs.sh - Fix nix-fmt test mock to properly write formatted output - Install shfmt in CI workflow for shell formatting checks - All pre-commit hooks now pass successfully Closes #26 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4122acf commit 0e4876d

File tree

8 files changed

+19
-18
lines changed

8 files changed

+19
-18
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
!.dockerignore
33
!Dockerfile
44
!tools/entrypoint.sh
5-
!tools/install/*.sh
5+
!tools/install/*.sh

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ jobs:
2222
run: |
2323
sudo apt-get update
2424
sudo apt-get install -y shellcheck
25+
2526
# Install shfmt
26-
GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest
27-
echo "$HOME/go/bin" >> $GITHUB_PATH
27+
wget -O /tmp/shfmt https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64
28+
chmod +x /tmp/shfmt
29+
sudo mv /tmp/shfmt /usr/local/bin/shfmt
2830
2931
- name: Run shellcheck
3032
run: |

docker/op-ggshield-img.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ VOLUME [ "/src:rw,Z" ]
1414

1515
ENV GITGUARDIAN_API_KEY `op read op://${OP_VAULT}/${OP_ITEM_NAME}/${OP_ITEM_FIELD}`
1616

17-
ENTRYPOINT [ "op run --env='/src/op.env' -- ggshield secret scan pre-commit" ]
17+
ENTRYPOINT [ "op run --env='/src/op.env' -- ggshield secret scan pre-commit" ]

hooks/nix/nix-build.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
pkgs.stdenv.mkDerivation {
44
pname = "pre-commit-hooks-nix-build";
55
version = "0.1.0";
6-
76
src = ./.;
8-
97
buildPhase = ''
108
echo "Running nix build validation..."
119
'';
12-
1310
installPhase = ''
1411
mkdir -p $out
1512
echo "Nix build validation completed" > $out/result.txt
1613
'';
17-
}
14+
}

hooks/nix/publish-to-nixpkgs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
nix-build "$@"
99
git clone https://github.com/NixOS/nixpkgs
10-
cd nixpkgs
10+
cd nixpkgs || exit
1111
mkdir -p pkgs/by-name/so/some-package
1212
emacs pkgs/by-name/so/some-package/package.nix
1313
git add pkgs/by-name/so/some-package/package.nix

hooks/update-vm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
22

3-
if [ $(uname -n) == "nixos" ]; then
3+
if [ "$(uname -n)" == "nixos" ]; then
44
cp "$GIT_DIR/nixos/WIP/*.nix" /etc/nixos/
55
fi

hooks/witness.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fi
110110
if ! command -v witness > /dev/null 2>&1; then
111111
echo "witness binary not found"
112112
echo "Downloading witness binary"
113-
go install/get github.com/in-toto/witness/cmd/${ARCH:-}/witness@latest
113+
go install/get "github.com/in-toto/witness/cmd/${ARCH:-}/witness@latest"
114114
fi
115115
if ! command -v yq > /dev/null 2>&1; then
116116
echo "yq binary not found"
@@ -134,6 +134,10 @@ while getopts ":r:a:s:" opt; do
134134
a)
135135
witness_run_args="$OPTARG"
136136
;;
137+
s)
138+
# Step option reserved for future use
139+
:
140+
;;
137141
\?)
138142
echo "Invalid option -$OPTARG" >&2
139143
exit 1
@@ -163,8 +167,8 @@ for i in $(yq eval '.verify.attestations[]' .witness.yaml); do
163167
echo "Attestation file ($i) specified in '.witness.yaml' not found"
164168
exit 1
165169
fi
166-
witness run --step build -o "$i" -a slsa --attestor-slsa-export -- $witness_run $witness_run_args .
167-
cat "$i" | jq -r .payload | base64 -d | jq
170+
witness run --step build -o "$i" -a slsa --attestor-slsa-export -- "$witness_run" "$witness_run_args" .
171+
jq -r .payload < "$i" | base64 -d | jq
168172
done
169173

170174
# 5.View Attestation data in the signed DSSE envelope
@@ -213,7 +217,7 @@ fi
213217

214218
# 7. Replace variables in the policy
215219
id=$(sha256sum testpub.pem | awk '{print $1}') && sed -i "s/{{PUBLIC_KEY_ID}}/$id/g" policy.json
216-
pubb64=$(cat testpub.pem | base64 -w 0) && sed -i "s/{{B64_PUBLIC_KEY}}/$pubb64/g" policy.json
220+
pubb64=$(base64 -w 0 < testpub.pem) && sed -i "s/{{B64_PUBLIC_KEY}}/$pubb64/g" policy.json
217221

218222
# 8. Sign the policy file
219223
witness sign -f policy.json --signer-file-key-path testkey.pem --outfile policy-signed.json

tests/nix/test_nix_fmt.bats

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ buildInputs=[pkgs.hello];
2525
EOF
2626

2727
# Mock nixpkgs-fmt
28-
mock_command "nixpkgs-fmt" "cat > default.nix << 'FORMATTED'
29-
{ pkgs }:
28+
mock_command "nixpkgs-fmt" "echo '{ pkgs }:
3029
pkgs.mkShell {
3130
buildInputs = [ pkgs.hello ];
32-
}
33-
FORMATTED"
31+
}' > \"\$1\""
3432

3533
run "$ORIGINAL_DIR/hooks/nix/nix-fmt.sh"
3634
[ "$status" -eq 0 ]

0 commit comments

Comments
 (0)