Skip to content

feat

feat #1331

Workflow file for this run

name: CICD-PUSH
on:
push:
branches:
- '*'
- '*/*'
tags-ignore:
- '*'
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
BASE_BRANCH: origin/main
GO_VERSION: "1.21"
jobs:
trigger-mode:
runs-on: ubuntu-latest
outputs:
trigger-mode: ${{ steps.get_trigger_mode.outputs.trigger_mode }}
base-commitid: ${{ steps.get_trigger_mode.outputs.base_commitid }}
steps:
- name: Cancel Previous Runs
if: github.ref_name != 'main'
uses: styfle/cancel-workflow-action@0.11.0
with:
all_but_latest: true
access_token: ${{ github.token }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get trigger mode
id: get_trigger_mode
run: |
TRIGGER_MODE=`bash .github/utils/utils.sh --type 6 \
--branch-name "${{ github.ref_name }}" \
--base-branch "${{ env.BASE_BRANCH }}"`
BASE_COMMITID=`bash .github/utils/utils.sh --type 19 \
--branch-name "${{ github.ref_name }}" \
--base-branch "${{ env.BASE_BRANCH }}"`
echo "TRIGGER_MODE:$TRIGGER_MODE"
echo "BASE_COMMITID:$BASE_COMMITID"
echo trigger_mode=$TRIGGER_MODE >> $GITHUB_OUTPUT
echo base_commitid=$BASE_COMMITID >> $GITHUB_OUTPUT
pre-push:
needs: trigger-mode
runs-on: ubuntu-latest
name: Push Pre-Check
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install pcregrep
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install pcregrep
- name: gen pcregrep
run: |
pcregrep --exclude-dir=mtr -r -n -I '[^\x00-\x7f]' . > pcregrep.out
- name: pcregrep Chinese
run: |
FILE_PATH=`git diff --name-only HEAD ${{ needs.trigger-mode.outputs.base-commitid }}`
echo "FILE_PATH: $FILE_PATH"
python ${{ github.workspace }}/.github/utils/pcregrep.py \
--source="${{ github.workspace }}/pcregrep.out" \
--filter="$FILE_PATH"
- name: Spell Check with Typos
if: contains(needs.trigger-mode.outputs.trigger-mode, '[docs]')
uses: crate-ci/typos@v1.13.14
with:
files: docs/
config: .github/utils/typos.toml
cli-doc:
needs: trigger-mode
runs-on: ubuntu-latest
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[cli]') }}
steps:
- uses: actions/checkout@v4
- name: install lib
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: Check cli doc
id: check-cli-doc
run: |
make kbcli-doc
FILE_CHANGES=`git diff --name-only ${{ github.sha }}`
if [[ ! -z "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit -a -m "chore: auto update cli doc changes"
fi
echo file_changes=$FILE_CHANGES >> $GITHUB_OUTPUT
- name: Push cli doc changes
uses: ad-m/github-push-action@master
if: ${{ steps.check-cli-doc.outputs.file_changes }}
with:
github_token: ${{ env.GITHUB_TOKEN }}
branch: ${{ github.ref }}
make-test:
needs: trigger-mode
runs-on: ubuntu-latest
if: contains(needs.trigger-mode.outputs.trigger-mode, '[test]')
steps:
- uses: actions/checkout@v4
- name: install lib
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- name: make module
run: |
make module
- name: make lint
run: |
make lint
- name: make test
run: |
make test
- name: upload coverage report
uses: codecov/codecov-action@v3
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./cover.out
flags: unittests
name: codecov-report
verbose: true
build-kbcli:
needs: trigger-mode
runs-on: ubuntu-latest
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[cli]') }}
strategy:
matrix:
os: [linux-amd64, darwin-arm64]
steps:
- uses: actions/checkout@v4
- name: install lib
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev \
libgpgme-dev
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: make generate
run: make generate
- name: build cli
run: |
CLI_OS_ARCH=`bash .github/utils/utils.sh \
--tag-name ${{ matrix.os }} \
--type 2`
make bin/kbcli.$CLI_OS_ARCH