@codfish/actions 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/codeql-config.yml +21 -0
- package/.github/dependabot.yml +35 -0
- package/.github/workflows/claude-code-review.yml +43 -0
- package/.github/workflows/claude.yml +39 -0
- package/.github/workflows/release.yml +48 -0
- package/.github/workflows/security.yml +103 -0
- package/.github/workflows/update-docs.yml +38 -0
- package/.github/workflows/validate.yml +210 -0
- package/.husky/pre-commit +1 -0
- package/.nvmrc +1 -0
- package/AGENT.md +129 -0
- package/CLAUDE.md +3 -0
- package/CONTRIBUTING.md +316 -0
- package/README.md +207 -0
- package/SECURITY.md +208 -0
- package/bin/generate-docs.js +432 -0
- package/comment/README.md +82 -0
- package/comment/action.yml +102 -0
- package/eslint.config.js +8 -0
- package/npm-publish-pr/README.md +145 -0
- package/npm-publish-pr/action.yml +171 -0
- package/package.json +52 -0
- package/setup-node-and-install/README.md +139 -0
- package/setup-node-and-install/action.yml +220 -0
- package/tests/fixtures/.node-version +1 -0
- package/tests/fixtures/.nvmrc +1 -0
- package/tests/fixtures/lockfiles/package-lock.json +12 -0
- package/tests/fixtures/lockfiles/pnpm-lock.yaml +9 -0
- package/tests/fixtures/lockfiles/yarn.lock +7 -0
- package/tests/fixtures/package-json/minimal.json +4 -0
- package/tests/fixtures/package-json/scoped.json +6 -0
- package/tests/fixtures/package-json/valid.json +13 -0
- package/tests/integration/comment/basic.bats +95 -0
- package/tests/integration/npm-pr-version/basic.bats +353 -0
- package/tests/integration/setup-node-and-install/basic.bats +200 -0
- package/tests/scripts/test-helpers.sh +113 -0
- package/tests/scripts/test-runner.sh +115 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Test runner script for GitHub Actions
|
|
5
|
+
# Usage: ./test-runner.sh [integration|unit|all]
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
9
|
+
TEST_DIR="$PROJECT_ROOT/tests"
|
|
10
|
+
|
|
11
|
+
# Colors for output
|
|
12
|
+
RED='\033[0;31m'
|
|
13
|
+
GREEN='\033[0;32m'
|
|
14
|
+
YELLOW='\033[1;33m'
|
|
15
|
+
BLUE='\033[0;34m'
|
|
16
|
+
NC='\033[0m' # No Color
|
|
17
|
+
|
|
18
|
+
log() {
|
|
19
|
+
echo -e "${BLUE}[TEST]${NC} $*"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
success() {
|
|
23
|
+
echo -e "${GREEN}[SUCCESS]${NC} $*"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
error() {
|
|
27
|
+
echo -e "${RED}[ERROR]${NC} $*"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
warn() {
|
|
31
|
+
echo -e "${YELLOW}[WARN]${NC} $*"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Check dependencies
|
|
35
|
+
check_dependencies() {
|
|
36
|
+
log "Checking dependencies..."
|
|
37
|
+
|
|
38
|
+
if ! command -v bats >/dev/null 2>&1; then
|
|
39
|
+
error "bats is not installed. Install with: pnpm install"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
if ! command -v act >/dev/null 2>&1; then
|
|
44
|
+
warn "act is not installed. Integration tests will use GitHub Actions API"
|
|
45
|
+
warn "Install act for local testing: brew install act"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
success "Dependencies checked"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Run unit tests
|
|
52
|
+
run_unit_tests() {
|
|
53
|
+
log "Running unit tests..."
|
|
54
|
+
|
|
55
|
+
if [ ! -d "$TEST_DIR/unit" ] || [ -z "$(find "$TEST_DIR/unit" -name "*.bats" 2>/dev/null)" ]; then
|
|
56
|
+
warn "No unit tests found in $TEST_DIR/unit"
|
|
57
|
+
return 0
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
bats "$TEST_DIR/unit"/**/*.bats
|
|
61
|
+
success "Unit tests completed"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Run integration tests
|
|
65
|
+
run_integration_tests() {
|
|
66
|
+
log "Running integration tests..."
|
|
67
|
+
|
|
68
|
+
if [ ! -d "$TEST_DIR/integration" ] || [ -z "$(find "$TEST_DIR/integration" -name "*.bats" 2>/dev/null)" ]; then
|
|
69
|
+
warn "No integration tests found in $TEST_DIR/integration"
|
|
70
|
+
return 0
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Set up test environment
|
|
74
|
+
export GITHUB_ACTIONS=true
|
|
75
|
+
export GITHUB_WORKFLOW="test"
|
|
76
|
+
export GITHUB_RUN_ID="test-run"
|
|
77
|
+
export GITHUB_RUN_NUMBER="1"
|
|
78
|
+
export GITHUB_SHA="$(git rev-parse HEAD 2>/dev/null || echo "test-sha")"
|
|
79
|
+
export GITHUB_REF="refs/heads/test"
|
|
80
|
+
export GITHUB_REPOSITORY="codfish/actions"
|
|
81
|
+
export GITHUB_ACTOR="test-user"
|
|
82
|
+
export GITHUB_EVENT_NAME="push"
|
|
83
|
+
|
|
84
|
+
bats "$TEST_DIR/integration"/**/*.bats
|
|
85
|
+
success "Integration tests completed"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Main execution
|
|
89
|
+
main() {
|
|
90
|
+
cd "$PROJECT_ROOT"
|
|
91
|
+
|
|
92
|
+
local test_type="${1:-all}"
|
|
93
|
+
|
|
94
|
+
log "Starting test runner (type: $test_type)"
|
|
95
|
+
log "Project root: $PROJECT_ROOT"
|
|
96
|
+
|
|
97
|
+
check_dependencies
|
|
98
|
+
|
|
99
|
+
case "$test_type" in
|
|
100
|
+
"unit")
|
|
101
|
+
run_unit_tests
|
|
102
|
+
;;
|
|
103
|
+
"integration")
|
|
104
|
+
run_integration_tests
|
|
105
|
+
;;
|
|
106
|
+
"all"|*)
|
|
107
|
+
run_unit_tests
|
|
108
|
+
run_integration_tests
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
111
|
+
|
|
112
|
+
success "All tests completed successfully!"
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main "$@"
|