|
1 | | -#!/bin/bash |
| 1 | +# This is a basic workflow to help you get started with Actions |
2 | 2 |
|
3 | | -range_sha=${BASE_SHA} |
4 | | -echo $(git diff --name-status ${range_sha} | awk '{print $2}') |
5 | | -#service files |
6 | | -update_service_functions="" |
7 | | -service_files=`git diff --name-status ${range_sha} | awk '{print $2}' | grep "^tencentcloud/service*"` |
8 | | -if [ $service_files ] ; then |
9 | | - update_service_functions=`echo $service_files | xargs git diff ${range_sha} | grep "@@" | grep "func" | awk -F ")" '{print $2}' | awk -F "(" '{print $1}' | tr -d ' '` |
10 | | -fi |
11 | | -echo "update_service_functions: $update_service_functions" |
12 | | -need_test_files="" |
13 | | -for update_service_function in $update_service_functions; do |
14 | | - tmp_files=`grep -r --with-filename $update_service_function ./tencentcloud | awk -F ":" '{print $1}' | grep -v "service_tencent*" | awk -F "/" '{print $3}' | sort | uniq | egrep "^resource_tc_|^data_source_tc" | awk -F "." '{print $1}' | awk '/_test$/{print "tencentcloud/"$0".go"} !/_test$/{print "tencentcloud/"$0"_test.go"}'` |
15 | | - need_test_files="$need_test_files $tmp_files" |
16 | | -done |
17 | | -echo "need_test_files: $need_test_files" |
| 3 | +name: MR_CHECK |
18 | 4 |
|
19 | | -# resource&&data_source files |
20 | | -update_sources=`git diff --name-status ${range_sha}| awk '{print $2}' | egrep "^tencentcloud/resource_tc|^tencentcloud/data_source" | egrep -v "_test.go" | awk -F "." '{print $1"_test.go"}'` |
21 | | -echo "update_sources: $update_sources" |
22 | | -# test files |
23 | | -delta_test_files=`git diff --name-status ${range_sha} | egrep "_test\.go$" | awk '{print $2}'` |
24 | | -echo "delta_test_files: $delta_test_files" |
25 | | -# all test files |
26 | | -delta_test_files="$delta_test_files $need_test_files $update_sources" |
27 | | -delta_test_files=`echo $delta_test_files | xargs -n1 | sort | uniq` |
28 | | -echo "all delta_test_files: $delta_test_files" |
29 | | -for delta_test_file in ${delta_test_files}; do |
30 | | - test_casts=`egrep "func TestAcc.+\(" ${delta_test_file} | awk -F "(" '{print $1}' | awk '{print $2}' | grep -v "NeedFix"` |
31 | | - echo "[$delta_test_file] \n$test_casts" |
32 | | - for test_cast in ${test_casts}; do |
33 | | - go_test_cmd="go test -v -run ${test_cast} -timeout=0 ./tencentcloud/" |
34 | | - $go_test_cmd |
35 | | - if [ $? -ne 0 ]; then |
36 | | - printf "[GO TEST FILED] ${go_test_cmd}" |
37 | | - exit 1 |
38 | | - fi |
39 | | - done |
40 | | -done |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + pull_request_target: |
| 8 | + types: [labeled] |
| 9 | + |
| 10 | + # Allows you to run this workflow manually from the Actions tab |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 14 | +jobs: |
| 15 | + # This workflow contains a single job called "build" |
| 16 | + build: |
| 17 | + # The type of runner that the job will run on |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 21 | + steps: |
| 22 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + ref: ${{ github.event.pull_request.head.sha }} |
| 27 | + |
| 28 | + # Runs a set of commands using the runners shell |
| 29 | + - name: MR INFO |
| 30 | + run: | |
| 31 | + export BASE_SHA=${{ github.event.pull_request.base.sha }} |
| 32 | + export HEAD_SHA=${{ github.event.pull_request.head.sha }} |
| 33 | + export TF_ACC=true |
| 34 | + export TENCENTCLOUD_REGION=ap-guangzhou |
| 35 | + export TENCENTCLOUD_SECRET_KEY=${{ secrets.TENCENTCLOUD_SECRET_KEY }} |
| 36 | + export TENCENTCLOUD_SECRET_ID=${{ secrets.TENCENTCLOUD_SECRET_ID }} |
| 37 | + export TENCENTCLOUD_APPID=${{ secrets.TENCENTCLOUD_APPID }} |
| 38 | + export TENCENTCLOUD_OWNER_UIN=${{ secrets.TENCENTCLOUD_OWNER_UIN }} |
| 39 | + export TENCENTCLOUD_SECRET_ID_INTERNATION=${{ secrets.TENCENTCLOUD_SECRET_ID_INTERNATION }} |
| 40 | + export TENCENTCLOUD_SECRET_KEY_INTERNATION=${{ secrets.TENCENTCLOUD_SECRET_KEY_INTERNATION }} |
| 41 | + export TENCENTCLOUD_SECRET_ID_PREPAY=${{ secrets.TENCENTCLOUD_SECRET_ID_PREPAY }} |
| 42 | + export TENCENTCLOUD_SECRET_KEY_PREPAY=${{ secrets.TENCENTCLOUD_SECRET_KEY_PREPAY }} |
| 43 | + export TENCENTCLOUD_SECRET_ID_PRIVATE=${{ secrets.TENCENTCLOUD_SECRET_ID_PRIVATE }} |
| 44 | + export TENCENTCLOUD_SECRET_KEY_PRIVATE=${{ secrets.TENCENTCLOUD_SECRET_KEY_PRIVATE }} |
| 45 | + export TENCENTCLOUD_SECRET_KEY_COMMON=${{ secrets.TENCENTCLOUD_SECRET_KEY }} |
| 46 | + export TENCENTCLOUD_SECRET_ID_COMMON=${{ secrets.TENCENTCLOUD_SECRET_ID }} |
| 47 | + export TENCENTCLOUD_SECRET_KEY_SUB_ACCOUNT=${{ secrets.TENCENTCLOUD_SECRET_KEY_SUB_ACCOUNT }} |
| 48 | + export TENCENTCLOUD_SECRET_ID_SUB_ACCOUNT=${{ secrets.TENCENTCLOUD_SECRET_ID_SUB_ACCOUNT }} |
| 49 | + sh .githooks/pre-commit |
0 commit comments