Skip to content

Commit 586ce30

Browse files
misc: merge from main
2 parents 7a07412 + 330d095 commit 586ce30

File tree

10 files changed

+242
-15
lines changed

10 files changed

+242
-15
lines changed

.github/actions/configure-gradle/action.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,21 @@ runs:
1212
shell: bash
1313
run: |
1414
cd ${{ inputs.working-directory }}
15-
gradleVersion=$(grep "distributionUrl" ./gradle/wrapper/gradle-wrapper.properties | sed -n 's|.*gradle-\([0-9.]*\)-bin.zip|\1|p')
16-
echo Configuring custom Gradle distribution URL with version: $gradleVersion
17-
echo gradle wrapper --gradle-distribution-url https://d2pjps8lqszrgq.cloudfront.net/gradle-$gradleVersion-bin.zip
18-
gradle wrapper --gradle-distribution-url https://d2pjps8lqszrgq.cloudfront.net/gradle-$gradleVersion-bin.zip
15+
16+
GRADLE_VERSION=$(grep "distributionUrl" ./gradle/wrapper/gradle-wrapper.properties | sed -n 's|.*gradle-\([0-9.]*\)-bin.zip|\1|p')
17+
CUSTOM_URL="https://d2pjps8lqszrgq.cloudfront.net/gradle-$GRADLE_VERSION-bin.zip"
18+
19+
echo Configuring custom Gradle distribution URL with version: $GRADLE_VERSION
20+
echo Setting distribution URL to: $CUSTOM_URL
21+
22+
# Detect OS and set appropriate sed option
23+
if sed --version 2>/dev/null | grep -q "GNU sed"; then
24+
SED_CMD="sed -i" # GNU sed (Linux)
25+
else
26+
SED_CMD="sed -i ''" # BSD sed (macOS)
27+
fi
28+
29+
# Replace the line containing "distributionUrl" with the new distributionUrl
30+
$SED_CMD "/distributionUrl/c\\
31+
distributionUrl=$CUSTOM_URL\\
32+
" ./gradle/wrapper/gradle-wrapper.properties
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Emit Metrics
2+
description: Emit metrics using the kat tool
3+
inputs:
4+
namespace:
5+
description: The CloudWatch namespace in which to emit metrics
6+
required: true
7+
dimensions:
8+
description: |-
9+
The dimensions to include with emitted metrics, as a collection of `name=value` pairs. Multiple dimensions are
10+
delimited by newlines (`\n`) and whitespace is trimmed from before/after each `name=value` pair. When passing
11+
multiple dimensions, make sure to use YAML's block literal syntax (`|` or `|-`).
12+
13+
For example:
14+
```
15+
dimensions: |
16+
Artifact=foo-artifact
17+
Platform=Kotlin/JVM
18+
Variant=External
19+
```
20+
required: true
21+
metrics:
22+
description: |-
23+
The metrics to emit into the given namespace and using the specified dimensions. Individual metrics are written in
24+
the form of `<name>:<value>[:<unit>]` where:
25+
* <name> is the metric name and may include spaces but not colons (`:`)
26+
* <value> is the numeric value of the metric
27+
* <unit> is the CloudWatch unit name (if omitted, `None` is assumed)
28+
29+
Multiple metrics are delimited by newlines (`\n`) and whitespace is trimmed from before/after each metric
30+
specification. When passing multiple metrics, make sure to use YAML's block literal syntax (`|` or `|-`).
31+
32+
For example:
33+
```
34+
metrics: |
35+
BuildTime:4.532:Seconds
36+
BuildSucceeded:1:Count
37+
```
38+
required: true
39+
40+
runs:
41+
using: composite
42+
steps:
43+
- name: Verify kat exists
44+
shell: bash
45+
run: kat version || ( echo "Cannot find kat in PATH ($PATH). Did you forget to run setup-kat first?" && exit 1 )
46+
- name: Emit Metrics
47+
shell: bash
48+
run: |
49+
# Trim a string and echo the result
50+
trim() {
51+
# args:
52+
# $1 the string to trim
53+
54+
echo -n "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
55+
}
56+
57+
# Convert a newline-delimited string into a single-line string delimited by spaces with each element prefixed
58+
format() {
59+
# args:
60+
# $1 the prefix for each element
61+
# $2 the newline-delimited string
62+
63+
PROCESSED=""
64+
IFS=$'\n'; ARR=($2); unset IFS
65+
for ITEM in "${ARR[@]}"; do
66+
PROCESSED="$PROCESSED $1 \"$(trim "$ITEM")\""
67+
done
68+
echo -n "$(trim "$PROCESSED")"
69+
}
70+
71+
NAMESPACE="--namespace \"${{ inputs.namespace }}\""
72+
DIMENSIONS="$(format "--dimension" "${{ inputs.dimensions }}")"
73+
METRICS="$(format "--metric" "${{ inputs.metrics }}")"
74+
CMD="kat metrics emit $NAMESPACE $DIMENSIONS $METRICS"
75+
76+
echo "Executing command \"$CMD\""
77+
eval "$CMD"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Merge Main
2+
description: Merges main into feature branches (*-main)
3+
inputs:
4+
exempt-branches:
5+
description: Feature branches that are exempt from receiving merges from main (comma separated, no blank space)
6+
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
13+
- name: Set up Git
14+
shell: bash
15+
run: |
16+
git config user.name aws-sdk-kotlin-ci
17+
git config user.email "[email protected]"
18+
19+
- name: Run Script
20+
shell: bash
21+
run: |
22+
.github/scripts/merge-main.sh ${{ inputs.exempt-branches }}

