-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
246c4b5
commit e9b7351
Showing
24 changed files
with
606 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Terraform Basic Checks | ||
triggers: | ||
merge_request: | ||
target-branches: | ||
- master | ||
paths: | ||
- '.aoneci/acctest-terraform-basic.yml' | ||
- 'alicloud/*.go' | ||
jobs: | ||
BreakingChange: | ||
steps: | ||
- name: Setup Go | ||
uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- uses: checkout | ||
inputs: | ||
# Checkout as many commits as needed for the diff | ||
fetch-depth: '2' | ||
- name: Attribute Breaking Change Check | ||
run: | | ||
git diff HEAD^ HEAD > diff.out | ||
go run scripts/compatibility/breaking_change_check.go -fileNames="diff.out" | ||
Consistency: | ||
steps: | ||
- name: Setup Go | ||
uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- uses: checkout | ||
inputs: | ||
# Checkout as many commits as needed for the diff | ||
fetch-depth: '2' | ||
- name: Attribute Consistency Check | ||
run: | | ||
git diff HEAD^ HEAD > diff.out | ||
go run scripts/consistency/consistency_check.go -fileNames="diff.out" | ||
Formatter: | ||
steps: | ||
- name: Setup Go | ||
uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- uses: checkout | ||
inputs: | ||
# Checkout as many commits as needed for the diff | ||
fetch-depth: '2' | ||
- name: Get dependencies | ||
run: | | ||
go install golang.org/x/tools/cmd/goimports@v0.24.0 | ||
go mod tidy | ||
- name: Golang Formatter Check | ||
run: | | ||
if [[ $(git diff --name-only HEAD^ HEAD | grep -c "^alicloud/") -lt 1 ]]; then | ||
echo -e "\033[33m[WARNING]\033[0m there are no go files were changed, skipped." | ||
exit 0 | ||
fi | ||
exitCode=0 | ||
echo "==> Checking that code complies with gofmt and goimports requirements..." | ||
diffFiles=$(git diff --name-only HEAD^ HEAD | grep "^alicloud/") | ||
for fileName in ${diffFiles[@]}; | ||
do | ||
if [[ ! -f ${filename} ]]; then | ||
continue | ||
fi | ||
goimpFile=$(goimports -l ${fileName}) | ||
if [[ -n ${goimpFile} ]]; then | ||
goimports -d ${fileName} | ||
exitCode=1 | ||
fi | ||
gofmtFile=$(gofmt -l ${fileName}) | ||
if [[ -n ${gofmtFile} ]]; then | ||
gofmt -d ${fileName} | ||
exitCode=1 | ||
fi | ||
done | ||
if [[ ${exitCode} -gt 0 ]]; then | ||
echo -e "\n\033[31m[Error]\033[0m==> gofmt or goimports needs running on the above files. You can use the command: \`make fmt\` to reformat code. \033[0m" | ||
exit 1 | ||
fi | ||
echo -e "==> PASS" | ||
Compile: | ||
steps: | ||
- name: Setup Go | ||
uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- uses: checkout | ||
inputs: | ||
# Checkout as many commits as needed for the diff | ||
fetch-depth: '2' | ||
- name: vet | ||
run: | | ||
make vet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: Terraform Integration Checks | ||
triggers: | ||
merge_request: | ||
types: [accepted] | ||
paths: | ||
- 'alicloud/*.go' | ||
|
||
jobs: | ||
IntegrationTest: | ||
steps: | ||
- uses: checkout | ||
- name: Setup Go | ||
uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- uses: checkout | ||
inputs: | ||
# Checkout as many commits as needed for the diff | ||
fetch-depth: '2' | ||
- name: Integration Test Check | ||
run: | | ||
# diffFiles=$(git diff --name-only HEAD^ HEAD | grep "^alicloud/" | grep ".go$" | grep -v "_test.go$") | ||
diffFiles=$(git diff --name-only HEAD^ HEAD) | ||
noNeedRun=true | ||
for fileName in ${diffFiles[@]}; | ||
do | ||
if [[ ${fileName} == "alicloud/resource_alicloud"* || ${fileName} == "alicloud/data_source_alicloud"* ]];then | ||
if [[ ${fileName} != *?_test.go ]]; then | ||
fileName=(${fileName//\.go/_test\.go }) | ||
# echo -e "\033[33m[SKIPPED]\033[0m skipping the file $fileName, continue..." | ||
# continue | ||
fi | ||
echo -e "\n\033[37mchecking diff file $fileName ... \033[0m" | ||
noNeedRun=false | ||
# fileName=(${fileName//\.go/_test\.go }) | ||
if [[ $(grep -c "func TestAcc.*" ${fileName}) -lt 1 ]]; then | ||
echo -e "\033[33m[WARNING]\033[0m missing the acceptance test cases in the file $fileName, continue..." | ||
continue | ||
fi | ||
checkFuncs=$(grep "func TestAcc.*" ${fileName}) | ||
echo -e "found the test funcs:\n${checkFuncs}\n" | ||
funcs=(${checkFuncs//"(t *testing.T) {"/ }) | ||
for func in ${funcs[@]}; | ||
do | ||
if [[ ${func} != "TestAcc"* ]]; then | ||
continue | ||
fi | ||
DiffFuncNames=$DiffFuncNames";"${func} | ||
done | ||
fi | ||
done | ||
if [[ "${noNeedRun}" = "false" && ${DiffFuncNames} == "" ]]; then | ||
echo -e "\n\033[33m[WARNING]\033[0m missing integration test cases, please add them. \033[0m" | ||
exit 1 | ||
fi | ||
if [[ "${noNeedRun}" = "true" ]]; then | ||
echo -e "\n\033[33m[WARNING]\033[0m the pr is no need to run integration test. \033[0m" | ||
exit 0 | ||
fi | ||
IN=$GH_JOB_IntegrationTest_HTML_URL | ||
arrIN=(${IN//actions/ }) | ||
ossObjectPath="github-actions"${arrIN[1]} | ||
go run scripts/integration/receive/integration_check.go ${ossObjectPath} | ||
DocsExampleTest: | ||
needs: IntegrationTest | ||
steps: | ||
- uses: checkout | ||
- name: Setup Go | ||
uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- uses: checkout | ||
inputs: | ||
# Checkout as many commits as needed for the diff | ||
fetch-depth: '2' | ||
- name: Docs Example Test Check | ||
run: | | ||
diffFiles=$(git diff --name-only HEAD^ HEAD) | ||
noNeedRun=true | ||
exampleCount=0 | ||
if [[ ${#diffFiles[@]} -eq 0 ]]; then | ||
echo -e "\033[33m[WARNING]\033[0m the pr ${prNum} does not change provider code and there is no need to check." | ||
exit 0 | ||
fi | ||
for fileName in ${diffFiles[@]}; do | ||
if [[ ${fileName} == *?_test.go ]]; then | ||
echo -e "\033[33m[SKIPPED]\033[0m skipping the file $fileName, continue..." | ||
continue | ||
fi | ||
if [[ ${fileName} == "alicloud/resource_alicloud"* || ${fileName} == "alicloud/data_source_alicloud"* || ${fileName} == "website/docs/r/"* || ${fileName} == "website/docs/d/"* ]]; then | ||
echo ${fileName} | ||
docsPathKey="website/docs/r" | ||
if [[ $fileName =~ "data_source_" || $fileName =~ "website/docs/d/" ]]; then | ||
docsPathKey="website/docs/d" | ||
fi | ||
if [[ ${fileName} == *".go" ]]; then | ||
fileName=(${fileName/_test./.}) | ||
fileName=(${fileName/.go/.html.markdown}) | ||
fileName=(${fileName#*resource_alicloud_}) | ||
fileName=(${fileName#*data_source_alicloud_}) | ||
fi | ||
if [[ ${fileName} == *?.html.markdown ]]; then | ||
fileName=(${fileName#*r/}) | ||
fileName=(${fileName#*d/}) | ||
fi | ||
resourceName=${fileName%%.html.markdown} | ||
docsDir="${docsPathKey}/${resourceName}.html.markdown" | ||
noNeedRun=false | ||
if [[ $(grep -c '```terraform' "${docsDir}") -lt 1 ]]; then | ||
echo -e "\033[33m[WARNING]\033[0m missing docs examples in the ${docsDir}, please adding them. \033[0m" | ||
exit 1 | ||
fi | ||
diffExampleCount=$(grep -c '```terraform' "${docsDir}") | ||
echo -e "found the example count:${diffExampleCount}" | ||
exampleCount=$(( $exampleCount + $diffExampleCount )) | ||
fi | ||
done | ||
if [[ "${noNeedRun}" = "false" && ${exampleCount} == "0" ]]; then | ||
echo -e "\033[31mthe pr ${prNum} missing docs example, please adding them. \033[0m" | ||
exit 1 | ||
fi | ||
if [[ "${noNeedRun}" = "true" ]]; then | ||
echo -e "\n\033[33m[WARNING]\033[0m the pr is no need to run example.\033[0m" | ||
exit 0 | ||
fi | ||
IN=$GH_JOB_DocsExampleTest_HTML_URL | ||
arrIN=(${IN//actions/ }) | ||
ossObjectPath="github-actions"${arrIN[1]} | ||
go run scripts/example/example_check.go ${ossObjectPath} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Golangci-Lint | ||
triggers: | ||
merge_request: | ||
paths: | ||
- '.aoneci/acctest-terraform-lint.yml' | ||
- 'alicloud/*.go' | ||
jobs: | ||
# golangci-lint-review-log: | ||
# name: golangci-lint-with-review-log | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Check out code into the Go module directory | ||
# uses: actions/checkout@v2 | ||
# - name: golangci-lint | ||
# uses: reviewdog/action-golangci-lint@v2 | ||
# with: | ||
# go_version: '1.19.3' | ||
# golangci_lint_flags: '--timeout=25m --disable-all -E gofmt ./alicloud' | ||
# level: info | ||
# reporter: github-pr-check | ||
|
||
|
||
megalinter: | ||
name: MegaLinter | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: checkout | ||
- name: errcheck | ||
uses: megalinter | ||
envs: | ||
ADDITIONAL_EXCLUDED_DIRECTORIES: ['scripts'] | ||
DISABLE_LINTERS: 'GO_REVIVE' | ||
VALIDATE_ALL_CODEBASE: 'false' | ||
GO_GOLANGCI_LINT_CLI_LINT_MODE: 'project' | ||
GO_FILTER_REGEX_EXCLUDE: '.scripts/*' | ||
inputs: | ||
language: GO | ||
compare-to: '${{git.merge_request.targetBranch ?: master}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
name: Documentation Checks | ||
triggers: | ||
push: | ||
branches: | ||
- master | ||
merge_request: | ||
types: | ||
- opened | ||
paths: | ||
- '.github/workflows/document-check.yml' | ||
- '.go-version' | ||
- 'website/docs/**' | ||
|
||
jobs: | ||
# 缺少组件库gaurav-nelson/github-action-markdown-link-check@v1 | ||
# markdown-link: | ||
# steps: | ||
# - uses: checkout | ||
# - uses: gaurav-nelson/github-action-markdown-link-check@v1 | ||
# with: | ||
# use-quiet-mode: 'yes' | ||
# use-verbose-mode: 'yes' | ||
# folder-path: "website/docs" | ||
# file-extension: '.md' | ||
|
||
# 缺少组件库avto-dev/markdown-lint@v1 | ||
# markdown-lint: | ||
# steps: | ||
# - uses: checkout | ||
# - uses: avto-dev/markdown-lint@v1 | ||
|
||
# 缺少组件库reviewdog/action-misspell@v1.11.1 | ||
# misspell: | ||
# steps: | ||
# - name: Check out code. | ||
# uses: checkout | ||
# - name: misspell | ||
# uses: reviewdog/action-misspell@v1.11.1 | ||
# with: | ||
# github_token: ${{secrets.github_token}} | ||
# fail_on_error: true | ||
# filter_mode: file | ||
# locale: "US" | ||
# path: ./website/docs | ||
|
||
terrafmt: | ||
steps: | ||
- uses: checkout | ||
- run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV | ||
- uses: setup-env | ||
inputs: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: terrafmt | ||
run: | | ||
export PATH=$PATH:$(go env GOPATH)/bin | ||
go install github.com/katbyte/terrafmt@latest | ||
terrafmt diff ./website --check --pattern '*.markdown' | ||
basic-check: | ||
steps: | ||
- uses: checkout | ||
inputs: | ||
fetch-depth: '3' | ||
- uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- run: bash scripts/basic-check.sh | ||
|
||
# 缺少组件库jitterbit/get-changed-files@v1 | ||
# Content: | ||
# steps: | ||
# - uses: checkout | ||
# - name: Setup Go | ||
# uses: setup-env | ||
# inputs: | ||
# go-version: '1.22.0' | ||
# - uses: jitterbit/get-changed-files@v1 | ||
# id: files | ||
# with: | ||
# format: 'json' | ||
# - name: Checking the docs content | ||
# run: | | ||
# readarray -t changed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')" | ||
# for changed_file in ${changed_files[@]}; do | ||
# if [[ ${changed_file} == "website/docs/"* ]]; then | ||
# go run scripts/document/document_check.go ${changed_file} | ||
# fi | ||
# done | ||
|
||
Consistency: | ||
# needs: Content | ||
steps: | ||
- uses: checkout | ||
- name: Setup Go | ||
uses: setup-env | ||
inputs: | ||
go-version: '1.22.0' | ||
- uses: checkout | ||
inputs: | ||
fetch-depth: '2' | ||
- name: Integration Test Check | ||
run: | | ||
git diff HEAD^ HEAD > diff.out | ||
go run scripts/consistency/consistency_check.go -fileNames="diff.out" | ||
# terraform-validate: | ||
# steps: | ||
# - uses: checkout | ||
# - name: import | ||
# run: | | ||
# echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV | ||
# - uses: setup-env | ||
# with: | ||
# go-version: ${{ env.GO_VERSION }} | ||
# - name: terraform-validate | ||
# run: | | ||
# export PATH=$PATH:$(go env GOPATH)/bin | ||
# go get -t github.com/katbyte/terrafmt | ||
# URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }}/files" | ||
# FILES=$(curl -s -X GET -G $URL | jq -r '.[] | .filename') | ||
# echo ${FILES} | ||
# ./scripts/terraform-validate.sh "${FILES[@]}" | ||
# if [[ "$?" == "1" ]]; then | ||
# echo "Please Check the Terraform Grammer" && exit 1 | ||
# fi | ||
|
||
|
Oops, something went wrong.