diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2829f6c..cd698db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: use-installer: true - run: make init - run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make build-single-arch - - run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make test + - run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} ARCH=x86_64 make test build-multi-arch: strategy: @@ -96,4 +96,5 @@ jobs: use-installer: true - run: make init - run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make build-multi-arch - - run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make test + - run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} ARCH=x86_64 make test + - run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} ARCH=arm64 make test diff --git a/Makefile b/Makefile index 46e8ae3..ba4e83d 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,22 @@ build-multi-arch: pre-build docker run --privileged --rm tonistiigi/binfmt --install arm64 docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=aarch64 --build-arg GO_ARCH=arm64 --build-arg IMAGE_ARCH=arm64 ./build-image-src +build-x86-64-arch: pre-build +ifeq ($(strip $(RUNTIME)), $(IS_java8)) || ($(strip $(RUNTIME)), $(IS_provided)) || ($(strip $(RUNTIME)), $(IS_go1x)) + docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):x86_64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) ./build-image-src +else + docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=x86_64 --build-arg GO_ARCH=amd64 --build-arg IMAGE_ARCH=x86_64 ./build-image-src +endif + +build-arm64-arch: pre-build + docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=aarch64 --build-arg GO_ARCH=arm64 --build-arg IMAGE_ARCH=arm64 ./build-image-src + test: pre-build - pytest tests -vv -m $(RUNTIME) +ifeq ($(strip $(ARCH)), x86_64) + pytest tests -vv -m $(RUNTIME)X86_64 +else ifeq ($(strip $(ARCH)), arm64) + pytest tests -vv -m $(RUNTIME)Arm64 +endif lint: # Linter performs static analysis to catch latent bugs diff --git a/requirements.txt b/requirements.txt index af7e593..edd7aa3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ pylint~=2.6.0 urllib3<2 # Test requirements -pytest==6.1.1 +pytest==7.3.1 # formatter black==20.8b1 diff --git a/tests/test_build_images.py b/tests/test_build_images.py index 4d6a19a..9aa5e5d 100644 --- a/tests/test_build_images.py +++ b/tests/test_build_images.py @@ -2,7 +2,7 @@ from tests.build_image_base_test import BuildImageBase, AL2023BasedBuildImageBase -@pytest.mark.java8 +@pytest.mark.java8X86_64 class TestBIJava8(BuildImageBase): __test__ = True @@ -22,7 +22,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.java8_al2 +@pytest.mark.java8_al2X86_64 class TestBIJava8AL2(BuildImageBase): __test__ = True @@ -42,7 +42,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.java8_al2 +@pytest.mark.java8_al2Arm64 class TestBIJava8AL2ForArm(BuildImageBase): __test__ = True @@ -62,7 +62,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.java11 +@pytest.mark.java11X86_64 class TestBIJava11(BuildImageBase): __test__ = True @@ -82,7 +82,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.java11 +@pytest.mark.java11Arm64 class TestBIJava11ForArm(BuildImageBase): __test__ = True @@ -102,7 +102,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.java17 +@pytest.mark.java17X86_64 class TestBIJava17Maven(BuildImageBase): __test__ = True @@ -122,7 +122,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.java17 +@pytest.mark.java17Arm64 class TestBIJava17ForArmMaven(BuildImageBase): __test__ = True @@ -142,7 +142,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.java17 +@pytest.mark.java17X86_64 class TestBIJava17AL2Gradle(BuildImageBase): __test__ = True @@ -162,7 +162,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.java17 +@pytest.mark.java17Arm64 class TestBIJava17AL2ForArmGradle(BuildImageBase): __test__ = True @@ -181,8 +181,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("gradle")) self.assertTrue(self.is_architecture("aarch64")) - -@pytest.mark.java21 +@pytest.mark.java21X86_64 class TestBIJava21Maven(AL2023BasedBuildImageBase): __test__ = True @@ -202,7 +201,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.java21 +@pytest.mark.java21Arm64 class TestBIJava21ForArmMaven(AL2023BasedBuildImageBase): __test__ = True @@ -222,7 +221,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.java21 +@pytest.mark.java21X86_64 class TestBIJava21Gradle(AL2023BasedBuildImageBase): __test__ = True @@ -242,7 +241,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.java21 +@pytest.mark.java21Arm64 class TestBIJava21ForArmGradle(AL2023BasedBuildImageBase): __test__ = True @@ -262,7 +261,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.nodejs16x +@pytest.mark.nodejs16xX86_64 class TestBINode16(BuildImageBase): __test__ = True @@ -279,7 +278,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.nodejs16x +@pytest.mark.nodejs16xArm64 class TestBINode16ForArm(BuildImageBase): __test__ = True @@ -296,7 +295,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.nodejs18x +@pytest.mark.nodejs18xX86_64 class TestBINode18(BuildImageBase): __test__ = True @@ -313,7 +312,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.nodejs18x +@pytest.mark.nodejs18xArm64 class TestBINode18ForArm(BuildImageBase): __test__ = True @@ -329,8 +328,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("npm")) self.assertTrue(self.is_architecture("aarch64")) - -@pytest.mark.nodejs20x +@pytest.mark.nodejs20xX86_64 class TestBINode20(AL2023BasedBuildImageBase): __test__ = True @@ -347,7 +345,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.nodejs20x +@pytest.mark.nodejs20xArm64 class TestBINode20ForArm(AL2023BasedBuildImageBase): __test__ = True @@ -364,7 +362,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.python37 +@pytest.mark.python37X86_64 class TestBIPython37(BuildImageBase): __test__ = True @@ -381,7 +379,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.python38 +@pytest.mark.python38X86_64 class TestBIPython38(BuildImageBase): __test__ = True @@ -398,7 +396,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("x86_64")) -@pytest.mark.python38 +@pytest.mark.python38Arm64 class TestBIPython38ForArm(BuildImageBase): __test__ = True @@ -415,7 +413,7 @@ def test_packages(self): self.assertTrue(self.is_architecture("aarch64")) -@pytest.mark.python39 +@pytest.mark.python39X86_64 class TestBIPython39(BuildImageBase): __test__ = True @@ -431,7 +429,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("pip")) -@pytest.mark.python310 +@pytest.mark.python310Arm64 class TestBIPython310ForArm(BuildImageBase): __test__ = True @@ -447,7 +445,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("pip")) -@pytest.mark.python310 +@pytest.mark.python310X86_64 class TestBIPython310(BuildImageBase): __test__ = True @@ -462,8 +460,7 @@ def test_packages(self): self.assertTrue(self.check_package_output("python --version", "Python 3.10.")) self.assertTrue(self.is_package_present("pip")) - -@pytest.mark.python311 +@pytest.mark.python311Arm64 class TestBIPython311ForArm(BuildImageBase): __test__ = True @@ -479,7 +476,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("pip")) -@pytest.mark.python311 +@pytest.mark.python311X86_64 class TestBIPython311(BuildImageBase): __test__ = True @@ -494,8 +491,7 @@ def test_packages(self): self.assertTrue(self.check_package_output("python --version", "Python 3.11.")) self.assertTrue(self.is_package_present("pip")) - -@pytest.mark.python312 +@pytest.mark.python312Arm64 class TestBIPython312ForArm(AL2023BasedBuildImageBase): __test__ = True @@ -511,7 +507,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("pip")) -@pytest.mark.python312 +@pytest.mark.python312X86_64 class TestBIPython312(AL2023BasedBuildImageBase): __test__ = True @@ -527,7 +523,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("pip")) -@pytest.mark.python39 +@pytest.mark.python39Arm64 class TestBIPython39ForArm(BuildImageBase): __test__ = True @@ -543,7 +539,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("pip")) -@pytest.mark.dotnet6 +@pytest.mark.dotnet6X86_64 class TestBIDotNet6(BuildImageBase): __test__ = True @@ -561,7 +557,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("dotnet")) -@pytest.mark.dotnet6 +@pytest.mark.dotnet6Arm64 class TestBIDotNet6Arm(BuildImageBase): __test__ = True @@ -579,7 +575,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("dotnet")) -@pytest.mark.dotnet7 +@pytest.mark.dotnet7X86_64 class TestBIDotNet7(BuildImageBase): __test__ = True @@ -597,7 +593,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("dotnet")) -@pytest.mark.dotnet7 +@pytest.mark.dotnet7Arm64 class TestBIDotNet7Arm(BuildImageBase): __test__ = True @@ -615,12 +611,15 @@ def test_packages(self): self.assertTrue(self.is_package_present("dotnet")) # TODO (hawflau): Revert change after publishing preview image -@pytest.mark.dotnet8 +@pytest.mark.dotnet8X86_64 def test_dummy(): assert 1 == 1 - -@pytest.mark.ruby32 +@pytest.mark.dotnet8Arm64 +def test_dummy_for_arm64(): + assert 1 == 1 + +@pytest.mark.ruby32X86_64 class TestBIRuby32(BuildImageBase): __test__ = True @@ -637,8 +636,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("gem")) self.assertTrue(self.is_architecture("x86_64")) - -@pytest.mark.ruby32 +@pytest.mark.ruby32Arm64 class TestBIRuby32ForArm(BuildImageBase): __test__ = True @@ -655,8 +653,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("gem")) self.assertTrue(self.is_architecture("aarch64")) - -@pytest.mark.go1x +@pytest.mark.go1xX86_64 class TestBIGo1(BuildImageBase): __test__ = True @@ -672,7 +669,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("go")) -@pytest.mark.provided +@pytest.mark.providedX86_64 class TestBIProvided(BuildImageBase): __test__ = True @@ -688,7 +685,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("go")) -@pytest.mark.provided_al2 +@pytest.mark.provided_al2X86_64 class TestBIProvidedAL2(BuildImageBase): __test__ = True @@ -710,7 +707,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("go")) -@pytest.mark.provided_al2 +@pytest.mark.provided_al2Arm64 class TestBIProvidedAL2ForArm(BuildImageBase): __test__ = True @@ -732,7 +729,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("go")) -@pytest.mark.provided_al2023 +@pytest.mark.provided_al2023X86_64 class TestBIProvidedAL2023(AL2023BasedBuildImageBase): __test__ = True @@ -756,7 +753,7 @@ def test_packages(self): self.assertTrue(self.is_package_present("go")) -@pytest.mark.provided_al2023 +@pytest.mark.provided_al2023Arm64 class TestBIProvidedAL2023ForArm(AL2023BasedBuildImageBase): __test__ = True