@codfish/actions 2.0.0 → 3.3.1
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/README.md +135 -64
- package/bin/generate-docs.js +10 -10
- package/comment/README.md +9 -9
- package/comment/action.yml +3 -3
- package/npm-publish-pr/README.md +319 -40
- package/npm-publish-pr/action.yml +271 -87
- package/package.json +19 -14
- package/setup-node-and-install/README.md +77 -34
- package/setup-node-and-install/action.yml +40 -5
- package/.github/codeql-config.yml +0 -21
- package/.github/dependabot.yml +0 -35
- package/.github/workflows/claude-code-review.yml +0 -43
- package/.github/workflows/claude.yml +0 -38
- package/.github/workflows/release.yml +0 -48
- package/.github/workflows/security.yml +0 -103
- package/.github/workflows/update-docs.yml +0 -38
- package/.github/workflows/validate.yml +0 -210
- package/.husky/pre-commit +0 -1
- package/.nvmrc +0 -1
- package/AGENT.md +0 -149
- package/CLAUDE.md +0 -3
- package/CONTRIBUTING.md +0 -316
- package/SECURITY.md +0 -208
- package/eslint.config.js +0 -8
- package/tests/fixtures/.node-version +0 -1
- package/tests/fixtures/.nvmrc +0 -1
- package/tests/fixtures/lockfiles/package-lock.json +0 -12
- package/tests/fixtures/lockfiles/pnpm-lock.yaml +0 -9
- package/tests/fixtures/lockfiles/yarn.lock +0 -7
- package/tests/fixtures/package-json/minimal.json +0 -4
- package/tests/fixtures/package-json/scoped.json +0 -6
- package/tests/fixtures/package-json/valid.json +0 -13
- package/tests/integration/comment/basic.bats +0 -95
- package/tests/integration/npm-pr-version/basic.bats +0 -438
- package/tests/integration/setup-node-and-install/basic.bats +0 -638
- package/tests/scripts/test-helpers.sh +0 -113
- package/tests/scripts/test-runner.sh +0 -115
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# Test helper functions for GitHub Actions testing
|
|
4
|
-
|
|
5
|
-
# Setup test environment variables
|
|
6
|
-
setup_github_env() {
|
|
7
|
-
export GITHUB_ACTIONS=true
|
|
8
|
-
export GITHUB_WORKFLOW="test"
|
|
9
|
-
export GITHUB_RUN_ID="test-run-$(date +%s)"
|
|
10
|
-
export GITHUB_RUN_NUMBER="1"
|
|
11
|
-
export GITHUB_SHA="${GITHUB_SHA:-$(git rev-parse HEAD 2>/dev/null || echo "test-sha-$(date +%s)")}"
|
|
12
|
-
export GITHUB_REF="refs/heads/test"
|
|
13
|
-
export GITHUB_REPOSITORY="codfish/actions"
|
|
14
|
-
export GITHUB_ACTOR="test-user"
|
|
15
|
-
export GITHUB_EVENT_NAME="pull_request"
|
|
16
|
-
export GITHUB_EVENT_PATH="/tmp/github-event.json"
|
|
17
|
-
|
|
18
|
-
# Create mock event file
|
|
19
|
-
cat > "$GITHUB_EVENT_PATH" <<EOF
|
|
20
|
-
{
|
|
21
|
-
"number": 123,
|
|
22
|
-
"pull_request": {
|
|
23
|
-
"number": 123,
|
|
24
|
-
"head": {
|
|
25
|
-
"sha": "$GITHUB_SHA"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
EOF
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
# Create temporary test directory
|
|
33
|
-
create_test_repo() {
|
|
34
|
-
local test_dir="$1"
|
|
35
|
-
local package_json_fixture="${2:-valid}"
|
|
36
|
-
|
|
37
|
-
mkdir -p "$test_dir"
|
|
38
|
-
cp "tests/fixtures/package-json/${package_json_fixture}.json" "$test_dir/package.json"
|
|
39
|
-
|
|
40
|
-
# Initialize git repo if needed
|
|
41
|
-
if [ ! -d "$test_dir/.git" ]; then
|
|
42
|
-
cd "$test_dir"
|
|
43
|
-
git init
|
|
44
|
-
git config user.name "Test User"
|
|
45
|
-
git config user.email "test@example.com"
|
|
46
|
-
git add .
|
|
47
|
-
git commit -m "Initial commit"
|
|
48
|
-
cd - >/dev/null
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
echo "$test_dir"
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# Mock npm publish command
|
|
55
|
-
mock_npm_publish() {
|
|
56
|
-
cat > /tmp/mock-npm <<'EOF'
|
|
57
|
-
#!/usr/bin/env bash
|
|
58
|
-
echo "Mock npm publish called with args: $*"
|
|
59
|
-
echo "npm notice"
|
|
60
|
-
echo "npm notice 📦 test-package@0.0.0-PR-123--abc1234"
|
|
61
|
-
echo "npm notice === Published Successfully ==="
|
|
62
|
-
exit 0
|
|
63
|
-
EOF
|
|
64
|
-
chmod +x /tmp/mock-npm
|
|
65
|
-
export PATH="/tmp:$PATH"
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
# Cleanup test environment
|
|
69
|
-
cleanup_test_env() {
|
|
70
|
-
local test_dir="$1"
|
|
71
|
-
if [ -n "$test_dir" ] && [ -d "$test_dir" ]; then
|
|
72
|
-
rm -rf "$test_dir"
|
|
73
|
-
fi
|
|
74
|
-
rm -f /tmp/mock-npm /tmp/github-event.json
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
# Check if action output contains expected value
|
|
78
|
-
assert_output_contains() {
|
|
79
|
-
local expected="$1"
|
|
80
|
-
local actual="$2"
|
|
81
|
-
|
|
82
|
-
if [[ "$actual" == *"$expected"* ]]; then
|
|
83
|
-
return 0
|
|
84
|
-
else
|
|
85
|
-
echo "Expected output to contain: $expected"
|
|
86
|
-
echo "Actual output: $actual"
|
|
87
|
-
return 1
|
|
88
|
-
fi
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
# Check if file exists
|
|
92
|
-
assert_file_exists() {
|
|
93
|
-
local file="$1"
|
|
94
|
-
if [ -f "$file" ]; then
|
|
95
|
-
return 0
|
|
96
|
-
else
|
|
97
|
-
echo "Expected file to exist: $file"
|
|
98
|
-
return 1
|
|
99
|
-
fi
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
# Check if environment variable is set
|
|
103
|
-
assert_env_set() {
|
|
104
|
-
local var_name="$1"
|
|
105
|
-
local var_value="${!var_name}"
|
|
106
|
-
|
|
107
|
-
if [ -n "$var_value" ]; then
|
|
108
|
-
return 0
|
|
109
|
-
else
|
|
110
|
-
echo "Expected environment variable to be set: $var_name"
|
|
111
|
-
return 1
|
|
112
|
-
fi
|
|
113
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
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 "$@"
|