@@ -16,62 +16,102 @@ jobs:
1616 contents : read
1717
1818 steps :
19- - name : Setup GitHub Token for reading Generate Go Doc Repo
20- id : setup-github-token-read
21- uses :
smartcontractkit/.github/actions/setup-github-token@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # [email protected] 22- with :
23- aws-role-arn : ${{ secrets.AWS_ROLE_ARN_READ_GENERATE_GO_DOC_REPO }}
24- aws-lambda-url : ${{ secrets.GATI_LAMBDA_TT_URL }}
25- aws-region : ${{ secrets.AWS_REGION }}
19+ # - name: Setup GitHub Token for reading Generate Go Doc Repo
20+ # id: setup-github-token-read
21+ # uses: smartcontractkit/.github/actions/setup-github-token@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # [email protected] 22+ # with:
23+ # aws-role-arn: ${{ secrets.AWS_ROLE_ARN_READ_GENERATE_GO_DOC_REPO }}
24+ # aws-lambda-url: ${{ secrets.GATI_LAMBDA_TT_URL }}
25+ # aws-region: ${{ secrets.AWS_REGION }}
2626
27- - name : Configure git for private repository and install go tools
28- env :
29- GOPRIVATE : github.com/smartcontractkit/generate-go-function-docs
30- run : |
31- git config --global \
32- url."https://x-access-token:${{ steps.setup-github-token-read.outputs.access-token }}@github.com/".insteadOf "https://github.com/"
33- go install github.com/smartcontractkit/generate-go-function-docs@latest
34- go install github.com/jmank88/[email protected] 35- go install golang.org/x/tools/gopls@latest
27+ # - name: Configure git for private repository and install go tools
28+ # env:
29+ # GOPRIVATE: github.com/smartcontractkit/generate-go-function-docs
30+ # run: |
31+ # git config --global \
32+ # url."https://x-access-token:${{ steps.setup-github-token-read.outputs.access-token }}@github.com/".insteadOf "https://github.com/"
33+ # go install github.com/smartcontractkit/generate-go-function-docs@latest
34+ # go install github.com/jmank88/[email protected] 35+ # go install golang.org/x/tools/gopls@latest
3636
3737 - name : Checkout current branch
3838 uses : actions/checkout@v3
3939 with :
4040 fetch-depth : 0
4141
42+ - name : Detect changes
43+ uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
44+ id : changes
45+ with :
46+ filters : |
47+ seth:
48+ - 'seth/**/*.go'
49+ wasp:
50+ - 'wasp/**/*.go'
51+ havoc:
52+ - 'havoc/**/*.go'
53+ lib:
54+ - 'lib/**/*.go'
55+ k8s-test-runner:
56+ - 'k8s-test-runner/**/*.go'
57+ framework:
58+ - 'framework/**/*.go'
59+ # later add tools here or make this filter dynamic (if possible)
60+
4261 - name : Find all go modules
4362 shell : bash
4463 id : go-modules
64+ env :
65+ FILTERS : ${{ steps.changes.outputs.changes }}
4566 run : |
4667 PATH=$PATH:$(go env GOPATH)/bin
47- export PATH
68+ export PATH
69+
4870 gomods_output=$(gomods 2>&1)
4971
5072 # Extract the parent directories of go.mod files
5173 parent_folders=$(echo "$gomods_output" | grep 'go\.mod$' | sed 's/\/go\.mod//' | sed 's/^[ \t]*//;s/[ \t]*$//' | xargs -n 1)
5274
5375 # Convert parent directories into a JSON matrix
54- echo "$parent_folders" | jq -R -s 'split("\n") | map(select(length > 0)) | map({folder: .})' > folders.json
76+ echo "$parent_folders" | jq -R -s 'split("\n") | map(select(length > 0)) | map({folder: .})' > all_folders.json
77+
78+ echo "$FILTERS" > filters.json
79+
80+ cat filters.json
81+
82+ jq --slurpfile filters filters.json '
83+ map(select(
84+ ($filters[] | . == (.folder | split("/")[0]))
85+ ))
86+ ' all_folders.json > filtered_folders.json
87+
88+ echo "Full folder List JSON"
89+ cat all_folders.json
90+
91+ echo "Filtered folder List JSON"
92+ cat filtered_folders.json
93+
94+ exit 1
5595
56- echo "Folder List JSON"
57- cat folders .json
96+ rm filters.json
97+ rm all_folders .json
5898
59- - name : Generate go docs for all projects
99+ - name : Generate go docs for changed projects
60100 shell : bash
61101 env :
62102 OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
63103 run : |
64104 # Add go binary to PATH
65105 PATH=$PATH:$(go env GOPATH)/bin
66106 export PATH
67- cat folders .json | jq -c '.[]' | while read -r item; do
107+ cat filtered_folders .json | jq -c '.[]' | while read -r item; do
68108 folder=$(echo "$item" | jq -r '.folder')
69109 echo "Processing folder: $folder"
70110 generate-go-function-docs diff -b ${{ github.event.pull_request.base.sha }} -c ${{ github.event.pull_request.head.sha }} -g chatgpt -f "$folder"
71111 cd "$folder"
72112 cd -
73113 done
74- rm folders .json
114+ rm filtered_folders .json
75115
76116 - name : Setup GitHub Token for creating a new PR
77117 id : setup-github-token-write
0 commit comments