Skip to content

Commit d259105

Browse files
committed
try to find relevant changes
1 parent 92afb4e commit d259105

File tree

1 file changed

+54
-18
lines changed

1 file changed

+54
-18
lines changed

.github/workflows/generate-go-docs.yaml

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,62 +16,98 @@ 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

2727
- name: Configure git for private repository and install go tools
2828
env:
2929
GOPRIVATE: github.com/smartcontractkit/generate-go-function-docs
3030
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
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
3434
go install github.com/jmank88/[email protected]
35-
go install golang.org/x/tools/gopls@latest
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 'map(select(($filters[] | . == (.folder | split("/")[0]))))' all_folders.json > filtered_folders.json
83+
84+
echo "Full folder List JSON"
85+
cat all_folders.json
86+
87+
echo "Filtered folder List JSON"
88+
cat filtered_folders.json
89+
90+
exit 1
5591
56-
echo "Folder List JSON"
57-
cat folders.json
92+
rm filters.json
93+
rm all_folders.json
5894
59-
- name: Generate go docs for all projects
95+
- name: Generate go docs for changed projects
6096
shell: bash
6197
env:
6298
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
6399
run: |
64100
# Add go binary to PATH
65101
PATH=$PATH:$(go env GOPATH)/bin
66102
export PATH
67-
cat folders.json | jq -c '.[]' | while read -r item; do
103+
cat filtered_folders.json | jq -c '.[]' | while read -r item; do
68104
folder=$(echo "$item" | jq -r '.folder')
69105
echo "Processing folder: $folder"
70106
generate-go-function-docs diff -b ${{ github.event.pull_request.base.sha }} -c ${{ github.event.pull_request.head.sha }} -g chatgpt -f "$folder"
71107
cd "$folder"
72108
cd -
73109
done
74-
rm folders.json
110+
rm filtered_folders.json
75111
76112
- name: Setup GitHub Token for creating a new PR
77113
id: setup-github-token-write

0 commit comments

Comments
 (0)