Skip to content

Commit

Permalink
chore: Consolidate tasks (#99)
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 authored Oct 20, 2023
1 parent 55bc657 commit 0b39992
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 33 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: 1 addition & 1 deletion .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
manual-ci-format:
uses: ./.github/workflows/library_dafny_format.yml
uses: ./.github/workflows/library_format.yml
with:
dafny: '4.2.0'
manual-ci-verification:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
pr-ci-format:
uses: ./.github/workflows/library_dafny_format.yml
uses: ./.github/workflows/library_format.yml
with:
dafny: '4.2.0'
pr-ci-verification:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
push-ci-format:
uses: ./.github/workflows/library_dafny_format.yml
uses: ./.github/workflows/library_format.yml
with:
dafny: '4.2.0'
push-ci-verification:
Expand Down
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
10 changes: 10 additions & 0 deletions AwsCryptographicMaterialProviders/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ plugins {
`signing`
id("com.github.johnrengelman.shadow") version "7.1.2"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
id("com.diffplug.spotless") version "6.22.0"
}
}

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

// Commented out until the format has been updated
// spotless {
// java {
// googleJavaFormat()
// }
// }
10 changes: 10 additions & 0 deletions AwsCryptographyPrimitives/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
id("com.diffplug.spotless") version "6.22.0"
}
}

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

// Commented out until the format has been updated
// spotless {
// java {
// googleJavaFormat()
// }
// }
10 changes: 10 additions & 0 deletions ComAmazonawsDynamodb/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
id("com.diffplug.spotless") version "6.22.0"
}
}

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

// Commented out until the format has been updated
// spotless {
// java {
// googleJavaFormat()
// }
// }
10 changes: 10 additions & 0 deletions ComAmazonawsKms/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
id("com.diffplug.spotless") version "6.22.0"
}
}

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

// Commented out until the format has been updated
// 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
10 changes: 10 additions & 0 deletions StandardLibrary/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import javax.annotation.Nullable
plugins {
`java-library`
`maven-publish`
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
id("com.diffplug.spotless") version "6.22.0"
}
}

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

// Commented out until the format has been updated
// 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,9 @@ tasks.wrapper {
plugins {
`java-library`
`maven-publish`
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
id("com.diffplug.spotless") version "6.22.0"
}
}

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

// Commented out until the format has been updated
// spotless {
// java {
// googleJavaFormat()
// }
// }

0 comments on commit 0b39992

Please sign in to comment.