Minor fixes #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
lint: | |
name: Lint and Format Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.25' | |
- name: Install golangci-lint | |
uses: golangci/golangci-lint-action@v8 | |
with: | |
version: v2.4.0 | |
args: --timeout=10m | |
skip-cache: true | |
- name: Install goimports | |
run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: Check formatting | |
run: | | |
if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then | |
echo "Code is not formatted. Please run 'make fmt' and commit changes." | |
gofmt -l . | |
exit 1 | |
fi | |
- name: Check imports | |
run: | | |
if [ "$(goimports -l . | wc -l)" -gt 0 ]; then | |
echo "Imports are not properly formatted. Please run 'make fmt' and commit changes." | |
goimports -l . | |
exit 1 | |
fi | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: [ '1.25' ] | |
os: [ ubuntu-latest, macos-latest ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install dependencies | |
run: go mod download | |
- name: Verify dependencies | |
run: go mod verify | |
- name: Run tests | |
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
file: ./coverage.out | |
flags: unittests | |
name: codecov-umbrella | |
fail_ci_if_error: false | |
security: | |
name: Security Scan | |
runs-on: ubuntu-latest | |
needs: [lint, test] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.25' | |
- name: Install GoSec | |
run: | | |
go install github.com/securego/gosec/v2/cmd/gosec@latest | |
- name: Run GoSec | |
run: | | |
gosec -fmt sarif -out results.sarif ./... | |
- name: Upload GoSec SARIF | |
uses: github/codeql-action/upload-sarif@v3 | |
if: always() | |
with: | |
sarif_file: results.sarif | |
- name: Run govulncheck | |
run: | | |
go install golang.org/x/vuln/cmd/govulncheck@latest | |
govulncheck ./... | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: [lint, test] | |
strategy: | |
matrix: | |
goos: [linux, darwin, windows] | |
goarch: [amd64, arm64] | |
exclude: | |
- goos: windows | |
goarch: arm64 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.25' | |
- name: Build for ${{ matrix.goos }}/${{ matrix.goarch }} | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
run: | | |
go build -v -ldflags="-s -w -X main.Version=$(cat VERSION)" -o "ssh-aliases-${{ matrix.goos }}-${{ matrix.goarch }}" | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ssh-aliases-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: ssh-aliases-${{ matrix.goos }}-${{ matrix.goarch }} | |
dependency-review: | |
name: Dependency Review | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Dependency Review | |
uses: actions/dependency-review-action@v4 | |
with: | |
fail-on-severity: moderate |