Compare commits

...

6 Commits

Author SHA1 Message Date
Bo-Yi Wu e8a39a16a6 chore: refactor release process configuration
- Change the changelog configuration in `.goreleaser.yaml` from using GitHub to using git.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-04-02 15:58:52 +08:00
Bo-Yi Wu f8b1db2997 chore: refine goreleaser configuration and output
- Change the name template in `.goreleaser.yaml` from single to double quotes
- Add a changelog configuration to `.goreleaser.yaml` with categorized groups for features, bug fixes, enhancements, refactor, and others

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-04-02 14:57:44 +08:00
Bo-Yi Wu f37c5b3557 ci: refactor CI workflows and update actions
- Update GitHub Actions to use newer versions (checkout to v4, codeql-action to v3, setup-go to v5, goreleaser-action to v5, golangci-lint-action to v4, codecov-action to v4)
- Remove specific Go version pinning in favor of using the version specified in go.mod
- Enable checking for the latest Go version in setup-go action
- Replace `release --rm-dist` argument with `release --clean` in goreleaser action
- Reorder steps and remove redundant checkout step in testing workflow

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-04-02 14:10:03 +08:00
appleboy 2c5e17dd2e docs: update badge
Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-03-16 13:00:11 +08:00
appleboy 42f9adb1b5 test: rename the workflow 2024-03-16 12:58:52 +08:00
Bo-Yi Wu cafc139713 test: enhance testing and internal API robustness (#269)
* test: support ipv6

* chore: update

Signed-off-by: appleboy <appleboy.tw@gmail.com>

* chore: update

Signed-off-by: appleboy <appleboy.tw@gmail.com>

---------

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-03-16 11:29:44 +08:00
7 changed files with 151 additions and 131 deletions
+3 -3
View File
@@ -38,11 +38,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@v3
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file. # If you wish to specify custom queries, you can do so here or in a config file.
@@ -51,4 +51,4 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main # queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v3
+6 -6
View File
@@ -14,14 +14,14 @@ jobs:
build-docker: build-docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: "^1.21"
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with: with:
fetch-depth: 0 go-version-file: go.mod
check-latest: true
- name: Build binary - name: Build binary
run: | run: |
+8 -8
View File
@@ -12,21 +12,21 @@ jobs:
goreleaser: goreleaser:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup go - name: Setup go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: "^1" go-version-file: go.mod
check-latest: true
- name: Run GoReleaser - name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4 uses: goreleaser/goreleaser-action@v5
with: with:
# either 'goreleaser' (default) or 'goreleaser-pro' # either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser distribution: goreleaser
version: latest version: latest
args: release --rm-dist args: release --clean
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -8,14 +8,17 @@ jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: "^1.21"
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- name: Setup golangci-lint - name: Setup golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v4
with: with:
version: latest version: latest
args: --verbose args: --verbose
@@ -27,10 +30,12 @@ jobs:
testing: testing:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: golang:1.21-alpine container:
image: golang:1.21-alpine
options: --sysctl net.ipv6.conf.all.disable_ipv6=0
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: setup sshd server - name: setup sshd server
run: | run: |
@@ -42,4 +47,4 @@ jobs:
make test make test
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v4
+92 -74
View File
@@ -3,78 +3,78 @@ before:
- go mod tidy - go mod tidy
builds: builds:
- env: - env:
- CGO_ENABLED=0 - CGO_ENABLED=0
goos: goos:
- darwin - darwin
- linux - linux
- windows - windows
- freebsd - freebsd
goarch: goarch:
- amd64 - amd64
- arm - arm
- arm64 - arm64
goarm: goarm:
- "5" - "5"
- "6" - "6"
- "7" - "7"
ignore: ignore:
- goos: darwin - goos: darwin
goarch: arm goarch: arm
- goos: darwin - goos: darwin
goarch: ppc64le goarch: ppc64le
- goos: darwin - goos: darwin
goarch: s390x goarch: s390x
- goos: windows - goos: windows
goarch: ppc64le goarch: ppc64le
- goos: windows - goos: windows
goarch: s390x goarch: s390x
- goos: windows - goos: windows
goarch: arm goarch: arm
goarm: "5" goarm: "5"
- goos: windows - goos: windows
goarch: arm goarch: arm
goarm: "6" goarm: "6"
- goos: windows - goos: windows
goarch: arm goarch: arm
goarm: "7" goarm: "7"
- goos: windows - goos: windows
goarch: arm64 goarch: arm64
- goos: freebsd - goos: freebsd
goarch: ppc64le goarch: ppc64le
- goos: freebsd - goos: freebsd
goarch: s390x goarch: s390x
- goos: freebsd - goos: freebsd
goarch: arm goarch: arm
goarm: "5" goarm: "5"
- goos: freebsd - goos: freebsd
goarch: arm goarch: arm
goarm: "6" goarm: "6"
- goos: freebsd - goos: freebsd
goarch: arm goarch: arm
goarm: "7" goarm: "7"
- goos: freebsd - goos: freebsd
goarch: arm64 goarch: arm64
flags: flags:
- -trimpath - -trimpath
ldflags: ldflags:
- -s -w - -s -w
- -X main.Version={{.Version}} - -X main.Version={{.Version}}
binary: >- binary: >-
{{ .ProjectName }}- {{ .ProjectName }}-
{{- if .IsSnapshot }}{{ .Branch }}- {{- if .IsSnapshot }}{{ .Branch }}-
{{- else }}{{- .Version }}-{{ end }} {{- else }}{{- .Version }}-{{ end }}
{{- .Os }}- {{- .Os }}-
{{- if eq .Arch "amd64" }}amd64 {{- if eq .Arch "amd64" }}amd64
{{- else if eq .Arch "amd64_v1" }}amd64 {{- else if eq .Arch "amd64_v1" }}amd64
{{- else if eq .Arch "386" }}386 {{- else if eq .Arch "386" }}386
{{- else }}{{ .Arch }}{{ end }} {{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}-{{ .Arm }}{{ end }} {{- if .Arm }}-{{ .Arm }}{{ end }}
no_unique_dist_dir: true no_unique_dist_dir: true
hooks: hooks:
post: post:
- cmd: xz -k -9 {{ .Path }} - cmd: xz -k -9 {{ .Path }}
dir: ./dist/ dir: ./dist/
archives: archives:
- format: binary - format: binary
@@ -82,9 +82,9 @@ archives:
allow_different_binary_count: true allow_different_binary_count: true
checksum: checksum:
name_template: 'checksums.txt' name_template: "checksums.txt"
extra_files: extra_files:
- glob: ./**.xz - glob: ./**.xz
snapshot: snapshot:
name_template: "{{ incpatch .Version }}" name_template: "{{ incpatch .Version }}"
@@ -97,3 +97,21 @@ release:
# Templates: allowed # Templates: allowed
extra_files: extra_files:
- glob: ./**.xz - glob: ./**.xz
changelog:
use: git
groups:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 1
- title: "Enhancements"
regexp: "^.*chore[(\\w)]*:+.*$"
order: 2
- title: "Refactor"
regexp: "^.*refactor[(\\w)]*:+.*$"
order: 3
- title: Others
order: 999
+1 -1
View File
@@ -4,7 +4,7 @@
[![GitHub tag](https://img.shields.io/github/tag/appleboy/drone-ssh.svg)](https://github.com/appleboy/drone-ssh/releases) [![GitHub tag](https://img.shields.io/github/tag/appleboy/drone-ssh.svg)](https://github.com/appleboy/drone-ssh/releases)
[![GoDoc](https://godoc.org/github.com/appleboy/drone-ssh?status.svg)](https://godoc.org/github.com/appleboy/drone-ssh) [![GoDoc](https://godoc.org/github.com/appleboy/drone-ssh?status.svg)](https://godoc.org/github.com/appleboy/drone-ssh)
[![Lint and Testing](https://github.com/appleboy/drone-ssh/actions/workflows/lint.yml/badge.svg)](https://github.com/appleboy/drone-ssh/actions/workflows/lint.yml) [![Lint and Testing](https://github.com/appleboy/drone-ssh/actions/workflows/testing.yml/badge.svg?branch=master)](https://github.com/appleboy/drone-ssh/actions/workflows/testing.yml)
[![codecov](https://codecov.io/gh/appleboy/drone-ssh/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-ssh) [![codecov](https://codecov.io/gh/appleboy/drone-ssh/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-ssh)
[![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-ssh)](https://goreportcard.com/report/github.com/appleboy/drone-ssh) [![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-ssh)](https://goreportcard.com/report/github.com/appleboy/drone-ssh)
[![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-ssh.svg)](https://hub.docker.com/r/appleboy/drone-ssh/) [![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-ssh.svg)](https://hub.docker.com/r/appleboy/drone-ssh/)
+27 -30
View File
@@ -432,7 +432,6 @@ func getHostPublicKeyFile(keypath string) (ssh.PublicKey, error) {
} }
pubkey, _, _, _, err = ssh.ParseAuthorizedKey(buf) pubkey, _, _, _, err = ssh.ParseAuthorizedKey(buf)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -965,33 +964,31 @@ func TestSudoCommand(t *testing.T) {
assert.Equal(t, unindent(expected), unindent(buffer.String())) assert.Equal(t, unindent(expected), unindent(buffer.String()))
} }
// TODO: TestCommandWithIPv6 is not working on github actions. func TestCommandWithIPv6(t *testing.T) {
// func TestCommandWithIPv6(t *testing.T) { var (
// var ( buffer bytes.Buffer
// buffer bytes.Buffer expected = `
// expected = ` ======CMD======
// ======CMD====== whoami
// whoami ======END======
// ======END====== out: drone-scp
// out: drone-scp `
// ` )
// )
// plugin := Plugin{ plugin := Plugin{
// Config: Config{ Config: Config{
// Host: []string{"::1"}, Host: []string{"::1"},
// Username: "drone-scp", Username: "drone-scp",
// Port: 22, Port: 22,
// KeyPath: "./tests/.ssh/id_rsa", KeyPath: "./tests/.ssh/id_rsa",
// Script: []string{ Script: []string{
// "whoami", "whoami",
// }, },
// Protocol: easyssh.PROTOCOL_TCP6, Protocol: easyssh.PROTOCOL_TCP6,
// CommandTimeout: 10 * time.Second, CommandTimeout: 10 * time.Second,
// }, },
// Writer: &buffer, Writer: &buffer,
// } }
assert.Nil(t, plugin.Exec())
// assert.Nil(t, plugin.Exec()) assert.Equal(t, unindent(expected), unindent(buffer.String()))
// assert.Equal(t, unindent(expected), unindent(buffer.String())) }
// }