.github/actions/setup-kat/action.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ runs:
1818
echo "No versions of kat were found"
1919
exit 1
2020
fi
21-
echo "Downloading kat version $kat_version"
22-
23-
aws s3 cp s3://kotlin-sdk-build-tools/kat-releases/$kat_version/kat-$kat_version.zip ./kat.zip
21+
22+
kat_dir="$HOME/kat"
23+
24+
echo "Creating directory for kat tool at $kat_dir"
25+
mkdir -p "$kat_dir"
26+
cd "$kat_dir"
27+
28+
echo "Downloading kat version $kat_version to $kat_dir"
29+
aws s3 cp s3://kotlin-sdk-build-tools/kat-releases/$kat_version/kat-$kat_version.zip ./kat.zip --no-progress
2430
2531
echo "Unzipping kat tool"
26-
unzip -qq ./kat.zip -d kat
32+
unzip -qq ./kat.zip
2733
28-
kat_binary_path="$PWD/kat/kat-$kat_version/bin"
34+
kat_binary_path="$kat_dir/kat-$kat_version/bin"
35+
echo "Appending \"$kat_binary_path\" to path"
2936
export PATH="$kat_binary_path:$PATH"
3037
echo "$kat_binary_path" >> $GITHUB_PATH
3138
32-
echo "Installed kat version $(kat version)" || (echo "Failed to execute kat command" && exit 1)
39+
echo "Installed kat version $(kat version)" || (echo "Failed to execute kat command" && exit 1)

