mirror of
https://github.com/Lifailon/lazyjournal.git
synced 2026-11-11 01:09:46 +01:00
3b42caf33c
Bumps the go-dependencies group with 2 updates: [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact). Updates `actions/upload-artifact` from 4 to 6 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v6) Updates `actions/download-artifact` from 4 to 7 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v4...v7) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: go-dependencies - dependency-name: actions/download-artifact dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: go-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
446 lines
19 KiB
YAML
446 lines
19 KiB
YAML
name: CI (Build and Testing)
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
Distro:
|
|
description: 'Select runner image for testing'
|
|
required: true
|
|
default: 'ubuntu-24.04'
|
|
type: choice
|
|
# https://github.com/actions/runner-images
|
|
options:
|
|
- 'ubuntu-24.04'
|
|
- 'macos-26'
|
|
- 'macos-15'
|
|
- 'windows-2025'
|
|
- 'windows-2022'
|
|
Update:
|
|
description: 'Update dependencies in modules'
|
|
default: false
|
|
type: boolean
|
|
Test:
|
|
description: 'Go unit testing'
|
|
default: false
|
|
type: boolean
|
|
Release:
|
|
description: 'Check flags and release in tmux'
|
|
default: false
|
|
type: boolean
|
|
Binary:
|
|
description: 'Build binary and deb packages'
|
|
default: false
|
|
type: boolean
|
|
README:
|
|
description: 'Update version in README'
|
|
default: false
|
|
type: boolean
|
|
|
|
run-name: "CI #${{ github.run_number }} on ${{ github.event.inputs.Distro }}"
|
|
|
|
jobs:
|
|
test:
|
|
name: Testing on ${{ github.event.inputs.Distro }}
|
|
|
|
runs-on: ${{ github.event.inputs.Distro }}
|
|
|
|
env:
|
|
APP_VERSION: 'n/a'
|
|
LAST_COMMIT: 'n/a'
|
|
COVERAGE: 'n/a'
|
|
|
|
steps:
|
|
- name: Checkout repository (main branch and 1 last commits)
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 1
|
|
ref: main
|
|
|
|
- name: Install Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: 1.25
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
go fmt ./...
|
|
go vet ./...
|
|
go get ./...
|
|
go mod tidy
|
|
go mod verify
|
|
go build -v ./...
|
|
|
|
- name: Get build information
|
|
shell: bash
|
|
run: |
|
|
DATETIME=$(date +"%d.%m.%Y %H:%M")
|
|
GO_VERSION=$(go version | awk '{print $3,"("$4")"}' | sed -e "s/go//g")
|
|
APP_VERSION=$(go run main.go -v)
|
|
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
|
|
LAST_COMMIT=$(git rev-parse --short HEAD)
|
|
echo "LAST_COMMIT=$LAST_COMMIT" >> $GITHUB_ENV
|
|
|
|
echo "## 🚀 Build Information" > build-info.md
|
|
|
|
echo "- **Date**: $DATETIME" >> build-info.md
|
|
echo "- **Build number**: #${{ github.run_number }}" >> build-info.md
|
|
echo "- **Go version**: $GO_VERSION" >> build-info.md
|
|
echo "- **App version**: $APP_VERSION" >> build-info.md
|
|
echo "- **Last commit**: [$LAST_COMMIT](${{ github.server_url }}/${{ github.repository }}/commit/$LAST_COMMIT)" >> build-info.md
|
|
|
|
echo "### Parameters" >> build-info.md
|
|
echo "- **OS**: ${{ github.event.inputs.Distro }}" >> build-info.md
|
|
echo "- **Update dependencies in modules**: ${{ github.event.inputs.Update == 'true' && '✅' || '❌' }}" >> build-info.md
|
|
echo "- **Go unit testing**: ${{ github.event.inputs.Test == 'true' && '✅' || '❌' }}" >> build-info.md
|
|
echo "- **Check flags and release in [tmux](https://github.com/tmux/tmux)**: ${{ github.event.inputs.Release == 'true' && '✅' || '❌' }}" >> build-info.md
|
|
echo "- **Build binary and deb packages**: ${{ github.event.inputs.Binary == 'true' && '✅' || '❌' }}" >> build-info.md
|
|
echo "- **Update version in README**: ${{ github.event.inputs.README == 'true' && '✅' || '❌' }}" >> build-info.md
|
|
|
|
- name: Update dependencies in modules
|
|
if: ${{ github.event.inputs.Update == 'true' }}
|
|
run: go get -u ./...
|
|
|
|
# Unit testing in Linux
|
|
|
|
- name: Start docker containers using compose
|
|
if: ${{ (github.event.inputs.Release == 'true' || github.event.inputs.Test == 'true') && github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
run: |
|
|
version=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)
|
|
curl -sSL "https://github.com/docker/compose/releases/download/$version/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
sudo chmod +x /usr/local/bin/docker-compose
|
|
mkdir -p $HOME/.docker/cli-plugins
|
|
cp /usr/local/bin/docker-compose $HOME/.docker/cli-plugins/docker-compose
|
|
docker compose version
|
|
sed "s/TTYD=false/TTYD=true/" docker-compose.yml -i
|
|
docker compose up -d
|
|
docker run -d --name pinguem -p 8085:8085 -p 3005:3005 lifailon/pinguem:latest
|
|
|
|
- name: Create pcap files for Linux
|
|
if: ${{ github.event.inputs.Test == 'true' && github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
run: |
|
|
sudo tcpdump -i any -c 1 -w test.pcap
|
|
gzip -c test.pcap > test.pcap.gz
|
|
sudo tcpdump -i any -c 1 -w test.pcapng
|
|
gzip -c test.pcapng > test.pcapng.gz
|
|
ls -lh
|
|
|
|
- name: Install auditd and create rules
|
|
if: ${{ github.event.inputs.Test == 'true' && github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
run: |
|
|
sudo apt install -y auditd
|
|
sudo auditctl -w /etc/ssh/ -p rwxa -k ssh
|
|
sudo auditctl -w /etc/passwd -p wa -k passwd
|
|
sudo auditctl -l
|
|
|
|
- name: Install bat and tailspin
|
|
if: ${{ github.event.inputs.Test == 'true' && github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
run: |
|
|
sudo apt install -y bat
|
|
bat --version || batcat --version || true
|
|
# sudo apt install -y tailspin
|
|
version=$(curl -s https://api.github.com/repos/bensadeh/tailspin/releases/latest | jq -r .tag_name)
|
|
curl -L "https://github.com/bensadeh/tailspin/releases/download/$version/tailspin-$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')-musl.tar.gz" -o /usr/local/bin/tailspin.tar.gz
|
|
tar -xzf /usr/local/bin/tailspin.tar.gz -C /usr/local/bin
|
|
mv /usr/local/bin/tspin /usr/local/bin/tailspin
|
|
chmod +x /usr/local/bin/tailspin
|
|
rm /usr/local/bin/*.tar.gz
|
|
tailspin --version
|
|
|
|
- name: Install gotestsum for junit report
|
|
if: ${{ github.event.inputs.Test == 'true' }}
|
|
run: go install gotest.tools/gotestsum@latest
|
|
|
|
- name: Unit testing in Linux (all functions and mock interface)
|
|
if: ${{ github.event.inputs.Test == 'true' && github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
id: unitTestLinux
|
|
continue-on-error: true
|
|
timeout-minutes: 10
|
|
run: sudo env "PATH=$PATH" gotestsum --format standard-verbose --junitfile report.xml -- ./... -v -cover | tee test.log
|
|
|
|
# Unit testing for Docker without root
|
|
|
|
- name: Unit testing for docker without root in Linux
|
|
if: ${{ github.event.inputs.Test == 'true' && github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
continue-on-error: true
|
|
timeout-minutes: 5
|
|
run: env "PATH=$PATH" go test -v -cover --run "TestDockerContainer"
|
|
|
|
- name: Check cli mode (color and filter) for container
|
|
if: ${{ github.event.inputs.Test == 'true' && github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
continue-on-error: true
|
|
run: |
|
|
docker logs lazyjournal | go run main.go -c
|
|
docker logs lazyjournal | go run main.go -f "start"
|
|
docker logs lazyjournal | go run main.go -r "start|close"
|
|
docker logs lazyjournal | go run main.go -c -r "start|close"
|
|
|
|
# Unit testing in macOS
|
|
|
|
- name: Unit testing in macOS (files, flags, cli and run main interface)
|
|
if: ${{ github.event.inputs.Test == 'true' && (github.event.inputs.Distro == 'macos-15' || github.event.inputs.Distro == 'macos-26') }}
|
|
timeout-minutes: 5
|
|
continue-on-error: true
|
|
shell: bash
|
|
run: |
|
|
env "PATH=$PATH" gotestsum --format standard-verbose --junitfile report.xml -- ./... -v -cover \
|
|
--run "TestUnixFiles|TestFlags|TestCommandColor|TestCommandFuzzyFilter|TestCommandRegexFilter|TestMainInterface" | tee test.log
|
|
|
|
# Unit testing in Windows
|
|
|
|
- name: Create log file for Windows
|
|
if: ${{ github.event.inputs.Test == 'true' && (github.event.inputs.Distro == 'windows-2022' || github.event.inputs.Distro == 'windows-2025') }}
|
|
continue-on-error: true
|
|
shell: pwsh
|
|
run: |
|
|
New-Item -Path "$env:APPDATA\test" -Type Directory
|
|
"line test" | Out-File -FilePath "$env:APPDATA\test\test.log"
|
|
|
|
- name: Unit testing in Windows (events, files, flags, cli, main and mock interface)
|
|
if: ${{ github.event.inputs.Test == 'true' && (github.event.inputs.Distro == 'windows-2022' || github.event.inputs.Distro == 'windows-2025') }}
|
|
timeout-minutes: 5
|
|
continue-on-error: true
|
|
shell: bash
|
|
run: |
|
|
env "PATH=$PATH" gotestsum --format standard-verbose --junitfile report.xml -- ./... -v -cover \
|
|
--run "TestWin.*|TestFlags|TestCommandColor|TestCommandFuzzyFilter|TestCommandRegexFilter|TestMainInterface|TestMockInterface" | tee test.log
|
|
|
|
# Build info report
|
|
|
|
- name: Send build info report to summary
|
|
continue-on-error: true
|
|
shell: bash
|
|
run: |
|
|
cat build-info.md >> $GITHUB_STEP_SUMMARY
|
|
|
|
# Coverage report
|
|
|
|
- name: Get coverage result
|
|
if: ${{ github.event.inputs.Test == 'true' }}
|
|
continue-on-error: true
|
|
shell: bash
|
|
run: |
|
|
COVERAGE=$(cat test.log | grep -E "^coverage: " | sed "s/coverage: //" | sed -E "s/ of.+//")
|
|
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
|
|
echo "---" >> $GITHUB_STEP_SUMMARY
|
|
echo "## 🧪 Test report" >> $GITHUB_STEP_SUMMARY
|
|
echo "💡 **Coverage**: $COVERAGE" >> $GITHUB_STEP_SUMMARY
|
|
|
|
# Junit report
|
|
|
|
- name: Publish junit report in summary
|
|
uses: test-summary/action@v2
|
|
if: ${{ github.event.inputs.Test == 'true' }}
|
|
with:
|
|
paths: "report.xml"
|
|
|
|
- name: Publish junit report in annotations
|
|
uses: mikepenz/action-junit-report@v6
|
|
if: ${{ github.event.inputs.Test == 'true' }}
|
|
with:
|
|
report_paths: "report.xml"
|
|
|
|
# Markdown report
|
|
|
|
- name: Send markdown report to summary for Linux or macOS
|
|
if: ${{ github.event.inputs.Test == 'true' && github.event.inputs.Distro != 'windows-2022' && github.event.inputs.Distro != 'windows-2025' }}
|
|
continue-on-error: true
|
|
shell: bash
|
|
run: cat test-report.md >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Send markdown report to summary for Windows
|
|
if: ${{ github.event.inputs.Test == 'true' && (github.event.inputs.Distro == 'windows-2022' || github.event.inputs.Distro == 'windows-2025') }}
|
|
continue-on-error: true
|
|
shell: pwsh
|
|
run: Get-Content test-report.md | Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY
|
|
|
|
# Release check (flags and tmux)
|
|
|
|
- name: Install binary from last commit on GitHub
|
|
if: ${{ github.event.inputs.Release == 'true' }}
|
|
run: |
|
|
LAST_COMMIT_HASH=$(git ls-remote https://github.com/lifailon/lazyjournal HEAD | awk '{print $1}')
|
|
go install github.com/Lifailon/lazyjournal@$LAST_COMMIT_HASH
|
|
|
|
- name: Check flags (cli mode)
|
|
if: ${{ github.event.inputs.Release == 'true' }}
|
|
run: |
|
|
echo -e "\n\033[32mVersion:\033[0m\n"
|
|
lazyjournal -v
|
|
echo -e "\n\033[32mConfig:\033[0m\n"
|
|
lazyjournal -g
|
|
echo -e "\n\033[32mAudit:\033[0m\n"
|
|
lazyjournal -a
|
|
echo -e "\n\033[32mColoring:\033[0m\n"
|
|
curl -s https://raw.githubusercontent.com/Lifailon/lazyjournal/refs/heads/main/color.log | lazyjournal -c
|
|
echo -e "\n\033[32mFiltering in fuzzy mode:\033[0m\n"
|
|
curl -s https://raw.githubusercontent.com/Lifailon/lazyjournal/refs/heads/main/color.log | lazyjournal -f "error"
|
|
echo -e "\n\033[32mFiltering in fuzzy mode with output coloring:\033[0m\n"
|
|
curl -s https://raw.githubusercontent.com/Lifailon/lazyjournal/refs/heads/main/color.log | lazyjournal -f "error" -c
|
|
echo -e "\n\033[32mFiltering in regex mode:\033[0m\n"
|
|
curl -s https://raw.githubusercontent.com/Lifailon/lazyjournal/refs/heads/main/color.log | lazyjournal -r "error|fatal|fail|crash"
|
|
echo -e "\n\033[32mFiltering in regex mode with output coloring:\033[0m\n"
|
|
curl -s https://raw.githubusercontent.com/Lifailon/lazyjournal/refs/heads/main/color.log | lazyjournal -r "error|fatal|fail|crash" -c
|
|
|
|
- name: Check interface in TMUX
|
|
if: ${{ github.event.inputs.Release == 'true' }}
|
|
run: |
|
|
tmux new-session -d -s test-session "lazyjournal"
|
|
sleep 1
|
|
tmux capture-pane -p
|
|
tmux send-keys -t test-session "$(echo -e 'cron')"
|
|
tmux send-keys -t test-session "$(echo -e '\t')" # Tab
|
|
tmux send-keys -t test-session "$(echo -e '\r')" # Enter
|
|
sleep 3
|
|
tmux capture-pane -p
|
|
tmux send-keys -t test-session "$(echo -e '\t\t\t\t\t')"
|
|
for i in {1..4}; do tmux send-keys -t test-session "$(echo -e '\x7f')"; done
|
|
tmux send-keys -t test-session "$(echo -e 'lazy')"
|
|
tmux send-keys -t test-session "$(echo -e '\t\t\t')"
|
|
tmux send-keys -t test-session "$(echo -e '\x1b[C')" # Right
|
|
sleep 1
|
|
tmux send-keys -t test-session "$(echo -e '\x1b[D')" # Left
|
|
sleep 1
|
|
tmux send-keys -t test-session "$(echo -e '\r')"
|
|
sleep 3
|
|
tmux capture-pane -p
|
|
tmux send-keys -t test-session "$(echo -e '\t')"
|
|
tmux send-keys -t test-session "$(echo -e '\x1b[A')" # Up
|
|
tmux send-keys -t test-session "$(echo -e '\x1b[B')" # Down
|
|
tmux send-keys -t test-session "$(echo -e '\x1b[B')"
|
|
tmux send-keys -t test-session "$(echo -e '\x1b[B')"
|
|
tmux send-keys -t test-session "$(echo -e 'tty|port')"
|
|
sleep 3
|
|
tmux capture-pane -p
|
|
tmux kill-session -t test-session
|
|
|
|
# Telegram report
|
|
|
|
- name: Send report to Telegram only on Linux
|
|
uses: appleboy/telegram-action@master
|
|
if: ${{ github.event.inputs.Distro == 'ubuntu-24.04' }}
|
|
with:
|
|
token: ${{ secrets.TELEGRAM_API_TOKEN }}
|
|
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
|
|
debug: true
|
|
format: markdown
|
|
message: |
|
|
🔔 **Action**: CI (build and unit testing)
|
|
|
|
📁 **Repository**: ${{ github.repository }}
|
|
👤 **User**: ${{ github.actor }}
|
|
🔗 **Build**: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
|
⭐️ **Version**: ${{ env.APP_VERSION }}
|
|
💬 **Last commit**: [${{ env.LAST_COMMIT }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ env.LAST_COMMIT }})
|
|
|
|
Parameters:
|
|
**OS**: ${{ github.event.inputs.Distro }}
|
|
**Update dependencies in modules**: ${{ github.event.inputs.Update == 'true' && '✅' || '❌' }}
|
|
**Go unit testing**: ${{ github.event.inputs.Test == 'true' && '✅' || '❌' }}
|
|
**Check flags and release in tmux**: ${{ github.event.inputs.Release == 'true' && '✅' || '❌' }}
|
|
**Build binary and deb packages**: ${{ github.event.inputs.Binary == 'true' && '✅' || '❌' }}
|
|
**Update version in README**: ${{ github.event.inputs.README == 'true' && '✅' || '❌' }}
|
|
|
|
🚀 Result unit testing: ${{ steps.unitTestLinux.outcome }}
|
|
🧪 Result unit coverage: ${{ env.COVERAGE || 'n/a' }}
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Build on ubuntu-latest
|
|
|
|
if: ${{ github.event.inputs.Binary == 'true' || github.event.inputs.README == 'true' }}
|
|
|
|
env:
|
|
VERSION: 'latest'
|
|
|
|
steps:
|
|
- name: Checkout repository (main branch and 1 last commits)
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 1
|
|
ref: main
|
|
|
|
- name: Install Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: 1.25
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
go fmt ./...
|
|
go vet ./...
|
|
go get ./...
|
|
go mod tidy
|
|
go mod verify
|
|
go build -v ./...
|
|
|
|
- name: Get app version for build
|
|
run: |
|
|
version=$(go run main.go -v)
|
|
echo "VERSION=$version" >> $GITHUB_ENV
|
|
|
|
# Build binary and deb package
|
|
|
|
- name: Build binaries
|
|
run: |
|
|
mkdir -p bin
|
|
architectures=("amd64" "arm64")
|
|
oss=("linux" "darwin" "openbsd" "freebsd" "windows")
|
|
for arch in "${architectures[@]}"; do
|
|
for os in "${oss[@]}"; do
|
|
binName="bin/lazyjournal-$VERSION-$os-$arch"
|
|
if [[ "$os" == "windows" ]]; then
|
|
binName="$binName.exe"
|
|
fi
|
|
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -o "$binName"
|
|
done
|
|
done
|
|
ls -lh bin
|
|
echo "ARTIFACT_NAME=lazyjournal-$VERSION" >> $GITHUB_ENV
|
|
|
|
- name: Build deb package
|
|
run: |
|
|
rm -f lazyjournal
|
|
mkdir -p lazyjournal/DEBIAN lazyjournal/usr/local/bin
|
|
architectures=("amd64" "arm64")
|
|
for arch in "${architectures[@]}"; do
|
|
rm -f lazyjournal/usr/local/bin/lazyjournal
|
|
cp bin/lazyjournal-$VERSION-linux-$arch lazyjournal/usr/local/bin/lazyjournal
|
|
rm -f lazyjournal/DEBIAN/control
|
|
echo "Package: lazyjournal" > lazyjournal/DEBIAN/control
|
|
echo "Version: $VERSION" >> lazyjournal/DEBIAN/control
|
|
echo "Architecture: $arch" >> lazyjournal/DEBIAN/control
|
|
echo "Maintainer: https://github.com/Lifailon" >> lazyjournal/DEBIAN/control
|
|
echo "Description: TUI for viewing logs from journald, auditd, file system, Docker and Podman containers, Compose stacks and Kubernetes pods." >> lazyjournal/DEBIAN/control
|
|
dpkg-deb --build lazyjournal lazyjournal-$VERSION-$arch.deb
|
|
dpkg-deb --contents lazyjournal-$VERSION-$arch.deb
|
|
mv lazyjournal-$VERSION-$arch.deb bin/lazyjournal-$VERSION-$arch.deb
|
|
done
|
|
ls -lh bin/*.deb
|
|
|
|
- name: Check install deb package
|
|
run: |
|
|
# sudo dpkg -i bin/lazyjournal-$VERSION-amd64.deb
|
|
# sudo dpkg -r lazyjournal
|
|
sudo apt install -y ./bin/lazyjournal-$VERSION-amd64.deb
|
|
lazyjournal -v
|
|
sudo apt remove -y lazyjournal
|
|
|
|
- name: Upload binaries
|
|
if: ${{ github.event.inputs.Binary == 'true' }}
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: ${{ env.ARTIFACT_NAME }}
|
|
path: bin/
|
|
env:
|
|
ARTIFACT_NAME: ${{ env.ARTIFACT_NAME }}
|
|
|
|
- name: Update version to README for install deb package
|
|
if: ${{ github.event.inputs.README == 'true' && env.VERSION != '' }}
|
|
run: |
|
|
sed -i -E "s|releases/download/[0-9.]+/lazyjournal-[0-9.]+-|releases/download/$VERSION/lazyjournal-$VERSION-|" README.md
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add README.md
|
|
git commit -m "update version on $VERSION for install deb package"
|
|
git push origin main |