@codfish/actions 2.0.1 โ 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 +36 -3
- 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,210 +0,0 @@
|
|
|
1
|
-
name: Validate
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request_target:
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
name: Test Actions
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
permissions:
|
|
15
|
-
pull-requests: write
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout repository
|
|
19
|
-
uses: actions/checkout@v5
|
|
20
|
-
with:
|
|
21
|
-
fetch-depth: 0
|
|
22
|
-
|
|
23
|
-
# Dogfood our own setup-node-and-install action
|
|
24
|
-
- name: Setup Node.js and install dependencies
|
|
25
|
-
uses: ./setup-node-and-install
|
|
26
|
-
with:
|
|
27
|
-
node-version: 'lts/*'
|
|
28
|
-
|
|
29
|
-
- name: Lint commits
|
|
30
|
-
if: github.event_name == 'pull_request_target'
|
|
31
|
-
run:
|
|
32
|
-
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }}
|
|
33
|
-
--verbose
|
|
34
|
-
|
|
35
|
-
- name: Lint code
|
|
36
|
-
run: pnpm lint
|
|
37
|
-
|
|
38
|
-
- name: Run tests
|
|
39
|
-
run: pnpm test
|
|
40
|
-
|
|
41
|
-
# Dogfood our own comment action on PRs
|
|
42
|
-
- name: Comment test results
|
|
43
|
-
if: github.event_name == 'pull_request_target'
|
|
44
|
-
uses: ./comment
|
|
45
|
-
with:
|
|
46
|
-
message: |
|
|
47
|
-
## ๐งช Test Results
|
|
48
|
-
|
|
49
|
-
โ
All tests passed successfully!
|
|
50
|
-
|
|
51
|
-
- Linting: โ
Passed
|
|
52
|
-
- Unit tests: โ
Passed
|
|
53
|
-
- Integration tests: โ
Passed
|
|
54
|
-
tag: test-results
|
|
55
|
-
upsert: true
|
|
56
|
-
|
|
57
|
-
test-matrix:
|
|
58
|
-
name: Test on ${{ matrix.os }}
|
|
59
|
-
runs-on: ${{ matrix.os }}
|
|
60
|
-
strategy:
|
|
61
|
-
matrix:
|
|
62
|
-
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
63
|
-
node-version: ['20', '24', 'lts/*']
|
|
64
|
-
fail-fast: false
|
|
65
|
-
|
|
66
|
-
steps:
|
|
67
|
-
- name: Checkout repository
|
|
68
|
-
uses: actions/checkout@v5
|
|
69
|
-
|
|
70
|
-
# Test our setup-node-and-install action across different environments
|
|
71
|
-
- name: Setup Node.js and install dependencies
|
|
72
|
-
uses: ./setup-node-and-install
|
|
73
|
-
with:
|
|
74
|
-
node-version: ${{ matrix.node-version }}
|
|
75
|
-
|
|
76
|
-
- name: Verify Node.js version
|
|
77
|
-
run: node --version
|
|
78
|
-
|
|
79
|
-
- name: Run basic tests
|
|
80
|
-
run: pnpm test
|
|
81
|
-
|
|
82
|
-
integration-test:
|
|
83
|
-
name: Integration Test - Publish PR Package
|
|
84
|
-
runs-on: ubuntu-latest
|
|
85
|
-
if: github.event_name == 'pull_request_target'
|
|
86
|
-
|
|
87
|
-
permissions:
|
|
88
|
-
pull-requests: write
|
|
89
|
-
|
|
90
|
-
steps:
|
|
91
|
-
- name: Checkout repository
|
|
92
|
-
uses: actions/checkout@v5
|
|
93
|
-
|
|
94
|
-
- name: Setup Node.js and install dependencies
|
|
95
|
-
uses: ./setup-node-and-install
|
|
96
|
-
with:
|
|
97
|
-
node-version: 'lts/*'
|
|
98
|
-
|
|
99
|
-
# Create a test package to publish
|
|
100
|
-
- name: Create test package
|
|
101
|
-
run: |
|
|
102
|
-
mkdir -p test-package
|
|
103
|
-
cd test-package
|
|
104
|
-
cat > package.json <<EOF
|
|
105
|
-
{
|
|
106
|
-
"name": "@codfish/actions-test-package",
|
|
107
|
-
"version": "1.0.0",
|
|
108
|
-
"description": "Test package for GitHub Actions validation",
|
|
109
|
-
"main": "index.js",
|
|
110
|
-
"private": false
|
|
111
|
-
}
|
|
112
|
-
EOF
|
|
113
|
-
echo "module.exports = { test: true };" > index.js
|
|
114
|
-
|
|
115
|
-
# Test our npm-pr-version action (but don't actually publish to avoid spam)
|
|
116
|
-
- name: Test PR version generation
|
|
117
|
-
working-directory: test-package
|
|
118
|
-
env:
|
|
119
|
-
# Don't actually publish by not providing npm-token
|
|
120
|
-
PR: ${{ github.event.number }}
|
|
121
|
-
SHA: ${{ github.event.pull_request.head.sha }}
|
|
122
|
-
run: |
|
|
123
|
-
# Test the version generation logic
|
|
124
|
-
version="0.0.0-PR-${PR}--$(echo ${SHA} | cut -c -7)"
|
|
125
|
-
echo "Generated version: $version"
|
|
126
|
-
|
|
127
|
-
# Test package.json update
|
|
128
|
-
npm version $version --no-git-tag-version
|
|
129
|
-
|
|
130
|
-
# Verify the version was set correctly
|
|
131
|
-
node -e "console.log('Package version:', require('./package.json').version)"
|
|
132
|
-
|
|
133
|
-
# Set output for comment
|
|
134
|
-
echo "version=$version" >> $GITHUB_OUTPUT
|
|
135
|
-
id: version-test
|
|
136
|
-
|
|
137
|
-
# Dogfood our comment action to report results
|
|
138
|
-
- name: Report integration test results
|
|
139
|
-
uses: ./comment
|
|
140
|
-
with:
|
|
141
|
-
message: |
|
|
142
|
-
## ๐ Integration Test Results
|
|
143
|
-
|
|
144
|
-
**npm-pr-version action test:**
|
|
145
|
-
- โ
Version generation: ${{ steps.version-test.outputs.version }}
|
|
146
|
-
- โ
package.json update: Successful
|
|
147
|
-
- โ
Format validation: Passed
|
|
148
|
-
|
|
149
|
-
The action is working correctly! ๐
|
|
150
|
-
tag: integration-test-results
|
|
151
|
-
upsert: true
|
|
152
|
-
|
|
153
|
-
validate-action-metadata:
|
|
154
|
-
name: Validate Action Metadata
|
|
155
|
-
runs-on: ubuntu-latest
|
|
156
|
-
|
|
157
|
-
steps:
|
|
158
|
-
- name: Checkout repository
|
|
159
|
-
uses: actions/checkout@v5
|
|
160
|
-
|
|
161
|
-
- name: Validate action.yml files
|
|
162
|
-
run: |
|
|
163
|
-
echo "Validating action.yml files..."
|
|
164
|
-
|
|
165
|
-
for action_dir in */; do
|
|
166
|
-
if [ -f "${action_dir}action.yml" ]; then
|
|
167
|
-
echo "โ
Found action.yml in $action_dir"
|
|
168
|
-
|
|
169
|
-
# Basic YAML validation
|
|
170
|
-
if ! python3 -c "import yaml; yaml.safe_load(open('${action_dir}action.yml'))" 2>/dev/null; then
|
|
171
|
-
echo "โ Invalid YAML in ${action_dir}action.yml"
|
|
172
|
-
exit 1
|
|
173
|
-
fi
|
|
174
|
-
|
|
175
|
-
# Check for required fields
|
|
176
|
-
if ! grep -q "^name:" "${action_dir}action.yml"; then
|
|
177
|
-
echo "โ Missing 'name' field in ${action_dir}action.yml"
|
|
178
|
-
exit 1
|
|
179
|
-
fi
|
|
180
|
-
|
|
181
|
-
if ! grep -q "^description:" "${action_dir}action.yml"; then
|
|
182
|
-
echo "โ Missing 'description' field in ${action_dir}action.yml"
|
|
183
|
-
exit 1
|
|
184
|
-
fi
|
|
185
|
-
|
|
186
|
-
echo "โ
${action_dir}action.yml is valid"
|
|
187
|
-
else
|
|
188
|
-
echo "โ ๏ธ No action.yml found in $action_dir"
|
|
189
|
-
fi
|
|
190
|
-
done
|
|
191
|
-
|
|
192
|
-
- name: Validate README files
|
|
193
|
-
run: |
|
|
194
|
-
echo "Validating README files..."
|
|
195
|
-
|
|
196
|
-
for action_dir in */; do
|
|
197
|
-
if [ -f "${action_dir}README.md" ]; then
|
|
198
|
-
echo "โ
Found README.md in $action_dir"
|
|
199
|
-
|
|
200
|
-
# Check for basic sections
|
|
201
|
-
if ! grep -q "# " "${action_dir}README.md"; then
|
|
202
|
-
echo "โ Missing main heading in ${action_dir}README.md"
|
|
203
|
-
exit 1
|
|
204
|
-
fi
|
|
205
|
-
|
|
206
|
-
echo "โ
${action_dir}README.md looks good"
|
|
207
|
-
else
|
|
208
|
-
echo "โ ๏ธ No README.md found in $action_dir"
|
|
209
|
-
fi
|
|
210
|
-
done
|
package/.husky/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx lint-staged
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
24.8.0
|
package/AGENT.md
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
# AGENT.md
|
|
2
|
-
|
|
3
|
-
<!-- DOCTOC SKIP -->
|
|
4
|
-
|
|
5
|
-
This file provides guidance to AI agents when working with code in this repository.
|
|
6
|
-
|
|
7
|
-
## Project Overview
|
|
8
|
-
|
|
9
|
-
This repository contains reusable GitHub Actions for use across multiple projects. Each action is self-contained in its
|
|
10
|
-
own directory at the root level.
|
|
11
|
-
|
|
12
|
-
## Package Manager
|
|
13
|
-
|
|
14
|
-
This project uses **pnpm** as the package manager. All commands should use pnpm:
|
|
15
|
-
|
|
16
|
-
- Install dependencies: `pnpm install`
|
|
17
|
-
- Run tests: `pnpm test`
|
|
18
|
-
- Run linting: `pnpm lint`
|
|
19
|
-
- Format code: `pnpm format`
|
|
20
|
-
- Generate documentation: `pnpm docs:generate`
|
|
21
|
-
- Run specific test types: `pnpm test:integration`, `pnpm test:unit`
|
|
22
|
-
|
|
23
|
-
## Code Quality Workflow
|
|
24
|
-
|
|
25
|
-
**IMPORTANT**: Always run the appropriate command after making file changes:
|
|
26
|
-
|
|
27
|
-
- **For JS/TS/TSX/JSX/YML/YAML files**: Run `pnpm fix` to apply ESLint fixes (CRITICAL for YAML files to prevent
|
|
28
|
-
formatting issues)
|
|
29
|
-
- **For JSON/MD/CSS files**: Run `pnpm format` to apply Prettier formatting
|
|
30
|
-
- **When in doubt**: Run both commands in sequence
|
|
31
|
-
|
|
32
|
-
## Action Structure
|
|
33
|
-
|
|
34
|
-
- Action names: lowercase kebab-case (e.g., `npm-publish-pr`)
|
|
35
|
-
- Each action directory contains:
|
|
36
|
-
- `action.yml` - Action definition and metadata
|
|
37
|
-
- Implementation files (JavaScript/TypeScript as needed)
|
|
38
|
-
- `README.md` - Action-specific documentation
|
|
39
|
-
|
|
40
|
-
## Development Guidelines
|
|
41
|
-
|
|
42
|
-
- Actions should be standalone and reusable across different projects
|
|
43
|
-
- Follow GitHub Actions best practices for inputs, outputs, and error handling
|
|
44
|
-
- Use semantic action names that clearly describe their purpose
|
|
45
|
-
- Each action should handle its own dependencies and setup requirements
|
|
46
|
-
- All actions support multiple package managers (npm/yarn/pnpm) when applicable
|
|
47
|
-
- Use comprehensive input validation with clear error messages
|
|
48
|
-
- Include proper error handling and informative logging
|
|
49
|
-
|
|
50
|
-
## Security Best Practices
|
|
51
|
-
|
|
52
|
-
- **File Operations**: Use file descriptors (`fs.openSync()`, `fs.readSync()`, `fs.writeSync()`) instead of file names
|
|
53
|
-
(`fs.readFileSync()`, `fs.writeFileSync()`) to prevent TOCTOU (Time-of-Check-Time-of-Use) vulnerabilities
|
|
54
|
-
- **Resource Management**: Always close file descriptors in `finally` blocks to prevent resource leaks
|
|
55
|
-
- **Atomic Operations**: Keep file descriptors open during entire read-modify-write operations to prevent race
|
|
56
|
-
conditions
|
|
57
|
-
|
|
58
|
-
## Current Actions
|
|
59
|
-
|
|
60
|
-
- `npm-pr-version` - Publishes packages with PR-specific version numbers using detected package manager (npm/yarn/pnpm)
|
|
61
|
-
for testing in downstream apps before merging
|
|
62
|
-
- `comment` - Creates or updates pull request comments with intelligent upsert functionality using unique tags
|
|
63
|
-
- **IMPORTANT**: Any job using the comment action must include `permissions: pull-requests: write`
|
|
64
|
-
- `setup-node-and-install` - Sets up Node.js environment and installs dependencies with automatic package manager
|
|
65
|
-
detection, intelligent caching, and dynamic Node version detection via input, `.node-version`, `.nvmrc`, or
|
|
66
|
-
`package.json` `volta.node`. Validation is relaxed; the action no longer fails when no version is detected.
|
|
67
|
-
|
|
68
|
-
## Testing
|
|
69
|
-
|
|
70
|
-
The project includes comprehensive testing infrastructure:
|
|
71
|
-
|
|
72
|
-
- **Integration tests**: Test full action workflows using bats
|
|
73
|
-
- **Test fixtures**: Reusable test data for different scenarios
|
|
74
|
-
- **CI/CD validation**: Dogfooding actions in GitHub workflows
|
|
75
|
-
- **Multi-platform testing**: Ubuntu, Windows, macOS support
|
|
76
|
-
|
|
77
|
-
Run tests with: `pnpm test`
|
|
78
|
-
|
|
79
|
-
**Cross-Platform Notes:**
|
|
80
|
-
|
|
81
|
-
- Test scripts use `bash` prefix for Windows compatibility
|
|
82
|
-
- All npm scripts should work on Windows, macOS, and Linux
|
|
83
|
-
- Bats tests require bash to be available (included in Git for Windows)
|
|
84
|
-
|
|
85
|
-
## Documentation System
|
|
86
|
-
|
|
87
|
-
### Automated Documentation Generation
|
|
88
|
-
|
|
89
|
-
- Run `pnpm docs:generate` to update all documentation
|
|
90
|
-
- The script automatically:
|
|
91
|
-
1. Updates main README.md with action overview using `<!-- start action docs -->` / `<!-- end action docs -->` markers
|
|
92
|
-
2. Updates individual action README files with inputs/outputs tables using `<!-- start inputs -->` /
|
|
93
|
-
`<!-- end inputs -->` and `<!-- start outputs -->` / `<!-- end outputs -->` markers
|
|
94
|
-
3. Runs prettier formatting on all updated documentation
|
|
95
|
-
|
|
96
|
-
### Documentation Markers
|
|
97
|
-
|
|
98
|
-
- **Main README.md**: Uses `<!-- start action docs -->` and `<!-- end action docs -->` for the Available Actions section
|
|
99
|
-
- **Action README files**: Uses `<!-- start inputs -->` / `<!-- end inputs -->` for inputs tables and
|
|
100
|
-
`<!-- start outputs -->` / `<!-- end outputs -->` for outputs tables
|
|
101
|
-
- **CRITICAL: NEVER EDIT AUTO-GENERATED CONTENT**: Never modify content between ANY HTML comment markers in README
|
|
102
|
-
files:
|
|
103
|
-
- `<!-- START doctoc generated TOC please keep comment here to allow auto update -->` and
|
|
104
|
-
`<!-- END doctoc generated TOC please keep comment here to allow auto update -->` (doctoc table of contents)
|
|
105
|
-
- `<!-- start action docs -->` and `<!-- end action docs -->` (main README action documentation)
|
|
106
|
-
- `<!-- start inputs -->` and `<!-- end inputs -->` (action inputs tables)
|
|
107
|
-
- `<!-- start outputs -->` and `<!-- end outputs -->` (action outputs tables)
|
|
108
|
-
- Any other `<!-- ... -->` comment markers - they indicate auto-generated content
|
|
109
|
-
- All content outside these markers is manually maintained and can be edited
|
|
110
|
-
- **Prettier Protection**: Doctoc blocks are wrapped in `<!-- prettier-ignore-start -->` and
|
|
111
|
-
`<!-- prettier-ignore-end -->` to prevent formatting
|
|
112
|
-
|
|
113
|
-
### Workflow Automation
|
|
114
|
-
|
|
115
|
-
- `.github/workflows/update-docs.yml` automatically runs on changes to `*/action.yml` or `bin/generate-docs.js`
|
|
116
|
-
- Uses `stefanzweifel/git-auto-commit-action` to commit documentation changes
|
|
117
|
-
- Handles both main README.md and all action README files
|
|
118
|
-
- Automatically formats all documentation using prettier
|
|
119
|
-
|
|
120
|
-
## Security
|
|
121
|
-
|
|
122
|
-
The project implements multiple security measures:
|
|
123
|
-
|
|
124
|
-
- **Dependabot**: Automated dependency updates
|
|
125
|
-
- **CodeQL**: Static security analysis
|
|
126
|
-
- **Secret scanning**: TruffleHog for committed secrets (uses default behavior without base/head commits for better
|
|
127
|
-
compatibility)
|
|
128
|
-
- **Vulnerability auditing**: Regular pnpm audit checks
|
|
129
|
-
- **Note**: Dependency review requires GitHub Advanced Security (available free on public repos, paid feature for
|
|
130
|
-
private repos)
|
|
131
|
-
|
|
132
|
-
## Code Quality and File Editing Rules
|
|
133
|
-
|
|
134
|
-
### Bats File Editing Rules
|
|
135
|
-
|
|
136
|
-
**CRITICAL**: After editing any `.bats` file, ALWAYS check for and remove trailing spaces:
|
|
137
|
-
|
|
138
|
-
1. Run: `grep -n " $" path/to/file.bats`
|
|
139
|
-
2. If any trailing spaces are found, remove them immediately
|
|
140
|
-
3. Bats files are NOT automatically formatted by eslint/prettier, so manual cleanup is required
|
|
141
|
-
4. Trailing spaces in bats files can cause test execution issues
|
|
142
|
-
|
|
143
|
-
### General File Editing Guidelines
|
|
144
|
-
|
|
145
|
-
- Do what has been asked; nothing more, nothing less
|
|
146
|
-
- NEVER create files unless they're absolutely necessary for achieving your goal
|
|
147
|
-
- ALWAYS prefer editing an existing file to creating a new one
|
|
148
|
-
- NEVER proactively create documentation files (\*.md) or README files. Only create documentation files if explicitly
|
|
149
|
-
requested by the User
|
package/CLAUDE.md
DELETED
package/CONTRIBUTING.md
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
# Contributing to codfish/actions
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing! This document provides guidelines for contributing to this repository.
|
|
4
|
-
|
|
5
|
-
<!-- prettier-ignore-start -->
|
|
6
|
-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
7
|
-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
8
|
-
## Table of Contents
|
|
9
|
-
|
|
10
|
-
- [Code of Conduct](#code-of-conduct)
|
|
11
|
-
- [Getting Started](#getting-started)
|
|
12
|
-
- [Development Workflow](#development-workflow)
|
|
13
|
-
- [1. Create a Branch](#1-create-a-branch)
|
|
14
|
-
- [2. Make Your Changes](#2-make-your-changes)
|
|
15
|
-
- [3. Test Your Changes](#3-test-your-changes)
|
|
16
|
-
- [4. Commit Your Changes](#4-commit-your-changes)
|
|
17
|
-
- [Action Development Guidelines](#action-development-guidelines)
|
|
18
|
-
- [Directory Structure](#directory-structure)
|
|
19
|
-
- [Action Naming](#action-naming)
|
|
20
|
-
- [Action Definition (action.yml)](#action-definition-actionyml)
|
|
21
|
-
- [Implementation Guidelines](#implementation-guidelines)
|
|
22
|
-
- [Error Handling](#error-handling)
|
|
23
|
-
- [Package Manager Detection](#package-manager-detection)
|
|
24
|
-
- [Testing](#testing)
|
|
25
|
-
- [Test Structure](#test-structure)
|
|
26
|
-
- [Writing Tests](#writing-tests)
|
|
27
|
-
- [Running Tests](#running-tests)
|
|
28
|
-
- [Documentation](#documentation)
|
|
29
|
-
- [README Structure](#readme-structure)
|
|
30
|
-
- [Documentation Updates](#documentation-updates)
|
|
31
|
-
- [Auto-Generated Documentation](#auto-generated-documentation)
|
|
32
|
-
- [Submitting Changes](#submitting-changes)
|
|
33
|
-
- [Pull Request Process](#pull-request-process)
|
|
34
|
-
- [PR Requirements](#pr-requirements)
|
|
35
|
-
- [Review Process](#review-process)
|
|
36
|
-
- [Action Ideas](#action-ideas)
|
|
37
|
-
- [Getting Help](#getting-help)
|
|
38
|
-
- [Recognition](#recognition)
|
|
39
|
-
|
|
40
|
-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
41
|
-
<!-- prettier-ignore-end -->
|
|
42
|
-
|
|
43
|
-
## Code of Conduct
|
|
44
|
-
|
|
45
|
-
This project follows the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected
|
|
46
|
-
to uphold this code.
|
|
47
|
-
|
|
48
|
-
## Getting Started
|
|
49
|
-
|
|
50
|
-
1. **Fork the repository** and clone it locally
|
|
51
|
-
2. **Install dependencies**: `pnpm install`
|
|
52
|
-
3. **Set up your development environment**:
|
|
53
|
-
```bash
|
|
54
|
-
# Install act for local testing (optional but recommended)
|
|
55
|
-
brew install act # macOS
|
|
56
|
-
# or
|
|
57
|
-
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash # Linux
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Development Workflow
|
|
61
|
-
|
|
62
|
-
### 1. Create a Branch
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
git checkout -b feature/your-feature-name
|
|
66
|
-
# or
|
|
67
|
-
git checkout -b fix/your-bug-fix
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### 2. Make Your Changes
|
|
71
|
-
|
|
72
|
-
Follow the [Action Development Guidelines](#action-development-guidelines) below.
|
|
73
|
-
|
|
74
|
-
### 3. Test Your Changes
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# Run all tests
|
|
78
|
-
pnpm test
|
|
79
|
-
|
|
80
|
-
# Run specific test types
|
|
81
|
-
pnpm test:integration
|
|
82
|
-
pnpm test:unit
|
|
83
|
-
|
|
84
|
-
# Run linting
|
|
85
|
-
pnpm lint
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### 4. Commit Your Changes
|
|
89
|
-
|
|
90
|
-
Use clear, descriptive commit messages:
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
git commit -m "feat(setup-node): add yarn berry support"
|
|
94
|
-
git commit -m "fix(comment): handle empty tag input properly"
|
|
95
|
-
git commit -m "docs(npm-pr-version): update README with new examples"
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Action Development Guidelines
|
|
99
|
-
|
|
100
|
-
### Directory Structure
|
|
101
|
-
|
|
102
|
-
Each action should be in its own directory at the repository root:
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
action-name/
|
|
106
|
-
โโโ action.yml # Action definition
|
|
107
|
-
โโโ README.md # Action documentation
|
|
108
|
-
โโโ [implementation files]
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Action Naming
|
|
112
|
-
|
|
113
|
-
- Use **kebab-case** for action directory names
|
|
114
|
-
- Action names should be descriptive and follow the pattern: `verb-noun` or `noun-verb`
|
|
115
|
-
- Examples: `setup-node-and-install`, `npm-pr-version`, `comment`
|
|
116
|
-
|
|
117
|
-
### Action Definition (action.yml)
|
|
118
|
-
|
|
119
|
-
```yaml
|
|
120
|
-
name: action-name
|
|
121
|
-
description: Clear, concise description of what the action does
|
|
122
|
-
|
|
123
|
-
inputs:
|
|
124
|
-
input-name:
|
|
125
|
-
description: Clear description of the input parameter
|
|
126
|
-
required: true|false
|
|
127
|
-
default: 'default-value' # if applicable
|
|
128
|
-
|
|
129
|
-
outputs:
|
|
130
|
-
output-name:
|
|
131
|
-
description: Clear description of the output
|
|
132
|
-
value: '${{ steps.step-id.outputs.output-name }}'
|
|
133
|
-
|
|
134
|
-
runs:
|
|
135
|
-
using: composite
|
|
136
|
-
steps:
|
|
137
|
-
# Implementation steps
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Implementation Guidelines
|
|
141
|
-
|
|
142
|
-
1. **Use composite actions** for consistency and transparency
|
|
143
|
-
2. **Validate inputs** early with clear error messages
|
|
144
|
-
3. **Handle errors gracefully** with actionable feedback
|
|
145
|
-
4. **Use consistent formatting**:
|
|
146
|
-
- โ for errors
|
|
147
|
-
- โ
for success messages
|
|
148
|
-
- ๐ฆ for package manager operations
|
|
149
|
-
- ๐ for informational messages
|
|
150
|
-
5. **Support multiple package managers** when applicable (npm/yarn/pnpm)
|
|
151
|
-
6. **Follow security best practices** - never log secrets or sensitive data
|
|
152
|
-
|
|
153
|
-
### Error Handling
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
# Good error handling example
|
|
157
|
-
if [ ! -f "package.json" ]; then
|
|
158
|
-
echo "โ ERROR: package.json not found in current directory"
|
|
159
|
-
echo "Make sure you're running this action in a directory with a package.json file"
|
|
160
|
-
exit 1
|
|
161
|
-
fi
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Package Manager Detection
|
|
165
|
-
|
|
166
|
-
When applicable, detect package managers in this order:
|
|
167
|
-
|
|
168
|
-
1. `yarn.lock` โ yarn
|
|
169
|
-
2. `pnpm-lock.yaml` โ pnpm
|
|
170
|
-
3. `package-lock.json` โ npm
|
|
171
|
-
4. No lockfile โ npm (default)
|
|
172
|
-
|
|
173
|
-
## Testing
|
|
174
|
-
|
|
175
|
-
### Test Structure
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
tests/
|
|
179
|
-
โโโ integration/ # Full action tests
|
|
180
|
-
โ โโโ action-name/
|
|
181
|
-
โ โโโ basic.bats
|
|
182
|
-
โโโ fixtures/ # Test data
|
|
183
|
-
โ โโโ package-json/
|
|
184
|
-
โ โโโ lockfiles/
|
|
185
|
-
โโโ scripts/
|
|
186
|
-
โโโ test-runner.sh
|
|
187
|
-
โโโ test-helpers.sh
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Writing Tests
|
|
191
|
-
|
|
192
|
-
1. **Create integration tests** for each action in `tests/integration/action-name/`
|
|
193
|
-
2. **Use the bats testing framework** for shell script testing
|
|
194
|
-
3. **Test error conditions** as well as success scenarios
|
|
195
|
-
4. **Use test fixtures** from `tests/fixtures/` when possible
|
|
196
|
-
|
|
197
|
-
Example test:
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
@test "action-name: handles valid input" {
|
|
201
|
-
# Setup
|
|
202
|
-
cp "$BATS_TEST_DIRNAME/../../../tests/fixtures/package-json/valid.json" package.json
|
|
203
|
-
|
|
204
|
-
# Test
|
|
205
|
-
run bash -c 'your-test-command'
|
|
206
|
-
|
|
207
|
-
# Assertions
|
|
208
|
-
assert_success
|
|
209
|
-
assert_output_contains "expected-output"
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Running Tests
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
# All tests
|
|
217
|
-
pnpm test
|
|
218
|
-
|
|
219
|
-
# Specific action tests
|
|
220
|
-
./tests/scripts/test-runner.sh integration
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
## Documentation
|
|
224
|
-
|
|
225
|
-
### README Structure
|
|
226
|
-
|
|
227
|
-
Each action should have a comprehensive README.md with:
|
|
228
|
-
|
|
229
|
-
1. **Title and description**
|
|
230
|
-
2. **Table of contents** (for longer READMEs)
|
|
231
|
-
3. **Usage section** with basic example
|
|
232
|
-
4. **Inputs table** with descriptions
|
|
233
|
-
5. **Outputs table** (if applicable)
|
|
234
|
-
6. **Examples section** with various use cases
|
|
235
|
-
7. **Special features** (package manager detection, etc.)
|
|
236
|
-
|
|
237
|
-
### Documentation Updates
|
|
238
|
-
|
|
239
|
-
- Update action README when changing inputs/outputs
|
|
240
|
-
- **Run `pnpm docs:generate`** to auto-update the main project README
|
|
241
|
-
- Update CLAUDE.md when changing project structure
|
|
242
|
-
- Add inline comments for complex logic
|
|
243
|
-
|
|
244
|
-
### Auto-Generated Documentation
|
|
245
|
-
|
|
246
|
-
The main project README's "Available Actions" section is automatically generated from:
|
|
247
|
-
|
|
248
|
-
- `action.yml` files (name, description, inputs, outputs)
|
|
249
|
-
- Individual action README files (usage examples)
|
|
250
|
-
|
|
251
|
-
**When to regenerate documentation:**
|
|
252
|
-
|
|
253
|
-
- After adding a new action
|
|
254
|
-
- After changing action.yml inputs/outputs
|
|
255
|
-
- After updating action descriptions
|
|
256
|
-
- Before submitting a PR
|
|
257
|
-
|
|
258
|
-
```bash
|
|
259
|
-
# Generate updated documentation
|
|
260
|
-
pnpm docs:generate
|
|
261
|
-
|
|
262
|
-
# Review the changes
|
|
263
|
-
git diff README.md
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
## Submitting Changes
|
|
267
|
-
|
|
268
|
-
### Pull Request Process
|
|
269
|
-
|
|
270
|
-
1. **Create a descriptive PR title**: `feat(action-name): add new feature`
|
|
271
|
-
2. **Fill out the PR template** completely
|
|
272
|
-
3. **Link related issues** using keywords (Closes #123)
|
|
273
|
-
4. **Request review** from maintainers
|
|
274
|
-
5. **Address feedback** promptly and respectfully
|
|
275
|
-
|
|
276
|
-
### PR Requirements
|
|
277
|
-
|
|
278
|
-
- [ ] All tests pass
|
|
279
|
-
- [ ] Code follows existing style guidelines
|
|
280
|
-
- [ ] Documentation is updated
|
|
281
|
-
- [ ] Changes are tested in real GitHub Actions workflows
|
|
282
|
-
- [ ] No security vulnerabilities introduced
|
|
283
|
-
|
|
284
|
-
### Review Process
|
|
285
|
-
|
|
286
|
-
1. **Automated checks** must pass (tests, linting, security scans)
|
|
287
|
-
2. **Manual review** by maintainers
|
|
288
|
-
3. **Testing** in real-world scenarios
|
|
289
|
-
4. **Approval** and merge
|
|
290
|
-
|
|
291
|
-
## Action Ideas
|
|
292
|
-
|
|
293
|
-
Looking for contribution ideas? Here are some actions that would be valuable:
|
|
294
|
-
|
|
295
|
-
- `slack-notify` - Send Slack notifications
|
|
296
|
-
- `docker-build-push` - Build and push Docker images
|
|
297
|
-
- `semantic-release` - Automated semantic versioning
|
|
298
|
-
- `cache-restore-save` - Advanced caching patterns
|
|
299
|
-
- `monorepo-changed` - Detect changed packages in monorepos
|
|
300
|
-
- `performance-test` - Lighthouse/performance testing
|
|
301
|
-
|
|
302
|
-
## Getting Help
|
|
303
|
-
|
|
304
|
-
- **GitHub Discussions**: Ask questions and discuss ideas
|
|
305
|
-
- **Issues**: Report bugs or request features
|
|
306
|
-
- **Discord/Slack**: [Link if available]
|
|
307
|
-
|
|
308
|
-
## Recognition
|
|
309
|
-
|
|
310
|
-
Contributors will be recognized in:
|
|
311
|
-
|
|
312
|
-
- Commit messages with `Co-authored-by`
|
|
313
|
-
- Release notes
|
|
314
|
-
- Contributors section (if added)
|
|
315
|
-
|
|
316
|
-
Thank you for contributing! ๐
|