.github/scripts/merge-main.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
input=$1
4+
5+
function fetch_latest_changes() {
6+
echo "Fetching the latest remote branches"
7+
git fetch --all
8+
}
9+
10+
fetch_latest_changes
11+
12+
function find_feature_branches() {
13+
echo "Searching for feature branches"
14+
feature_branches=($(git branch -r --list "*-main" | sed 's|origin/||'))
15+
16+
if [ ${#feature_branches[@]} -eq 0 ]; then
17+
echo "...none found"
18+
return
19+
fi
20+
21+
for feature_branch in "${feature_branches[@]}"; do
22+
echo "...found feature branch: $feature_branch"
23+
done
24+
}
25+
26+
find_feature_branches
27+
28+
function find_exempt_branches() {
29+
echo "Searching for exempt branches"
30+
IFS=',' read -r -a exempt_branches <<< "$input"
31+
32+
if [ ${#exempt_branches[@]} -eq 0 ]; then
33+
echo "...none found"
34+
return
35+
fi
36+
37+
for exempt_branch in "${exempt_branches[@]}"; do
38+
echo "...found exempt branch: $exempt_branch"
39+
done
40+
}
41+
42+
find_exempt_branches
43+
44+
function filter_feature_branches() {
45+
echo "Filtering branches"
46+
branches=()
47+
48+
for feature_branch in "${feature_branches[@]}"; do
49+
if ! [[ "${exempt_branches[*]}" =~ "$feature_branch" ]]; then
50+
echo "...including feature branch: $feature_branch"
51+
branches+=("$feature_branch")
52+
else
53+
echo "...excluding feature branch: $feature_branch"
54+
fi
55+
done
56+
}
57+
58+
filter_feature_branches
59+
60+
function merge_main() {
61+
echo "Merging main into branches"
62+
63+
if [ ${#branches[@]} -eq 0 ]; then
64+
echo "...no branches to merge into"
65+
return
66+
fi
67+
68+
for branch in "${branches[@]}"; do
69+
echo "...switching to branch: $branch"
70+
git switch "$branch"
71+
echo "...merging main"
72+
git merge -m "misc: merge from main" main
73+
if [ $? -eq 0 ]; then
74+
echo "...pushing to origin"
75+
git push origin "$branch"
76+
else
77+
echo "...merge failed"
78+
git merge --abort
79+
fi
80+
done
81+
}
82+
83+
merge_main

.github/workflows/continuous-integration.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ jobs:
1919
steps:
2020
- name: Checkout sources
2121
uses: actions/checkout@v2
22-
- uses: actions/cache@v2
22+
- uses: actions/cache@v4
2323
with:
2424
path: |
2525
~/.gradle/caches
2626
~/.gradle/wrapper
2727
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
2828
restore-keys: |
2929
${{ runner.os }}-gradle-
30+
- name: Configure Gradle
31+
uses: ./.github/actions/configure-gradle
3032
- name: Build and Test ${{ env.PACKAGE_NAME }}
3133
run: |
3234
./gradlew build
@@ -36,14 +38,16 @@ jobs:
3638
steps:
3739
- name: Checkout sources
3840
uses: actions/checkout@v2
39-
- uses: actions/cache@v2
41+
- uses: actions/cache@v4
4042
with:
4143
path: |
4244
~/.gradle/caches
4345
~/.gradle/wrapper
4446
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
4547
restore-keys: |
4648
${{ runner.os }}-gradle-
49+
- name: Configure Gradle
50+
uses: ./.github/actions/configure-gradle
4751
- name: Build and Test ${{ env.PACKAGE_NAME }}
4852
run: |
4953
./gradlew build
@@ -53,6 +57,8 @@ jobs:
5357
steps:
5458
- name: Checkout sources
5559
uses: actions/checkout@v2
60+
- name: Configure Gradle
61+
uses: ./.github/actions/configure-gradle
5662
- name: Build and Test ${{ env.PACKAGE_NAME }}
5763
run: |
58-
./gradlew build
64+
./gradlew build

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
steps:
1919
- name: Checkout sources
2020
uses: actions/checkout@v2
21+
- name: Run ls
22+
run: ls & pwd
23+
- name: Configure Gradle
24+
uses: ./.github/actions/configure-gradle
2125
- name: Lint ${{ env.PACKAGE_NAME }}
2226
run: |
2327
./gradlew ktlint

.github/workflows/merge-main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Merge main
2+
on:
3+
schedule:
4+
- cron: "0 7 * * 1-5" # At 07:00 UTC (00:00 PST, 03:00 EST), Monday through Friday
5+
workflow_dispatch:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Merge main
12+
uses: awslabs/aws-kotlin-repo-tools/.github/actions/merge-main@main
13+
with:
14+
exempt-branches: # Add any if required

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
9090
url.set("https://github.com/$githubOrganization/$repoName")
9191
licenses {
9292
license {
93-
name.set("The Apache License, Version 2.0")
93+
name.set("Apache-2.0")
9494
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
9595
}
9696
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https://services.gradle.org/distributions/gradle-8.12.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)