Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,29 @@ on:
- main

jobs:
test:
unit-tests:
runs-on: macos-latest
steps:
- uses: LuisEnMarroquin/setup-ssh-action@v2.0.5
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test

integration-test:
runs-on: macos-latest
needs: unit-tests
steps:
- uses: LuisEnMarroquin/setup-ssh-action@v3.0.0
with:
SSHKEY: ${{ secrets.SSH_GITHUB }}
- run: ssh -T git@github.com || true
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Test

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

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run type checking
run: npm run typecheck

- name: Run unit tests
run: npm run test

- name: Run tests with coverage
run: npm run test:coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage/lcov.info
flags: unittests
continue-on-error: true

build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Check if dist/ is up to date
run: |
if [[ `git status --porcelain dist/` ]]; then
echo "❌ dist/ directory is not up to date. Please run 'npm run build' and commit the changes."
git diff --name-only
git diff
exit 1
else
echo "βœ… dist/ directory is up to date."
fi
23 changes: 21 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,29 @@ on:
- main

jobs:
test:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: LuisEnMarroquin/setup-ssh-action@v2.0.5
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test

integration-test:
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: LuisEnMarroquin/setup-ssh-action@v3.0.0
with:
SSHKEY: ${{ secrets.SSH_GITHUB }}
- run: ssh -T git@github.com || true
23 changes: 21 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,29 @@ on:
- main

jobs:
test:
unit-tests:
runs-on: windows-latest
steps:
- uses: LuisEnMarroquin/setup-ssh-action@v2.0.5
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test

integration-test:
runs-on: windows-latest
needs: unit-tests
steps:
- uses: LuisEnMarroquin/setup-ssh-action@v3.0.0
with:
SSHKEY: ${{ secrets.SSH_GITHUB }}
- run: ssh -T git@github.com || true
169 changes: 169 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0] - 2024-12-28

### πŸš€ Major Release - Complete Refactor

This is a major refactor that brings significant improvements in security, maintainability, and reliability while maintaining full backward compatibility.

### ✨ Added

#### πŸ—οΈ **Modular Architecture**
- **TypeScript Modularization**: Complete rewrite with TypeScript modules
- **InputValidator**: Dedicated input validation and sanitization
- **SSHManager**: Centralized SSH configuration and file operations
- **GitManager**: Enhanced Git configuration with GitHub context integration
- **Utils**: Common utilities and platform detection

#### πŸ”’ **Enhanced Security**
- **SSH Key Validation**: Support for RSA, Ed25519, ECDSA, DSS key formats
- **Input Validation**: Port numbers (1-65535), hostname/IP validation
- **Input Sanitization**: Length limits for names (255 chars) and users (32 chars)
- **File Permissions**: Proper permission setting (755 for directory, 600 for private key)
- **Security Warnings**: Validation warnings for suspicious inputs

#### πŸ§ͺ **Comprehensive Testing**
- **41 Unit Tests**: Full test coverage with Jest
- **Cross-Platform Tests**: Windows, macOS, and Linux scenarios
- **Mock-Based Testing**: Isolated testing of all components
- **Edge Case Coverage**: Invalid inputs and error condition handling
- **CI/CD Integration**: Automated testing on all PRs and pushes

#### πŸ›‘οΈ **Robust Error Handling**
- **Detailed Error Messages**: Clear, actionable error descriptions
- **Graceful Degradation**: Fallback behaviors for non-critical failures
- **Enhanced Logging**: Comprehensive logging with @actions/core
- **Error Recovery**: Better handling of permission and file system errors

#### 🌐 **Cross-Platform Improvements**
- **Platform Detection**: Enhanced platform-specific logic
- **Windows Support**: Improved CMD/PowerShell detection and handling
- **Unix Improvements**: Better cleanup and permission handling
- **macOS Compatibility**: Tested and verified on macOS runners

#### πŸ“‹ **CI/CD Workflows**
- **PR Testing**: Automatic testing on all pull requests to main
- **Build Verification**: Ensures dist/ directory is up to date
- **Coverage Reports**: Code coverage tracking with Codecov integration
- **Multi-Platform CI**: Tests run on Ubuntu, Windows, and macOS

### πŸ”§ Changed

#### **Input Processing**
- **GitHub Context Integration**: Dynamic git configuration from GitHub context
- **Fallback Strategy**: Intelligent fallbacks for missing user information
- **Validation Pipeline**: Multi-stage input validation and sanitization

#### **SSH Configuration**
- **Template System**: Improved SSH config generation with proper escaping
- **Host Management**: Better host name and alias handling
- **Key Management**: Secure private key storage and permission setting

#### **Build Process**
- **TypeScript Compilation**: Full TypeScript support with type checking
- **Module Bundling**: Optimized bundling with @vercel/ncc
- **Development Scripts**: Added test, coverage, and type checking scripts

### πŸ—‘οΈ Removed

#### **Hardcoded Values**
- **User Credentials**: Removed hardcoded fallback user credentials
- **Static Configuration**: Eliminated static configuration values
- **Magic Strings**: Replaced with typed constants and enums

#### **Legacy Code**
- **Monolithic Structure**: Split into focused, testable modules
- **Inline Logic**: Extracted into dedicated utility functions
- **Console Logging**: Replaced with proper @actions/core logging

### πŸ“¦ Dependencies

#### **Added**
- `@types/jest`: ^29.5.14
- `jest`: ^29.7.0
- `ts-jest`: ^29.2.5

#### **Updated**
- `@actions/core`: ^1.11.1
- `@actions/github`: ^6.0.0
- `@types/node`: ^22.9.0
- `@vercel/ncc`: ^0.38.2
- `cross-env`: ^7.0.3
- `typescript`: ^5.6.3

### πŸ”„ Migration Guide

This version maintains **full backward compatibility**. No changes are required to existing workflows:

```yaml
# This continues to work exactly as before
- uses: LuisEnMarroquin/setup-ssh-action@v3.0.0
with:
SSHKEY: ${{ secrets.SSH }}
```

#### **New Features Available**
- Enhanced error messages for debugging
- Better cross-platform compatibility
- Improved security validation
- More detailed logging output

#### **Recommended Updates**
- Update version from `@v2.0.5` to `@v3.0.0` in workflows
- Consider setting up branch protection rules for better CI/CD
- Review security warnings in action logs

### πŸ§ͺ Testing

#### **Test Coverage**
- **41 comprehensive unit tests** covering all functionality
- **100% branch coverage** for critical paths
- **Cross-platform test scenarios** for all supported platforms
- **Error condition testing** for robust error handling

#### **CI/CD Pipeline**
- **Automated testing** on all PRs to main
- **Multi-platform validation** (Ubuntu, Windows, macOS)
- **Build verification** ensures consistency
- **Coverage reporting** tracks code quality

### πŸ“š Documentation

#### **Enhanced README**
- Updated usage examples with v3.0.0
- Added testing and CI/CD documentation
- Branch protection setup guide
- Troubleshooting section

#### **Code Documentation**
- Comprehensive JSDoc comments
- Type definitions for all interfaces
- Example usage in tests

#### **Development Guide**
- Testing instructions
- Build process documentation
- Contributing guidelines

---

## [2.0.5] - 2023-XX-XX

### Changed
- Released with better formatting
- Updated README.md with additional information

## [2.0.1] - 2023-XX-XX

### Changed
- Updated all dependencies to latest versions
- Version consistency improvements

---

**Full Changelog**: https://github.com/LuisEnMarroquin/setup-ssh-action/compare/v2.0.5...v3.0.0
Loading
Loading