Skip to content
Open
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
122 changes: 60 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,63 @@
name: CI
name: ci

on:
push:
branches: [main]
pull_request:
branches: [main]

push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Format check
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "gofmt needed on:"
echo "$unformatted"
exit 1
fi

- name: Test
run: go test ./...

docker:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: daipham3213/mux0.dev
tags: |
type=ref,event=pr
type=ref,event=tag

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: ">=1.24"
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.6
build:
needs: golangci
name: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: daipham3213/mux0.dev
tags: |
type=ref,event=pr
type=ref,event=tag

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
secret-envs: |
SSH_HOST_KEY=${{ secrets.SSH_HOST_KEY }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
RUN if [ -n "$SSH_HOST_KEY" ]; then \
echo "$SSH_HOST_KEY" > /app/host_key; \
else \
apk add --no-cache openssh && \
ssh-keygen -t rsa -b 2048 -f /app/host_key -N ""; \
fi && \
chmod 600 /app/host_key
EXPOSE 22 80
CMD TERM=xterm-256color ./ssh

Check warning on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
5 changes: 4 additions & 1 deletion cmd/ssh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func main() {
)
if err != nil {
log.Error("Could not start server", "error", err)
return
}

log.Info("Starting SSH server", "port", addr)
Expand Down Expand Up @@ -103,7 +104,9 @@ func main() {
}()

<-ctx.Done()
srv.Shutdown(ctx)
if err := srv.Shutdown(ctx); err != nil && !errors.Is(err, ssh.ErrServerClosed) {
log.Error("Could not shutdown server", "error", err)
}
slog.Info("Shutting down server")
}

Expand Down
8 changes: 5 additions & 3 deletions pkg/tui/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const (
large
)

type contextKey string

const clientIPKey contextKey = "client_ip"

type sectionItem struct {
id string
title string
Expand All @@ -48,8 +52,6 @@ type model struct {
viewportHeight int
widthContainer int
heightContainer int
widthContent int
heightContent int
size size
theme theme.Theme
showSplash bool
Expand All @@ -68,7 +70,7 @@ func NewModel(
command []string,
) (tea.Model, error) {
ctx := context.Background()
ctx = context.WithValue(ctx, "client_ip", clientIP)
ctx = context.WithValue(ctx, clientIPKey, clientIP)

p := portfolio.Default()
th := theme.BasicTheme(renderer, nil)
Expand Down
50 changes: 25 additions & 25 deletions pkg/tui/theme/huh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ import (
// copy returns a copy of a TextInputStyles with all children styles copied.
func copyTextStyles(t huh.TextInputStyles) huh.TextInputStyles {
return huh.TextInputStyles{
Cursor: t.Cursor.Copy(),
Placeholder: t.Placeholder.Copy(),
Prompt: t.Prompt.Copy(),
Text: t.Text.Copy(),
Cursor: t.Cursor,
Placeholder: t.Placeholder,
Prompt: t.Prompt,
Text: t.Text,
}
}

// copy returns a copy of a FieldStyles with all children styles copied.
func copyFieldStyles(f huh.FieldStyles) huh.FieldStyles {
return huh.FieldStyles{
Base: f.Base.Copy(),
Title: f.Title.Copy(),
Description: f.Description.Copy(),
ErrorIndicator: f.ErrorIndicator.Copy(),
ErrorMessage: f.ErrorMessage.Copy(),
SelectSelector: f.SelectSelector.Copy(),
// NextIndicator: f.NextIndicator.Copy(),
// PrevIndicator: f.PrevIndicator.Copy(),
Option: f.Option.Copy(),
// Directory: f.Directory.Copy(),
// File: f.File.Copy(),
MultiSelectSelector: f.MultiSelectSelector.Copy(),
SelectedOption: f.SelectedOption.Copy(),
SelectedPrefix: f.SelectedPrefix.Copy(),
UnselectedOption: f.UnselectedOption.Copy(),
UnselectedPrefix: f.UnselectedPrefix.Copy(),
FocusedButton: f.FocusedButton.Copy(),
BlurredButton: f.BlurredButton.Copy(),
Base: f.Base,
Title: f.Title,
Description: f.Description,
ErrorIndicator: f.ErrorIndicator,
ErrorMessage: f.ErrorMessage,
SelectSelector: f.SelectSelector,
// NextIndicator: f.NextIndicator,
// PrevIndicator: f.PrevIndicator,
Option: f.Option,
// Directory: f.Directory,
// File: f.File,
MultiSelectSelector: f.MultiSelectSelector,
SelectedOption: f.SelectedOption,
SelectedPrefix: f.SelectedPrefix,
UnselectedOption: f.UnselectedOption,
UnselectedPrefix: f.UnselectedPrefix,
FocusedButton: f.FocusedButton,
BlurredButton: f.BlurredButton,
TextInput: copyTextStyles(f.TextInput),
Card: f.Card.Copy(),
NoteTitle: f.NoteTitle.Copy(),
Next: f.Next.Copy(),
Card: f.Card,
NoteTitle: f.NoteTitle,
Next: f.Next,
}
}
2 changes: 1 addition & 1 deletion pkg/tui/theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (b Theme) Accent() lipgloss.TerminalColor {
}

func (b Theme) Base() lipgloss.Style {
return b.base.Copy()
return b.base
}

func (b Theme) TextBody() lipgloss.Style {
Expand Down
Loading