Skip to content

Commit 1a28620

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

File tree

1 file changed

+61
-23
lines changed

1 file changed

+61
-23
lines changed

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

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,62 +16,100 @@ 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
4564
run: |
4665
PATH=$PATH:$(go env GOPATH)/bin
47-
export PATH
66+
export PATH
67+
4868
gomods_output=$(gomods 2>&1)
4969
5070
# Extract the parent directories of go.mod files
5171
parent_folders=$(echo "$gomods_output" | grep 'go\.mod$' | sed 's/\/go\.mod//' | sed 's/^[ \t]*//;s/[ \t]*$//' | xargs -n 1)
5272
5373
# Convert parent directories into a JSON matrix
54-
echo "$parent_folders" | jq -R -s 'split("\n") | map(select(length > 0)) | map({folder: .})' > folders.json
74+
echo "$parent_folders" | jq -R -s 'split("\n") | map(select(length > 0)) | map({folder: .})' > all_folders.json
75+
76+
echo "${{ steps.changes.outputs.changes }}" > filters.json
77+
78+
cat filters.json
79+
80+
jq --slurpfile filters filters.json '
81+
map(select(
82+
($filters[] | . == (.folder | split("/")[0]))
83+
))
84+
' all_folders.json > filtered_folders.json
85+
86+
echo "Full folder List JSON"
87+
cat all_folders.json
88+
89+
echo "Filtered folder List JSON"
90+
cat filtered_folders.json
91+
92+
exit 1
5593
56-
echo "Folder List JSON"
57-
cat folders.json
94+
rm filters.json
95+
rm all_folders.json
5896
59-
- name: Generate go docs for all projects
97+
- name: Generate go docs for changed projects
6098
shell: bash
6199
env:
62100
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
63101
run: |
64102
# Add go binary to PATH
65103
PATH=$PATH:$(go env GOPATH)/bin
66104
export PATH
67-
cat folders.json | jq -c '.[]' | while read -r item; do
105+
cat filtered_folders.json | jq -c '.[]' | while read -r item; do
68106
folder=$(echo "$item" | jq -r '.folder')
69107
echo "Processing folder: $folder"
70108
generate-go-function-docs diff -b ${{ github.event.pull_request.base.sha }} -c ${{ github.event.pull_request.head.sha }} -g chatgpt -f "$folder"
71109
cd "$folder"
72110
cd -
73111
done
74-
rm folders.json
112+
rm filtered_folders.json
75113
76114
- name: Setup GitHub Token for creating a new PR
77115
id: setup-github-token-write

0 commit comments

Comments
 (0)