Skip to content

Commit

Permalink
chore: setup actions
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWhiteWu committed Apr 6, 2021
1 parent 9de30db commit 274d0ce
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pull Request Check

on: pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Check Branch
run: ./check_branch_name.sh ${{ github.head_ref }}

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Benchmark
run: go test -bench=. -benchmem -run=none ./...
34 changes: 34 additions & 0 deletions .github/workflows/push-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Push Check

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Check License Header
uses: apache/skywalking-eyes@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint
run: |
test -z "$(gofmt -s -l .)"
go vet -stdmethods=false $(go list ./...)
- name: Unit Test
run: go test -v -race -covermode=atomic -coverprofile=coverage.out ./...
25 changes: 25 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release Check

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Check Source Branch
run: python2 -c "exit(0 if '${{ github.head_ref }}'.startswith('release') or '${{ github.head_ref }}'.startswith('hotfix') else 1)"

- name: Check Version
run: |
# get version code, runner not support grep -E here
SOURCE_VERSION=`grep 'Version\s*=\s*\"v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\"' *.go | awk -F '\"' '{print $(NF-1)}'`
git checkout main
MASTER_VERSION=`grep 'Version\s*=\s*\"v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\"' *.go | awk -F '\"' '{print $(NF-1)}'`
git checkout ${{Head.SHA}}
# check version update
python2 -c "exit(0 if list(map(int,'${SOURCE_VERSION#v}'.split('.')[:3])) > list(map(int,'${MASTER_VERSION#v}'.split('.')[:3])) else 1)"
10 changes: 10 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
header:
license:
spdx-id: Apache-2.0
copyright-owner: ByteDance Inc.

paths:
- '**/*.go'
- '**/*.s'

comment: on-failure
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# How to Contribute
Empty file added CREDITS
Empty file.
10 changes: 10 additions & 0 deletions check_branch_name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

current=$(git status | head -n1 | sed 's/On branch //')
name=${1:-$current}
if [[ ! $name =~ ^(((opt(imize)?|feat(ure)?|(bug|hot)?fix|test|refact(or)?|ci)/.+)|(main|develop)|(release-v[0-9]+\.[0-9]+)|(release/v[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]+(\+[a-z0-9.]+)?)?)|revert-[a-z0-9]+)$ ]]; then
echo "branch name '$name' is invalid"
exit 1
else
echo "branch name '$name' is valid"
fi

0 comments on commit 274d0ce

Please sign in to comment.