Skip to content

Commit

Permalink
chore: Consolidate tasks
Browse files Browse the repository at this point in the history
* Update the root Makefile to run for each library
* Add format and codegen targets to root Makefile
* Add java and net format/check targets
* Update format action to prepare for update
  • Loading branch information
seebees committed Oct 19, 2023
1 parent 7e42029 commit b265bc9
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This workflow performs static analysis checks.
name: Library Dafny format check
name: Library format check

on:
workflow_call:
Expand Down Expand Up @@ -49,4 +49,21 @@ jobs:
run: |
# This works because `node` is installed by default on GHA runners
CORES=$(node -e 'console.log(os.cpus().length)')
make format-check
make format_dafny-check
# Commented out until the format has been updated
# - name: Check format of ${{ matrix.library }} Net code
# shell: bash
# working-directory: ./${{ matrix.library }}
# run: |
# # This works because `node` is installed by default on GHA runners
# CORES=$(node -e 'console.log(os.cpus().length)')
# make format_net-check

# - name: Check format of ${{ matrix.library }} Java code
# shell: bash
# working-directory: ./${{ matrix.library }}
# run: |
# # This works because `node` is installed by default on GHA runners
# CORES=$(node -e 'console.log(os.cpus().length)')
# make format_java-check
2 changes: 0 additions & 2 deletions AwsCryptographicMaterialProviders/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@ SERVICE_DEPS_AwsCryptographyKeyStore := \
ComAmazonawsDynamodb \
AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders \

format_net:
pushd runtimes/net && dotnet format && popd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
`signing`
id("com.github.johnrengelman.shadow") version "7.1.2"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("com.diffplug.spotless") version "6.22.0"
}

group = "software.amazon.cryptography"
Expand Down Expand Up @@ -307,3 +308,9 @@ fun buildPom(mavenPublication: MavenPublication) {
}
}
}

spotless {
java {
googleJavaFormat()
}
}
7 changes: 7 additions & 0 deletions AwsCryptographyPrimitives/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
id("com.diffplug.spotless") version "6.22.0"
}

group = "software.amazon.cryptography"
Expand Down Expand Up @@ -82,3 +83,9 @@ tasks {
classpath = sourceSets["test"].runtimeClasspath
}
}

spotless {
java {
googleJavaFormat()
}
}
7 changes: 7 additions & 0 deletions ComAmazonawsDynamodb/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
id("com.diffplug.spotless") version "6.22.0"
}

group = "software.amazon.cryptography"
Expand Down Expand Up @@ -87,3 +88,9 @@ tasks {
classpath = sourceSets["test"].runtimeClasspath
}
}

spotless {
java {
googleJavaFormat()
}
}
7 changes: 7 additions & 0 deletions ComAmazonawsKms/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
id("com.diffplug.spotless") version "6.22.0"
}

group = "software.amazon.cryptography"
Expand Down Expand Up @@ -87,3 +88,9 @@ tasks {
classpath = sourceSets["test"].runtimeClasspath
}
}

spotless {
java {
googleJavaFormat()
}
}
56 changes: 35 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# This finds all Dafny projects in this repository
# This makes building root level targets for each project easy
PROJECTS = $(shell find . -mindepth 2 -maxdepth 2 -type f -name "Makefile" | xargs dirname | xargs basename)

verify:
$(MAKE) -C StandardLibrary verify CORES=4
$(MAKE) -C AwsCryptographyPrimitives verify CORES=4
$(MAKE) -C ComAmazonawsKms verify CORES=4
$(MAKE) -C ComAmazonawsDynamodb verify CORES=4
$(MAKE) -C AwsCryptographicMaterialProviders verify CORES=4
$(MAKE) -C TestVectorsAwsCryptographicMaterialProviders verify CORES=4
$(foreach PROJECT, $(PROJECTS), \
$(MAKE) -C $(PROJECT) verify CORES=4 && \
) true

dafny-reportgenerator:
$(MAKE) -C StandardLibrary dafny-reportgenerator
$(MAKE) -C AwsCryptographyPrimitives dafny-reportgenerator
$(MAKE) -C ComAmazonawsKms dafny-reportgenerator
$(MAKE) -C ComAmazonawsDynamodb dafny-reportgenerator
$(MAKE) -C AwsCryptographicMaterialProviders dafny-reportgenerator
$(MAKE) -C TestVectorsAwsCryptographicMaterialProviders dafny-reportgenerator
$(foreach PROJECT, $(PROJECTS), \
$(MAKE) -C $(PROJECT) dafny-reportgenerator && \
) true

