Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,72 @@ on:
permissions:
pull-requests: write

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
format:
runs-on: ubuntu-latest
name: Auto-format
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.PR_TOKEN }}

- name: Check if last commit is from bot
id: check-bot
run: |
LAST_AUTHOR=$(git log -1 --format='%an')
if [ "$LAST_AUTHOR" = "github-actions[bot]" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- name: Set up JDK 21
if: steps.check-bot.outputs.skip != 'true'
uses: actions/setup-java@v5
with:
java-version: 21
distribution: 'corretto'

- name: Cache compiled buildscripts
if: steps.check-bot.outputs.skip != 'true'
uses: actions/cache@v5
with:
key: ${{ runner.os }}-gradle-${{ hashFiles('buildSrc/**/*.kts') }}
path: |
./buildSrc/build

- name: Setup Gradle
if: steps.check-bot.outputs.skip != 'true'
uses: gradle/actions/setup-gradle@v6
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
gradle-home-cache-includes: |
caches

- name: Run spotlessApply
if: steps.check-bot.outputs.skip != 'true'
run: ./gradlew spotlessApply

- name: Commit formatting changes
if: steps.check-bot.outputs.skip != 'true'
run: |
if [ -n "$(git status --porcelain)" ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Auto-format: apply spotless formatting"
git push
fi

build:
needs: [format]
if: always() && !cancelled()
runs-on: ${{ matrix.os }}
name: Java ${{ matrix.java }} ${{ matrix.os }}
strategy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public final class VersionCheck {
private static final InternalLogger LOGGER = InternalLogger.getLogger(VersionCheck.class);
private static final String SKIP_PROPERTY = "smithy.java.skipVersionCheck";
private static final String SKIP_VERSION_CHECK_PROPERTY = "smithy.java.skipVersionCheck";
private static final AtomicBoolean CHECKED = new AtomicBoolean(false);

private VersionCheck() {}
Expand All @@ -47,11 +47,11 @@ public static void check(ModuleVersion codegenVersion) {
if (CHECKED.get()) {
return;
}
if (Boolean.getBoolean(SKIP_PROPERTY)) {
if (Boolean.getBoolean(SKIP_VERSION_CHECK_PROPERTY)) {
LOGGER.warn("Smithy Java version compatibility check is disabled via '{}'. "
+ "This is not recommended and should only be used as a temporary workaround. "
+ "Running with mismatched module versions may cause unexpected runtime errors.",
SKIP_PROPERTY);
SKIP_VERSION_CHECK_PROPERTY);
CHECKED.set(true);
return;
}
Expand Down Expand Up @@ -120,4 +120,5 @@ public static void check(ModuleVersion codegenVersion) {
static void reset() {
CHECKED.set(false);
}

}