Skip to content

Commit

Permalink
test new tools
Browse files Browse the repository at this point in the history
  • Loading branch information
reynico committed Sep 30, 2024
1 parent 672e8ad commit f8db227
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/test-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test Container Sec Tools

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build and test all tools
run: |
for tool in $(make list | tail -n +2); do
echo "Testing tool: $tool"
make test $tool
done
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TOOLS := trivy trufflehog

.PHONY: help build-all build run list clean
.PHONY: help build-all build run list clean test

help:
@echo "Usage:"
Expand All @@ -14,6 +14,7 @@ help:
@echo " run <tool> -- [args...] Run a specific tool (e.g., make run trufflehog -- git ssh://github.com/reynico/container-sec-tools --only-verified)"
@echo " list List all available tools"
@echo " clean Remove all Docker images"
@echo " test <tool> Test a specific tool to check if it runs without errors"
@echo ""
@echo "Available tools:"
@echo " $(TOOLS)"
Expand Down Expand Up @@ -58,6 +59,29 @@ clean:
done
@echo "All images removed."

test:
@tool="$(word 2,$(MAKECMDGOALS))"; \
if [ -z "$$tool" ]; then \
echo "Please specify a tool to test. Available tools: $(TOOLS)"; \
exit 1; \
fi; \
if echo "$(TOOLS)" | grep -wq "$$tool"; then \
echo "Testing Docker image for $$tool"; \
make build $$tool; \
echo "Running $$tool to ensure it executes without errors..."; \
docker run --rm $$tool; \
if [ $$? -eq 0 ]; then \
echo "Test for $$tool passed!"; \
else \
echo "Test for $$tool failed!"; \
exit 1; \
fi; \
else \
echo "Tool $$tool not found. Available tools: $(TOOLS)"; \
exit 1; \
fi
@exit 0

# Prevent make from interpreting additional arguments as targets
%:
@:

0 comments on commit f8db227

Please sign in to comment.