-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
402 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: bats | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [master, next] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
bats-alpine: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
bash: ["4.2", "4.4", "5.0", "5.2"] | ||
container: | ||
image: bash:${{ matrix.bash }} | ||
steps: | ||
- name: Install packages | ||
run: | | ||
# Pipeline requirements | ||
apk add curl git ncurses parallel sudo tar | ||
# Theme dependencies | ||
apk add bc coreutils gawk jq playerctl sed | ||
# Allow tar to cache system paths | ||
- name: root suid tar | ||
run: sudo chown root:wheel /bin/tar && sudo chmod u+s /bin/tar | ||
|
||
- name: Setup Bats and bats libs | ||
uses: stealthii/bats-action@main | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run tokyo-night-tmux tests | ||
shell: bash -e {0} | ||
run: bats --verbose-run --report-formatter junit test/ | ||
|
||
- name: Upload Test Report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: report-alpine-${{ matrix.bash }} | ||
path: report.xml | ||
bats-macos: | ||
runs-on: macos-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
libs: ["gnu", "builtin"] | ||
steps: | ||
- name: Install Homebrew packages | ||
run: | | ||
# Theme dependencies | ||
brew install bash jq nowplaying-cli | ||
if [[ "${{ matrix.libs }}" == "gnu" ]]; then | ||
brew install bc coreutils gawk gsed | ||
fi | ||
- name: Setup Bats and bats libs | ||
run: | | ||
brew install bats-core | ||
brew tap stealthii/bats-core | ||
brew install bats-support bats-assert bats-file bats-detik bats-mock | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run tokyo-night-tmux tests | ||
run: bats --verbose-run --report-formatter junit test/ | ||
|
||
- name: Upload Test Report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: report-macOS-${{ matrix.libs }} | ||
path: report.xml | ||
junit-publish: | ||
needs: [bats-alpine, bats-macos] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download all workflow run artifacts | ||
uses: actions/download-artifact@v4 | ||
|
||
- name: Publish Test Report | ||
uses: mikepenz/action-junit-report@v4 | ||
with: | ||
report_paths: "**/report.xml" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: report | ||
on: | ||
workflow_run: | ||
workflows: [bats] | ||
types: [completed] | ||
|
||
permissions: | ||
checks: write | ||
|
||
jobs: | ||
checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Test Report | ||
uses: dawidd6/action-download-artifact@v3 | ||
with: | ||
name: report-.* | ||
name_is_regexp: true | ||
workflow: ${{ github.event.workflow.id }} | ||
run_id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Publish Test Report | ||
uses: mikepenz/action-junit-report@v4 | ||
with: | ||
commit: ${{github.event.workflow_run.head_sha}} | ||
report_paths: "**/report.xml" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# JUnit reports | ||
**/report.xml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
repos: | ||
- repo: https://github.com/pecigonzalo/pre-commit-shfmt | ||
rev: v2.1.0 | ||
- repo: local | ||
hooks: | ||
- id: shell-fmt-go | ||
name: shfmt | ||
description: Rewrites all shell scripts to a canonical format. | ||
language: golang | ||
additional_dependencies: | ||
- mvdan.cc/sh/v3/cmd/[email protected] | ||
entry: shfmt | ||
types: | ||
- file | ||
- shell | ||
exclude_types: | ||
- zsh | ||
args: | ||
- -w | ||
- -s | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Get network transmit data | ||
function get_bytes() { | ||
local interface="$1" | ||
if [[ "$(uname)" == "Linux" ]]; then | ||
awk -v interface="$interface" '$1 == interface ":" {print $2, $10}' /proc/net/dev | ||
elif [[ "$(uname)" == "Darwin" ]]; then | ||
netstat -ib | awk -v interface="$interface" '/^'"${interface}"'/ {print $7, $10}' | head -n1 | ||
else | ||
# Unsupported operating system | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Convert into readable format | ||
function readable_format() { | ||
local bytes=$1 | ||
local secs=${2:-1} | ||
|
||
if [[ $bytes -lt 1048576 ]]; then | ||
echo "$(bc -l <<<"scale=1; $bytes / 1024 / $secs")KB/s" | ||
else | ||
echo "$(bc -l <<<"scale=1; $bytes / 1048576 / $secs")MB/s" | ||
fi | ||
} | ||
|
||
# Auto-determine interface | ||
function find_interface() { | ||
local interface | ||
if [[ $(uname) == "Linux" ]]; then | ||
interface=$(awk '$2 == 00000000 {print $1}' /proc/net/route) | ||
elif [[ $(uname) == "Darwin" ]]; then | ||
interface=$(route get default 2>/dev/null | grep interface | awk '{print $2}') | ||
# If VPN, fallback to en0 | ||
[[ ${interface:0:4} == "utun" ]] && interface="en0" | ||
fi | ||
echo "$interface" | ||
} | ||
|
||
# Detect interface IPv4 and status | ||
function interface_ipv4() { | ||
local interface="$1" | ||
local ipv4_addr | ||
local status="up" # Default assumption | ||
if [[ $(uname) == "Darwin" ]]; then | ||
# Check for an IPv4 on macOS | ||
ipv4_addr=$(ipconfig getifaddr "$interface") | ||
[[ -z $ipv4_addr ]] && status="down" | ||
elif [[ $(uname) == "Linux" ]]; then | ||
# Use 'ip' command to check for IPv4 address | ||
if command -v ip >/dev/null 2>&1; then | ||
ipv4_addr=$(ip addr show dev "$interface" 2>/dev/null | grep "inet\b" | awk '{sub("/.*", "", $2); print $2}') | ||
[[ -z $ipv4_addr ]] && status="down" | ||
# Use 'ifconfig' command to check for IPv4 address | ||
elif command -v ifconfig >/dev/null 2>&1; then | ||
ipv4_addr=$(ifconfig "$interface" 2>/dev/null | grep "inet\b" | awk '{print $2}') | ||
[[ -z $ipv4_addr ]] && status="down" | ||
# Fallback to operstate on Linux | ||
elif [[ $(cat "/sys/class/net/$interface/operstate" 2>/dev/null) != "up" ]]; then | ||
status="down" | ||
fi | ||
fi | ||
echo "$ipv4_addr" | ||
[[ $status == "up" ]] && return 0 || return 1 | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.