mirror of
https://github.com/Adembc/lazyssh.git
synced 2026-07-14 12:13:34 +02:00
ci: add action to enforce semantic PR titles and run tests (#55)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
name: Go Build and Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
types:
|
||||
- edited
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
cache: true
|
||||
|
||||
- name: Run make build
|
||||
run: make build
|
||||
|
||||
- name: Run make test
|
||||
run: make test
|
||||
@@ -0,0 +1,43 @@
|
||||
name: Semantic PRs
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- edited
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
validate_title:
|
||||
name: Validate Title
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: amannn/action-semantic-pull-request@v5.5.3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
types: |
|
||||
fix
|
||||
feat
|
||||
improve
|
||||
refactor
|
||||
revert
|
||||
test
|
||||
ci
|
||||
docs
|
||||
chore
|
||||
|
||||
scopes: |
|
||||
ui
|
||||
cli
|
||||
config
|
||||
parser
|
||||
requireScope: false
|
||||
+8
-1
@@ -14,7 +14,14 @@ issues:
|
||||
- dupl
|
||||
- lll
|
||||
|
||||
|
||||
# exclude some linters for the test directory and test files
|
||||
- path: test/.*|.*_test\.go
|
||||
linters:
|
||||
- dupl
|
||||
- errcheck
|
||||
- goconst
|
||||
- gocyclo
|
||||
- gosec
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
|
||||
@@ -200,6 +200,35 @@ Contributions are welcome!
|
||||
|
||||
We love seeing the community make Lazyssh better 🚀
|
||||
|
||||
### Semantic Pull Requests
|
||||
|
||||
This repository enforces semantic PR titles via an automated GitHub Action. Please format your PR title as:
|
||||
|
||||
- type(scope): short descriptive subject
|
||||
Notes:
|
||||
- Scope is optional and should be one of: ui, cli, config, parser.
|
||||
|
||||
Allowed types in this repo:
|
||||
- feat: a new feature
|
||||
- fix: a bug fix
|
||||
- improve: quality or UX improvements that are not a refactor or perf
|
||||
- refactor: code change that neither fixes a bug nor adds a feature
|
||||
- docs: documentation only changes
|
||||
- test: adding or refactoring tests
|
||||
- ci: CI/CD or automation changes
|
||||
- chore: maintenance tasks, dependency bumps, non-code infra
|
||||
- revert: reverts a previous commit
|
||||
|
||||
Examples:
|
||||
- feat(ui): add server pinning and sorting options
|
||||
- fix(parser): handle comments at end of Host blocks
|
||||
- improve(cli): show friendly error when ssh binary missing
|
||||
- refactor(config): simplify backup rotation logic
|
||||
- docs: add installation instructions for Homebrew
|
||||
- ci: cache Go toolchain and dependencies
|
||||
|
||||
Tip: If your PR touches multiple areas, pick the most relevant scope or omit the scope.
|
||||
|
||||
---
|
||||
|
||||
## ⭐ Support
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -134,6 +136,29 @@ func TestValidateBindAddress(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateKeyPaths(t *testing.T) {
|
||||
// Prepare an isolated HOME with a mock .ssh folder and key files
|
||||
oldHome := os.Getenv("HOME")
|
||||
t.Cleanup(func() {
|
||||
_ = os.Setenv("HOME", oldHome)
|
||||
})
|
||||
|
||||
tempHome := t.TempDir()
|
||||
sshDir := filepath.Join(tempHome, ".ssh")
|
||||
if err := os.MkdirAll(sshDir, 0o755); err != nil {
|
||||
t.Fatalf("failed to create temp .ssh dir: %v", err)
|
||||
}
|
||||
|
||||
shouldExistFiles := []string{"id_rsa", "id_ed25519"}
|
||||
for _, name := range shouldExistFiles {
|
||||
p := filepath.Join(sshDir, name)
|
||||
if err := os.WriteFile(p, []byte("test"), 0o644); err != nil {
|
||||
t.Fatalf("failed to create mock key file %s: %v", p, err)
|
||||
}
|
||||
}
|
||||
if err := os.Setenv("HOME", tempHome); err != nil {
|
||||
t.Fatalf("failed to set HOME: %v", err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
keys string
|
||||
|
||||
Reference in New Issue
Block a user