diff --git a/.github/chatops_commands.md b/.github/chatops_commands.md new file mode 100644 index 0000000000..d9f0408676 --- /dev/null +++ b/.github/chatops_commands.md @@ -0,0 +1,6 @@ +- :ok_woman: `/approve` - approve +- :love_letter: `/changelog` - add changelog comment +- :bento: `/format` - format codes and add licenses +- :white_check_mark: `/gen-test` - generate test codes +- :label: `/label` - add labels +- :rewind: `/rebase` - rebase master diff --git a/.github/workflows/chatops-help.yml b/.github/workflows/chatops-help.yml new file mode 100644 index 0000000000..6ed7e02d49 --- /dev/null +++ b/.github/workflows/chatops-help.yml @@ -0,0 +1,24 @@ +name: "ChatOps help" +on: + pull_request: + types: [opened] +jobs: + print-help: + name: print help + runs-on: ubuntu-latest + steps: + - name: comment to PR + run: | + curl -o chatops_commands.md https://raw.githubusercontent.com/vdaas/vald/master/.github/chatops_commands.md + BODY=`cat chatops_commands.md | sed ':a;N;$!ba;s/\n/\\\\n/g'` + curl --include --verbose --fail \ + -H "Accept: application/json" \ + -H "Content-Type:application/json" \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + --request POST \ + --data "{\"body\": \"**[CHATOPS:HELP]** ChatOps commands.\\n${BODY}\"}" \ + $API_URL + env: + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + API_URL: ${{ github.event.pull_request.comments_url }} + PR_NUM: ${{ github.event.issue.number }} diff --git a/.github/workflows/chatops.yml b/.github/workflows/chatops.yml index c9d24f9b3d..f7b9c87ac2 100644 --- a/.github/workflows/chatops.yml +++ b/.github/workflows/chatops.yml @@ -8,6 +8,7 @@ jobs: label: name: Add labels runs-on: ubuntu-latest + if: steps.check_comments_label.outputs.COMMENTER_USERNAME != 'vdaas-ci' steps: - name: check PR Comments id: check_comments_label @@ -60,6 +61,7 @@ jobs: changelog: name: Add draft comment for a new CHANGELOG entry runs-on: ubuntu-latest + if: steps.check_comments_label.outputs.COMMENTER_USERNAME != 'vdaas-ci' steps: - name: check PR Comments id: check_comments_changelog @@ -102,7 +104,7 @@ jobs: run: | git checkout master PREVIOUS_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) - BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..master | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%" | sed ':a;N;$!ba;s/\n/\\\\n/g'` + BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..master | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%g" | sed ':a;N;$!ba;s/\n/\\\\n/g'` CURRENT="- ${PR_TITLE} ([#${PR_NUM}](https://github.com/vdaas/vald/pull/${PR_NUM}))" curl --include --verbose --fail \ -H "Accept: application/json" \ @@ -119,6 +121,7 @@ jobs: rebase: name: Rebase runs-on: ubuntu-latest + if: steps.check_comments_label.outputs.COMMENTER_USERNAME != 'vdaas-ci' steps: - name: check PR Comments id: check_comments_rebase @@ -192,6 +195,7 @@ jobs: needs: - rebase runs-on: ubuntu-latest + if: steps.check_comments_label.outputs.COMMENTER_USERNAME != 'vdaas-ci' steps: - name: check PR Comments id: check_comments_gen_test @@ -298,6 +302,7 @@ jobs: - rebase - gentest runs-on: ubuntu-latest + if: steps.check_comments_label.outputs.COMMENTER_USERNAME != 'vdaas-ci' steps: - name: check PR Comments id: check_comments_format @@ -428,6 +433,7 @@ jobs: - rebase - format runs-on: ubuntu-latest + if: steps.check_comments_label.outputs.COMMENTER_USERNAME != 'vdaas-ci' steps: - name: check PR Comments id: check_comments_approve diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb716e763e..02b39f809e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,8 +16,8 @@ on: - 'cmd/**' jobs: - coverage: - name: Run tests + test-cmd: + name: Run tests for cmd packages runs-on: ubuntu-latest container: image: vdaas/vald-ci-container:nightly @@ -26,6 +26,32 @@ jobs: uses: actions/checkout@v1 with: fetch-depth: 1 - - name: Run tests + - name: Run tests for cmd packages run: | - make test + make test/cmd + test-internal: + name: Run tests for internal packages + runs-on: ubuntu-latest + container: + image: vdaas/vald-ci-container:nightly + steps: + - name: Check out code. + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Run tests for internal packages + run: | + make test/internal + test-pkg: + name: Run tests for pkg packages + runs-on: ubuntu-latest + container: + image: vdaas/vald-ci-container:nightly + steps: + - name: Check out code. + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Run tests for pkg packages + run: | + make test/pkg diff --git a/Makefile.d/test.mk b/Makefile.d/test.mk index 0719b0ea4b..f20d01753d 100644 --- a/Makefile.d/test.mk +++ b/Makefile.d/test.mk @@ -15,9 +15,34 @@ # .PHONY: test -## run tests +## run tests for cmd, internal, pkg test: - go test -json -cover ./... | tparse -top + go test -json -cover ./cmd/... ./internal/... ./pkg/... | tparse -notests + +.PHONY: test/cmd +## run tests for cmd +test/cmd: + go test -json -cover ./cmd/... | tparse -pass -notests + +.PHONY: test/internal +## run tests for internal +test/internal: + go test -json -cover ./internal/... | tparse -pass -notests + +.PHONY: test/pkg +## run tests for pkg +test/pkg: + go test -json -cover ./pkg/... | tparse -pass -notests + +.PHONY: test/hack +## run tests for hack +test/hack: + go test -json -cover ./hack/... | tparse -pass -notests + +.PHONY: test/all +## run tests for all Go codes +test/all: + go test -json -cover ./... | tparse -notests .PHONY: coverage ## calculate coverages