clean-dafny-report:
$(foreach PROJECT, $(PROJECTS), \
$(MAKE) -C $(PROJECT) clean-dafny-report && \
) true

format_dafny:
$(foreach PROJECT, $(PROJECTS), \
$(MAKE) -C $(PROJECT) format_dafny && \
) true

format_net:
$(foreach PROJECT, $(PROJECTS), \
$(MAKE) -C $(PROJECT) format_net && \
) true

format_java:
$(foreach PROJECT, $(PROJECTS), \
$(MAKE) -C $(PROJECT) format_java && \
) true

polymorph_code_gen:
$(foreach PROJECT, $(PROJECTS), \
$(MAKE) -C $(PROJECT) polymorph_code_gen && \
) true

duvet: | duvet_extract duvet_report

Expand All @@ -35,12 +58,3 @@ duvet_report:
--source-pattern "AwsCryptographicMaterialProviders/compliance_exceptions/**/*.txt" \
--source-pattern "(# //=,# //#).github/workflows/duvet.yaml" \
--html specification_compliance_report.html

format:
$(MAKE) -C StandardLibrary format
$(MAKE) -C AwsCryptographyPrimitives format
$(MAKE) -C ComAmazonawsKms format
$(MAKE) -C ComAmazonawsDynamodb format
$(MAKE) -C AwsCryptographicMaterialProviders format
$(MAKE) -C TestVectorsAwsCryptographicMaterialProviders format

19 changes: 17 additions & 2 deletions SharedMakefileV2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ verify_service:
-trace \
`find ./dafny/$(SERVICE) -name '*.dfy'` \

format:
format_dafny:
dafny format \
--function-syntax 3 \
--quantifier-syntax 3 \
--unicode-char false \
`find . -name '*.dfy'`

format-check:
format_dafny-check:
dafny format \
--check \
--function-syntax 3 \
Expand All @@ -144,6 +144,9 @@ dafny-reportgenerator:
--max-resource-count $(MAX_RESOURCE_COUNT) \
TestResults/*.csv

clean-dafny-report:
rm TestResults/*.csv

# Dafny helper targets

# Transpile the entire project's impl
Expand Down Expand Up @@ -341,11 +344,23 @@ test_net_mac_brew:
setup_net:
dotnet restore runtimes/net/

format_net:
dotnet format runtimes/net/*.csproj

format_net-check:
dotnet format runtimes/net/*.csproj --verify-no-changes

########################## Java targets

build_java: transpile_java mvn_local_deploy_dependencies
./runtimes/java/gradlew -p runtimes/java build

format_java:
./runtimes/java/gradlew -p runtimes/java spotlessApply

format_java-check:
./runtimes/java/gradlew -p runtimes/java spotlessCheck

transpile_java: | transpile_implementation_java transpile_test_java transpile_dependencies_java

transpile_implementation_java: TARGET=java
Expand Down
7 changes: 7 additions & 0 deletions StandardLibrary/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
id("com.diffplug.spotless") version "6.22.0"
}

group = "software.amazon.cryptography"
Expand Down Expand Up @@ -78,3 +79,9 @@ tasks {
classpath = sourceSets["test"].runtimeClasspath
}
}

spotless {
java {
googleJavaFormat()
}
}
3 changes: 0 additions & 3 deletions TestVectorsAwsCryptographicMaterialProviders/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,3 @@ SERVICE_DEPS_KeyVectors := \
ComAmazonawsDynamodb \
AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStore \
AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders \

format_net:
pushd runtimes/net && dotnet format && popd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tasks.wrapper {
plugins {
`java-library`
`maven-publish`
id("com.diffplug.spotless") version "6.22.0"
}

group = "software.amazon.cryptography"
Expand Down Expand Up @@ -94,3 +95,9 @@ tasks.register<Copy>("copyKeysJSON") {
from(layout.projectDirectory.file("../../dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json"))
into(layout.projectDirectory.dir("dafny/TestVectorsAwsCryptographicMaterialProviders/test"))
}

spotless {
java {
googleJavaFormat()
}
}

0 comments on commit b265bc9

Please sign in to comment.