Skip to content

Commit aab3151

Browse files
Tejas Ganesh Naikrlhagerm
authored andcommitted
fixed linting yaml errors and adding rust prem-ex
1 parent 67b302c commit aab3151

File tree

2 files changed

+100
-89
lines changed

2 files changed

+100
-89
lines changed

.github/workflows/sync-S3-KB.yml

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: syncS3andKB
22
on:
33
push:
4-
branches: [ "sync-S3-KB" ] # Once merged, update branch name to main.
4+
branches: ["sync-S3-KB"] # Once merged, update branch name to main.
55
workflow_dispatch:
66
inputs:
77
sdk_name:
@@ -10,17 +10,17 @@ on:
1010
default: 'python'
1111
type: choice
1212
options:
13-
- javascriptv3
14-
- dotnetv4
15-
- javav2
16-
- rustv1
17-
- gov2
18-
- swift
19-
- python
20-
- ruby
21-
- php
22-
- cpp
23-
- kotlin
13+
- javascriptv3
14+
- dotnetv4
15+
- javav2
16+
- rustv1
17+
- gov2
18+
- swift
19+
- python
20+
- ruby
21+
- php
22+
- cpp
23+
- kotlin
2424

2525
permissions:
2626
id-token: write
@@ -32,89 +32,89 @@ jobs:
3232
sdk_name: ${{ github.event.inputs.sdk_name || 'cpp' }}
3333

3434
steps:
35-
- name: Checkout
36-
uses: actions/checkout@v4
35+
- name: Checkout
36+
uses: actions/checkout@v4
3737

38-
- name: Configure AWS Credentials
39-
uses: aws-actions/configure-aws-credentials@main # Or a specific version
40-
with:
41-
role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_Role #once merged, update trust policy of the role to point to main
42-
aws-region: us-west-2
38+
- name: Configure AWS Credentials
39+
uses: aws-actions/configure-aws-credentials@main # Or a specific version
40+
with:
41+
role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_Role # once merged, update trust policy of the role to point to main branch
42+
aws-region: us-west-2
4343

