Skip to content

Commit

Permalink
Initial commit for public kflowd repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk29 committed Apr 12, 2024
0 parents commit 95ca0ec
Show file tree
Hide file tree
Showing 16 changed files with 295,682 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/kflowd-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: kflowd-ci

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
ci:
runs-on: ubuntu-20.04
steps:
- name: 'Create Build Environment'
run: |
sudo apt update
sudo apt install -y libz-dev libelf-dev libcap-dev libbfd-dev libc6-dev-i386 pkg-config
sudo wget https://apt.llvm.org/llvm.sh
sudo chmod u+x llvm.sh
echo | sudo ./llvm.sh 16
sudo apt install clang-tidy-16
sudo rm -f /usr/bin/clang
sudo ln -s /usr/bin/clang-16 /usr/bin/clang
sudo rm -f /usr/bin/clang-tidy
sudo ln -s /usr/bin/clang-tidy-16 /usr/bin/clang-tidy
sudo rm -f /usr/bin/llvm-strip
sudo ln -s /usr/bin/llvm-strip-16 /usr/bin/llvm-strip
- name: 'Clone Repository'
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 'Update Submodules'
run: git submodule update --init --recursive

- name: 'Build'
run: |
cd src
make
- name: 'Check with Static Code Analyzer'
run: |
cd src
make check
- name: 'Build Packages'
run: |
cd src
sudo echo -e "deb [trusted=yes] https://repo.goreleaser.com/apt/ /" | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt update
sudo apt install nfpm
make deb
make rpm
- name: 'Update Version'
run: |
VERSION=$(./bin/kflowd --version | cut -f2 -d\ )
git config user.name "GitHub Actions"
git config user.email "<>"
git checkout gh-stats
echo -e "{\"schemaVersion\": 1, \"label\": \"kflowd\", "\
"\"message\": \"$VERSION\", \"color\": \"blue\"}" > gh-stats-version.json
git add gh-stats-version.json
git commit -m "Updated json file to version $VERSION." || true
git push origin gh-stats
- name: 'Create Artifacts'
run: |
cd src
VERSION=$(../bin/kflowd --version | cut -f2 -d\ | cut -c2-)
mkdir -p kflowd-$VERSION/x86_64
cp ../bin/kflowd *.deb *rpm kflowd-$VERSION/x86_64
tar -czvf kflowd-$VERSION.tgz kflowd-$VERSION/x86_64
mkdir -p ../artifacts
mv *.tgz ../artifacts
echo -e "The tar archive contains the kflowd binary and DEB and RPM packages.\n"\
"Run the following commands to extract the archive and install kflowd on your distribution:\n"\
" tar xzvf kflowd-$VERSION.tgz\n"\
" cd kflowd-$VERSION/x86_64/\n"\
" sudo apt install ./kflowd_${VERSION}_amd64.deb # Debian\n"\
" sudo dnf install ./kflowd-$VERSION.x86_64.rpm # Redhat" > ../artifacts/README
- name: 'Name Artifacts'
run: |
cd src
echo "ARTIFACT=kflowd-$(../bin/kflowd --version | cut -f2 -d\ | cut -c2-)" >> $GITHUB_ENV
- name: 'Upload Artifacts'
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: artifacts
82 changes: 82 additions & 0 deletions .github/workflows/kflowd-gh-stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: kflowd-gh-stats

on:
schedule:
- cron: '10 0 * * *'

permissions: write-all

jobs:
gh-stats:
runs-on: ubuntu-20.04
steps:
- name: 'Clone Repository'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 'Install GitHub Api'
run: |
type -p curl >/dev/null || sudo apt install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg\
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg\
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] "\
"https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null\
&& sudo apt update\
&& sudo apt install gh -y
- name: 'Update Views and Clones'
env:
GH_TOKEN: ${{ secrets.GH_STATS_TOKEN }}
run: |
git config user.name "GitHub Actions"
git config user.email "<>"
git checkout gh-stats
gh api -H "Accept: application/vnd.github+json" /repos/kflowd/kflowd/traffic/views > gh-stats-views-14d
VIEWS_14D=$(jq ".count" gh-stats-views-14d)
VIEWS_UNIQUE_14D=$(jq ".uniques" gh-stats-views-14d)
cp gh-stats-views-all all
jq "[.views[]]" gh-stats-views-14d > 14d
jq -s "add | sort_by(.timestamp,-.count) | unique_by(.timestamp) | reverse" 14d all > gh-stats-views-all
VIEWS_TOTAL=$(jq "[.[].count] | add" gh-stats-views-all)
echo -e "{\"schemaVersion\": 1, \"label\": \"VIEWS: Total\", "\
"\"message\": \"$VIEWS_TOTAL\", \"color\": \"yellow\"}" > gh-stats-views.json
echo -e "{\"schemaVersion\": 1, \"label\": \"Unique 14d\", "\
"\"message\": \"$VIEWS_UNIQUE_14D of $VIEWS_14D\", \"color\": \"yellow\"}" > gh-stats-views-14d.json
gh api -H "Accept: application/vnd.github+json" /repos/kflowd/kflowd/traffic/clones > gh-stats-clones-14d
CLONES_14D=$(jq ".count" gh-stats-clones-14d)
CLONES_UNIQUE_14D=$(jq ".uniques" gh-stats-clones-14d)
cp gh-stats-clones-all all
jq "[.clones[]]" gh-stats-clones-14d > 14d
jq -s "add | sort_by(.timestamp,-.count) | unique_by(.timestamp) | reverse" 14d all > gh-stats-clones-all
CLONES_TOTAL=$(jq "[.[].count] | add" gh-stats-clones-all)
echo -e "{\"schemaVersion\": 1, \"label\": \"CLONES: Total\", "\
"\"message\": \"$CLONES_TOTAL\", \"color\": \"orange\"}" > gh-stats-clones.json
echo -e "{\"schemaVersion\": 1, \"label\": \"Unique 14d\", "\
"\"message\": \"$CLONES_UNIQUE_14D of $CLONES_14D\", \"color\": \"orange\"}" > gh-stats-clones-14d.json
git add gh-stats-views.json gh-stats-clones.json gh-stats-views-14d.json gh-stats-clones-14d.json gh-stats-views-all gh-stats-clones-all
MSG_TOTAL=$(echo "Total: $VIEWS_TOTAL views, $CLONES_TOTAL clones")
MSG_14D=$(echo "Unique 14d: $VIEWS_UNIQUE_14D of $VIEWS_14D views, $CLONES_UNIQUE_14D of $CLONES_14D clones")
git commit -m "$MSG_TOTAL"$'\n'"$MSG_14D" || true
git push origin gh-stats
- name: 'Delete gh-stats workflow runs'
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.GH_STATS_TOKEN }}
repository: kflowd/kflowd
delete_workflow_pattern: kflowd-gh-stats
retain_days: 0
keep_minimum_runs: 0

- name: 'Delete pages-build-deployment workflow runs'
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.GH_STATS_TOKEN }}
repository: kflowd/kflowd
delete_workflow_pattern: pages-build-deployment
retain_days: 0
keep_minimum_runs: 0
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
Loading

0 comments on commit 95ca0ec

Please sign in to comment.