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>
479 lines
17 KiB
YAML
479 lines
17 KiB
YAML
name: Merge coverage and update Wiki
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
Debug:
|
|
description: 'Advanced summary report from tests'
|
|
default: false
|
|
type: boolean
|
|
Linter:
|
|
description: 'Check linters for final report'
|
|
default: false
|
|
type: boolean
|
|
Coverage:
|
|
description: 'Update html and svg reports on Wiki'
|
|
default: false
|
|
type: boolean
|
|
Markdown:
|
|
description: 'Update markdown report on Wiki'
|
|
default: false
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
Linux:
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- name: Checkout main repository
|
|
uses: actions/checkout@v6
|
|
|
|
- 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: Start docker containers using compose
|
|
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
|
|
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
|
|
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
|
|
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: Run all unit test in Linux
|
|
run: sudo go test -v -cover -coverprofile linux-coverage.out
|
|
continue-on-error: true
|
|
timeout-minutes: 10
|
|
|
|
- name: Create markdown report for Linux
|
|
run: |
|
|
mv test-report.md test-linux-report.md
|
|
if [[ "${{ inputs.Debug }}" == "true" ]]; then
|
|
cat test-linux-report.md >> $GITHUB_STEP_SUMMARY
|
|
fi
|
|
continue-on-error: true
|
|
|
|
- name: Upload test summary report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: linux-report
|
|
path: test-linux-report.md
|
|
|
|
- name: Upload coverage report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: linux-coverage
|
|
path: linux-coverage.out
|
|
|
|
Docker:
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- name: Checkout main repository
|
|
uses: actions/checkout@v6
|
|
|
|
- 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: Start docker containers using compose
|
|
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: Run unit test for docker in Linux without root
|
|
run: go test -v --run "TestDockerContainer" -cover -coverprofile docker-coverage.out
|
|
continue-on-error: true
|
|
timeout-minutes: 5
|
|
|
|
- name: Upload coverage report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: docker-coverage
|
|
path: docker-coverage.out
|
|
|
|
macOS:
|
|
runs-on: macos-15
|
|
|
|
steps:
|
|
- name: Checkout main repository
|
|
uses: actions/checkout@v6
|
|
|
|
- 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: Run unit test in macOS
|
|
run: sudo go test -v --run "TestUnixFiles|TestFlags|TestCommandColor|TestCommandFuzzyFilter|TestCommandRegexFilter|TestMainInterface" -cover -coverprofile macos-coverage.out
|
|
continue-on-error: true
|
|
timeout-minutes: 5
|
|
|
|
- name: Create markdown report for macOS
|
|
run: |
|
|
mv test-report.md test-macos-report.md
|
|
if [[ "${{ inputs.Debug }}" == "true" ]]; then
|
|
cat test-macos-report.md >> $GITHUB_STEP_SUMMARY
|
|
fi
|
|
continue-on-error: true
|
|
|
|
- name: Upload test summary report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: macos-report
|
|
path: test-macos-report.md
|
|
|
|
- name: Upload coverage report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: macos-coverage
|
|
path: macos-coverage.out
|
|
|
|
Windows:
|
|
runs-on: windows-2022
|
|
steps:
|
|
- name: Checkout main repository
|
|
uses: actions/checkout@v6
|
|
|
|
- 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: Create log file for Windows
|
|
run: |
|
|
New-Item -Path "$env:APPDATA\test" -Type Directory
|
|
"line test" | Out-File -FilePath "$env:APPDATA\test\test.log"
|
|
shell: pwsh
|
|
continue-on-error: true
|
|
|
|
- name: Run unit test in Windows
|
|
run: go test -v --run "TestWin.*|TestFlags|TestCommandColor|TestCommandFuzzyFilter|TestCommandRegexFilter|TestMainInterface|TestMockInterface" -cover -coverprofile windows-coverage.out
|
|
continue-on-error: true
|
|
timeout-minutes: 5
|
|
|
|
- name: Create markdown report for Windows
|
|
run: |
|
|
Rename-Item -Path test-report.md -NewName test-windows-report.md
|
|
if ($env:DEBUG -eq "true") {
|
|
Get-Content test-windows-report.md | Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY
|
|
}
|
|
shell: pwsh
|
|
continue-on-error: true
|
|
env:
|
|
DEBUG: ${{ inputs.Debug }}
|
|
|
|
- name: Upload test summary report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: windows-report
|
|
path: test-windows-report.md
|
|
|
|
- name: Upload coverage report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: windows-coverage
|
|
path: windows-coverage.out
|
|
|
|
Merge:
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [Linux, Docker, macOS, Windows]
|
|
|
|
env:
|
|
LINUX_COVERAGE: "n/a"
|
|
DOCKER_COVERAGE: "n/a"
|
|
MAC_COVERAGE: "n/a"
|
|
WIN_COVERAGE: "n/a"
|
|
TOTAL_COVERAGE: "n/a"
|
|
|
|
steps:
|
|
- name: Checkout main repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Install Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: 1.25
|
|
|
|
- name: Download coverage report for Linux (with root)
|
|
uses: actions/download-artifact@v7
|
|
with:
|
|
name: linux-coverage
|
|
path: .
|
|
|
|
- name: Download coverage report for Docker without root
|
|
uses: actions/download-artifact@v7
|
|
with:
|
|
name: docker-coverage
|
|
path: .
|
|
|
|
- name: Download coverage report for macOS
|
|
uses: actions/download-artifact@v7
|
|
with:
|
|
name: macos-coverage
|
|
path: .
|
|
|
|
- name: Download coverage report for Windows
|
|
uses: actions/download-artifact@v7
|
|
with:
|
|
name: windows-coverage
|
|
path: .
|
|
|
|
- name: Check coverage report for all tests on Linux with root
|
|
run: |
|
|
out=$(go tool cover -func linux-coverage.out)
|
|
echo "# 🧪 Test Coverage" >> $GITHUB_STEP_SUMMARY
|
|
coverTotal=$(echo "$out" | tail -n 1 | sed -E "s/.+\)\s+//")
|
|
echo "LINUX_COVERAGE=$coverTotal" >> $GITHUB_ENV
|
|
echo "Linux coverage: $coverTotal"
|
|
echo "- 🐧 **Linux**: $coverTotal" >> $GITHUB_STEP_SUMMARY
|
|
cat "$GITHUB_STEP_SUMMARY" > all-report.md
|
|
|
|
- name: Check coverage report for Docker without root
|
|
run: |
|
|
out=$(go tool cover -func docker-coverage.out)
|
|
coverTotal=$(echo "$out" | tail -n 1 | sed -E "s/.+\)\s+//")
|
|
echo "DOCKER_COVERAGE=$coverTotal" >> $GITHUB_ENV
|
|
echo "Docker coverage: $coverTotal"
|
|
echo "- 🐳 **Docker**: $coverTotal" >> $GITHUB_STEP_SUMMARY
|
|
cat "$GITHUB_STEP_SUMMARY" >> all-report.md
|
|
|
|
- name: Check coverage report for macOS
|
|
run: |
|
|
out=$(go tool cover -func macos-coverage.out)
|
|
coverTotal=$(echo "$out" | tail -n 1 | sed -E "s/.+\)\s+//")
|
|
echo "MAC_COVERAGE=$coverTotal" >> $GITHUB_ENV
|
|
echo "macOS coverage: $coverTotal"
|
|
echo "- 🍏 **macOS**: $coverTotal" >> $GITHUB_STEP_SUMMARY
|
|
cat "$GITHUB_STEP_SUMMARY" >> all-report.md
|
|
|
|
- name: Check coverage report for Windows
|
|
run: |
|
|
out=$(go tool cover -func windows-coverage.out)
|
|
coverTotal=$(echo "$out" | tail -n 1 | sed -E "s/.+\)\s+//")
|
|
echo "WIN_COVERAGE=$coverTotal" >> $GITHUB_ENV
|
|
echo "Windows coverage: $coverTotal"
|
|
echo "- 💻 **Windows**: $coverTotal" >> $GITHUB_STEP_SUMMARY
|
|
cat "$GITHUB_STEP_SUMMARY" >> all-report.md
|
|
|
|
- name: Install go coverage merge
|
|
run: |
|
|
go install github.com/wadey/gocovmerge@latest
|
|
echo "$HOME/go/bin" >> $GITHUB_PATH
|
|
export PATH=$HOME/go/bin:$PATH
|
|
which gocovmerge
|
|
|
|
- name: Merge coverage reports
|
|
run: |
|
|
gocovmerge linux-coverage.out docker-coverage.out macos-coverage.out windows-coverage.out > merge-coverage.out
|
|
out=$(go tool cover -func merge-coverage.out)
|
|
coverTotal=$(echo "$out" | tail -n 1 | sed -E "s/.+\)\s+//")
|
|
echo "TOTAL_COVERAGE=$coverTotal" >> $GITHUB_ENV
|
|
echo "Total after merge coverage: $coverTotal"
|
|
echo "- **Total after merge**: $coverTotal" >> $GITHUB_STEP_SUMMARY
|
|
mdReport=$(echo "$out" | sed -E 's/.+\///' | sed "s/:/ /g" | head -n -1)
|
|
title="File Line Function Coverage"
|
|
separator="- - - -"
|
|
echo "# 📚 Merge test results" >> $GITHUB_STEP_SUMMARY
|
|
echo "Test coverage results for all functions:" >> $GITHUB_STEP_SUMMARY
|
|
mdReport=$(echo -e "$title\n$separator\n$mdReport")
|
|
echo "$mdReport" | awk '{print "|" $1 "|" $2 "|" $3 "|" $4 "|"}' >> $GITHUB_STEP_SUMMARY
|
|
cat "$GITHUB_STEP_SUMMARY" >> all-report.md
|
|
|
|
- name: Linters reports
|
|
if: ${{ github.event.inputs.Linter == 'true' }}
|
|
run: |
|
|
echo "# 👮♂️ Linters check" >> $GITHUB_STEP_SUMMARY
|
|
echo "## GolangCI" >> $GITHUB_STEP_SUMMARY
|
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
|
|
golangci-lint run -v ./main.go 2>&1 | tee -a $GITHUB_STEP_SUMMARY
|
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
echo "## Go Critic" >> $GITHUB_STEP_SUMMARY
|
|
go install github.com/go-critic/go-critic/cmd/gocritic@latest
|
|
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
|
|
gocritic check -v -enableAll ./main.go 2>&1 | tee -a $GITHUB_STEP_SUMMARY
|
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
echo "## Go Security" >> $GITHUB_STEP_SUMMARY
|
|
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
|
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
|
|
gosec -severity=high ./... 2>&1 | tee -a $GITHUB_STEP_SUMMARY
|
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
cat "$GITHUB_STEP_SUMMARY" >> all-report.md
|
|
|
|
- name: Upload merge coverage report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: merge-coverage
|
|
path: merge-coverage.out
|
|
|
|
- name: Update html and svg reports on Wiki
|
|
if: ${{ github.event.inputs.Coverage == 'true' }}
|
|
uses: ncruces/go-coverage-report@v0
|
|
with:
|
|
coverage-file: merge-coverage.out
|
|
report: true
|
|
chart: true
|
|
amend: true
|
|
continue-on-error: true
|
|
|
|
- name: Download test summary report for Linux
|
|
uses: actions/download-artifact@v7
|
|
with:
|
|
name: linux-report
|
|
path: .
|
|
|
|
- name: Download test summary report for macOS
|
|
uses: actions/download-artifact@v7
|
|
with:
|
|
name: macos-report
|
|
path: .
|
|
|
|
- name: Download test summary report for Windows
|
|
uses: actions/download-artifact@v7
|
|
with:
|
|
name: windows-report
|
|
path: .
|
|
|
|
- name: Merge all reports
|
|
run: |
|
|
echo "# 🐧 Linux" >> all-report.md
|
|
cat "test-linux-report.md" >> all-report.md
|
|
echo "# 🍏 macOS" >> all-report.md
|
|
cat "test-macos-report.md" >> all-report.md
|
|
echo "# 💻 Windows" >> all-report.md
|
|
cat "test-windows-report.md" >> all-report.md
|
|
|
|
- name: Upload final report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: all-report
|
|
path: all-report.md
|
|
|
|
- name: Checkout Wiki repository
|
|
if: ${{ github.event.inputs.Markdown == 'true' }}
|
|
run: git clone https://github.com/Lifailon/lazyjournal.wiki wiki
|
|
|
|
- name: Update markdown report on Wiki
|
|
if: ${{ github.event.inputs.Markdown == 'true' }}
|
|
run: |
|
|
echo -e '# Test report\n' > wiki/home.md
|
|
echo -e 'The test coverage report in `html` format using [go-coverage-report](https://github.com/marketplace/actions/go-coverage-report) is available [here](https://raw.githubusercontent.com/wiki/Lifailon/lazyjournal/coverage.html).\n' >> wiki/home.md
|
|
echo -e 'During testing, the interface operation is checked in the disabled `tcell` mode, as well as the reading and coloring time of all available logs in Linux, macOS and Windows systems.\n' >> wiki/home.md
|
|
echo -e 'To combine test results from different systems [gosovmerge](https://github.com/wadey/gocovmerge) is used.\n' >> wiki/home.md
|
|
echo -e '# 📈 Coverage history\n' >> wiki/home.md
|
|
echo -e '\n' >> wiki/home.md
|
|
cat all-report.md >> wiki/home.md
|
|
cd wiki
|
|
git config --global user.name 'GitHub Actions'
|
|
git config --global user.email 'actions@github.com'
|
|
git add home.md
|
|
if ! git diff --staged --quiet; then
|
|
git diff
|
|
git commit -m "update markdown report"
|
|
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/Lifailon/lazyjournal.wiki.git master
|
|
else
|
|
echo "No changes to commit"
|
|
fi
|
|
|
|
- name: Send report to Telegram
|
|
uses: appleboy/telegram-action@master
|
|
with:
|
|
token: ${{ secrets.TELEGRAM_API_TOKEN }}
|
|
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
|
|
debug: true
|
|
format: markdown
|
|
message: |
|
|
🔔 **Action**: Merge coverage
|
|
|
|
📁 **Repository**: ${{ github.repository }}
|
|
👤 **User**: ${{ github.actor }}
|
|
🔗 **Build**: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
|
|
|
Result unit testing coverage:
|
|
🐧 Linux: ${{ env.LINUX_COVERAGE }}
|
|
🐳 Docker: ${{ env.DOCKER_COVERAGE }}
|
|
🍏 macOS: ${{ env.MAC_COVERAGE }}
|
|
💻 Windows: ${{ env.WIN_COVERAGE }}
|
|
📚 Total: ${{ env.TOTAL_COVERAGE }} |