44-
- name: Set SDK and language mapping for S3
45-
run: |
46-
if [ "$sdk_name" == "javascriptv3" ]; then
47-
echo "S3_LANGUAGE=javascript" >> $GITHUB_ENV
48-
elif [ "$sdk_name" == "dotnetv4" ]; then
49-
echo "S3_LANGUAGE=dotnet" >> $GITHUB_ENV
50-
elif [ "$sdk_name" == "javav2" ]; then
51-
echo "S3_LANGUAGE=java" >> $GITHUB_ENV
52-
elif [ "$sdk_name" == "rustv1" ]; then
53-
echo "S3_LANGUAGE=rust" >> $GITHUB_ENV
54-
elif [ "$sdk_name" == "gov2" ]; then
55-
echo "S3_LANGUAGE=go" >> $GITHUB_ENV
56-
else
57-
echo "S3_LANGUAGE=$sdk_name" >> $GITHUB_ENV
58-
fi
59-
60-
- name: Extract and copy premium examples in temp. dir.
61-
run: |
62-
MARKDOWN_FILE="./$sdk_name/premium-ex.md"
63-
64-
if [ ! -f "$MARKDOWN_FILE" ]; then
65-
echo "Premium examples file not found: $MARKDOWN_FILE"
66-
exit 1
67-
fi
44+
- name: Set SDK and language mapping for S3
45+
run: |
46+
if [ "$sdk_name" == "javascriptv3" ]; then
47+
echo "S3_LANGUAGE=javascript" >> $GITHUB_ENV
48+
elif [ "$sdk_name" == "dotnetv4" ]; then
49+
echo "S3_LANGUAGE=dotnet" >> $GITHUB_ENV
50+
elif [ "$sdk_name" == "javav2" ]; then
51+
echo "S3_LANGUAGE=java" >> $GITHUB_ENV
52+
elif [ "$sdk_name" == "rustv1" ]; then
53+
echo "S3_LANGUAGE=rust" >> $GITHUB_ENV
54+
elif [ "$sdk_name" == "gov2" ]; then
55+
echo "S3_LANGUAGE=go" >> $GITHUB_ENV
56+
else
57+
echo "S3_LANGUAGE=$sdk_name" >> $GITHUB_ENV
58+
fi
6859
69-
extract_paths() {
70-
local level="$1"
71-
local section_found=false
60+
- name: Extract and copy premium examples in temp. dir.
61+
run: |
62+
MARKDOWN_FILE="./$sdk_name/premium-ex.md"
7263
73-
while IFS= read -r line; do
74-
if [[ "$line" =~ ^##[[:space:]]*${level}:[[:space:]]*$ ]]; then
75-
section_found=true
76-
continue
77-
elif [[ "$line" =~ ^##[[:space:]] ]] && [ "$section_found" = true ]; then
78-
break
79-
elif [ "$section_found" = true ] && [[ "$line" =~ ^/ ]]; then
80-
echo "$line"
81-
fi
82-
done < "$MARKDOWN_FILE"
83-
}
84-
85-
for level in "basics" "feature-scenario" "complex-feature-scenario"; do
86-
paths=$(extract_paths "$level")
64+
if [ ! -f "$MARKDOWN_FILE" ]; then
65+
echo "Premium examples file not found: $MARKDOWN_FILE"
66+
exit 1
67+
fi
68+
69+
extract_paths() {
70+
local level="$1"
71+
local section_found=false
72+
73+
while IFS= read -r line; do
74+
if [[ "$line" =~ ^##[[:space:]]*${level}:[[:space:]]*$ ]]; then
75+
section_found=true
76+
continue
77+
elif [[ "$line" =~ ^##[[:space:]] ]] && [ "$section_found" = true ]; then
78+
break
79+
elif [ "$section_found" = true ] && [[ "$line" =~ ^/ ]]; then
80+
echo "$line"
81+
fi
82+
done < "$MARKDOWN_FILE"
83+
}
8784
88-
if [ -n "$paths" ]; then
89-
mkdir -p "./extracted_snippets/$level"
85+
for level in "basics" "feature-scenario" "complex-feature-scenario"; do
86+
paths=$(extract_paths "$level")
9087
91-
while IFS= read -r path; do
92-
if [ -n "$path" ]; then
93-
source_path="./$sdk_name$path"
94-
if [ -e "$source_path" ]; then
95-
cp -r "$source_path" "./extracted_snippets/$level/"
88+
if [ -n "$paths" ]; then
89+
mkdir -p "./extracted_snippets/$level"
90+
91+
while IFS= read -r path; do
92+
if [ -n "$path" ]; then
93+
source_path="./$sdk_name$path"
94+
if [ -e "$source_path" ]; then
95+
cp -r "$source_path" "./extracted_snippets/$level/"
96+
fi
9697
fi
97-
fi
98-
done <<< "$paths"
99-
fi
100-
done
98+
done <<< "$paths"
99+
fi
100+
done
101101
102-
- name: Upload/Sync to S3
103-
run: |
104-
for level in "basics" "feature-scenario" "complex-feature-scenario"; do
105-
if [ -d "./extracted_snippets/$level" ]; then
106-
aws s3 sync "./extracted_snippets/$level/" "s3://$S3_LANGUAGE-premium-bucket/$level/" --delete
107-
echo "Uploaded $level examples to S3"
108-
fi
109-
done
102+
- name: Upload/Sync to S3
103+
run: |
104+
for level in "basics" "feature-scenario" "complex-feature-scenario"; do
105+
if [ -d "./extracted_snippets/$level" ]; then
106+
aws s3 sync "./extracted_snippets/$level/" "s3://$S3_LANGUAGE-premium-bucket/$level/" --delete
107+
echo "Uploaded $level examples to S3"
108+
fi
109+
done
110110
111-
- name: Sync Knowledge Base Data Source
112-
run: |
113-
aws lambda invoke \
114-
--function-name KB_Updater \
115-
--payload "{\"language\":\"$S3_LANGUAGE\",\"region\":\"us-west-2\"}" \
116-
--cli-binary-format raw-in-base64-out \
117-
response.json
118-
119-
echo "Knowledge Base sync initiated"
120-
cat response.json
111+
- name: Sync Knowledge Base Data Source
112+
run: |
113+
aws lambda invoke \
114+
--function-name KB_Updater \
115+
--payload "{\"language\":\"$S3_LANGUAGE\",\"region\":\"us-west-2\"}" \
116+
--cli-binary-format raw-in-base64-out \
117+
response.json
118+
119+
echo "Knowledge Base sync initiated"
120+
cat response.json

ruby/premium-ex.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//Add paths for premium examples here which will be consumed by workflow to update KB with quality code
2+
//Don't forget to add new line at the end of this file
3+
4+
## basics:
5+
/example_code/s3/scenario_getting_started.rb
6+
7+
## feature-scenario:
8+
9+
10+
## complex-feature-scenario:
11+

0 commit comments

Comments
 (0)