generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 31
kn: checksum bindings #1182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
kn: checksum bindings #1182
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
a29b8ca
Checksum bindings
lauzadis 1b63dc3
CI
lauzadis b131cd2
ktlint
lauzadis 8ae9c99
Replace `ensureServerRunning` with `.start(wait = true)`
lauzadis e0eb127
ktlint
lauzadis 0d56c69
Bump plugin version
lauzadis e327567
"Failed" -> "Could not" to make searching logs for compiler errors ea…
lauzadis f6effee
Add section on using `run-container-test.py`
lauzadis 688c434
CI
lauzadis 88f8fcd
Remove `wait=true`
lauzadis ae19ccf
Remove unused import
lauzadis 5b1baac
Add debug step
lauzadis 479a389
Add debug step
lauzadis e7da56e
Upgrade plugin version
lauzadis c5c4efb
Checkout kn-main aws-kotlin-repo-tools
lauzadis 48a1b40
Bump version
lauzadis 82dda2d
Remove debug step
lauzadis 5166805
Parse aws-kotlin-repo-tools version from libs.versions.toml
lauzadis 9ff195c
Add `shell`
lauzadis 49079ad
Remove disabledTests
lauzadis c1d4513
Re-enable tests
lauzadis 6799823
ktlint
lauzadis 84ea65d
Remove @Ignore
lauzadis 3e967ab
Clarify digestValue() behavior
lauzadis 1992bd3
Use port selector, replace `ensureServerRunning`
lauzadis 0049c00
Use event monitoring to ensure server is running
lauzadis 5ea2009
ktlint
lauzadis 8010e22
Fix broken assumption about `digestValue`
lauzadis 1bfceb4
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into kn-c…
lauzadis 215c347
Bump to latest build tools plugin
lauzadis b8ddc49
Test disabling cross compile
lauzadis c0da98b
Apply to `allprojects`
lauzadis c1c74af
Windows JVM aws.kotlin.native=false
lauzadis 15490c5
Use aws-kotlin-repo-tools disableCrossCompile
lauzadis fcd0384
Merge branch 'kn-main' of github.com:smithy-lang/smithy-kotlin into k…
lauzadis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| #!/usr/bin/env python3 | ||
| # | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """ | ||
| Run precompiled Kotlin/Native test binaries in a Docker container for a specific Linux distribution and architecture. | ||
|
|
||
| This requires Docker multiarch support, see https://docs.docker.com/build/building/multi-platform/ and https://github.com/multiarch/qemu-user-static | ||
| In GitHub we use a provided action for this: https://github.com/docker/setup-qemu-action | ||
|
|
||
| Locally you would need to run one of: | ||
|
|
||
| `docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes` | ||
|
|
||
| OR | ||
|
|
||
| `docker run --privileged --rm tonistiigi/binfmt --install all` | ||
| """ | ||
|
|
||
| import argparse | ||
| import os | ||
| import subprocess | ||
| import shlex | ||
| import shutil | ||
|
|
||
| VERBOSE = False | ||
|
|
||
| DISTRO_TO_IMAGE_NAME = { | ||
| "ubuntu-22.04": "public.ecr.aws/lts/ubuntu:22.04_stable", | ||
| "al2023": "public.ecr.aws/amazonlinux/amazonlinux:2023", | ||
| "al2": "public.ecr.aws/amazonlinux/amazonlinux:2" | ||
| } | ||
|
|
||
| DOCKER_PLATFORM_BY_ARCH = { | ||
| "x64": "linux/amd64", | ||
| "arm64": "linux/arm64" | ||
| } | ||
|
|
||
|
|
||
| def vprint(message): | ||
| global VERBOSE | ||
| if VERBOSE: | ||
| print(message) | ||
|
|
||
|
|
||
| def running_in_github_action(): | ||
| """ | ||
| Test if currently running in a GitHub action or running locally | ||
| :return: True if running in GH, False otherwise | ||
| """ | ||
| return "GITHUB_WORKFLOW" in os.environ | ||
|
|
||
|
|
||
| def shell(command, cwd=None, check=True, capture_output=False): | ||
| """ | ||
| Run a command | ||
| :param command: command to run | ||
| :param cwd: the current working directory to change to before executing the command | ||
| :param check: flag indicating if the status code should be checked. When true an exception will be | ||
| thrown if the command exits with a non-zero exit status. | ||
| :returns: the subprocess CompletedProcess output | ||
| """ | ||
| vprint(f"running `{command}`") | ||
| return subprocess.run(command, shell=True, check=check, cwd=cwd, capture_output=capture_output) | ||
|
|
||
|
|
||
| def oci_executable(): | ||
| """ | ||
| Attempt to find the OCI container executor used to build and run docker containers | ||
| """ | ||
| oci_exe = os.environ.get('OCI_EXE') | ||
| if oci_exe is not None: | ||
| return oci_exe | ||
|
|
||
| executors = ['finch', 'podman', 'docker'] | ||
|
|
||
| for exe in executors: | ||
| if shutil.which(exe) is not None: | ||
| return exe | ||
|
|
||
| print("cannot find container executor") | ||
| exit(1) | ||
|
|
||
|
|
||
| def run_docker_test(opts): | ||
| """ | ||
| Run a docker test for a precompiled Kotlin/Native binary | ||
|
|
||
| :param opts: the parsed command line options | ||
| """ | ||
| platform = DOCKER_PLATFORM_BY_ARCH[opts.arch] | ||
| oci_exe = oci_executable() | ||
|
|
||
| test_bin_dir = os.path.abspath(opts.test_bin_dir) | ||
| image_name = DISTRO_TO_IMAGE_NAME[opts.distro] | ||
| path_to_exe = f'./linux{opts.arch.capitalize()}/debugTest/test.kexe' | ||
|
|
||
| cmd = [ | ||
| oci_exe, | ||
| 'run', | ||
| '--rm', | ||
| f'-v{test_bin_dir}:/test', | ||
| ] | ||
| if not opts.no_system_certs: | ||
| cmd.append(f'-v/etc/ssl:/etc/ssl') | ||
|
Comment on lines
+105
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
|
|
||
| cmd.extend( | ||
| [ | ||
| '-w/test', | ||
| '-e DEBIAN_FRONTEND=noninteractive', | ||
| '--platform', | ||
| platform, | ||
| image_name, | ||
| path_to_exe, | ||
| ] | ||
| ) | ||
|
|
||
| cmd = shlex.join(cmd) | ||
| print(cmd) | ||
| shell(cmd) | ||
|
|
||
|
|
||
| def create_cli(): | ||
| parser = argparse.ArgumentParser( | ||
| prog="run-container-test", | ||
| description="Run cross platform test binaries in a container", | ||
| formatter_class=argparse.ArgumentDefaultsHelpFormatter | ||
| ) | ||
|
|
||
| parser.add_argument("-v", "--verbose", help="enable verbose output", action="store_true") | ||
|
|
||
| parser.add_argument("--distro", required=True, choices=DISTRO_TO_IMAGE_NAME.keys(), help="the distribution name to run the task on") | ||
| parser.add_argument("--arch", required=True, choices=DOCKER_PLATFORM_BY_ARCH.keys(), help="the architecture to use") | ||
| parser.add_argument("--test-bin-dir", required=True, help="the path to the test binary directory root") | ||
| parser.add_argument("--no-system-certs", action='store_true', help="disable mounting system certificates into the container") | ||
|
|
||
| return parser | ||
|
|
||
|
|
||
| def main(): | ||
| cli = create_cli() | ||
| opts = cli.parse_args() | ||
| if opts.verbose: | ||
| global VERBOSE | ||
| VERBOSE = True | ||
|
|
||
| run_docker_test(opts) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Docs are missing for
capture_output