-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix image handling bugs in twoliter update
#326
Merged
Merged
Changes from all commits
Commits
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 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,45 @@ | ||
name: "Install crane" | ||
description: "Installs crane for use in testing." | ||
inputs: | ||
crane-version: | ||
description: "Version of crane to install" | ||
required: false | ||
default: latest | ||
install-dir: | ||
description: "Directory to install crane" | ||
required: false | ||
default: $HOME/.crane | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- shell: bash | ||
run: | | ||
mkdir -p ${{ inputs.install-dir }} | ||
|
||
VERSION=${{ inputs.crane-version }} | ||
if [[ "${VERSION}" == "latest" ]]; then | ||
VERSION=$(gh release list \ | ||
--exclude-pre-releases \ | ||
-R google/go-containerregistry \ | ||
--json name \ | ||
| jq -r '.[0].name') | ||
fi | ||
|
||
case ${{ runner.arch }} in | ||
X64) | ||
ARCH=x86_64 | ||
;; | ||
ARM64) | ||
ARCH=arm64 | ||
;; | ||
esac | ||
|
||
ARTIFACT_NAME="go-containerregistry_Linux_${ARCH}.tar.gz" | ||
gh release download "${VERSION}" \ | ||
-R google/go-containerregistry \ | ||
-p "${ARTIFACT_NAME}" \ | ||
--output - \ | ||
| tar -zxvf - -C "${{ inputs.install-dir }}" crane | ||
|
||
echo "${{ inputs.install-dir }}" >> "${GITHUB_PATH}" | ||
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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,9 @@ | ||
[package] | ||
name = "integration-tests" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[dev-dependencies] | ||
tokio = { version = "1", default-features = false, features = ["process", "fs", "rt-multi-thread"] } | ||
twoliter = { version = "0", path = "../../twoliter", artifact = [ "bin:twoliter" ] } |
This file contains 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,44 @@ | ||
#![cfg(test)] | ||
|
||
use std::ffi::OsStr; | ||
use std::path::PathBuf; | ||
use tokio::process::Command; | ||
|
||
mod twoliter_update; | ||
|
||
pub const TWOLITER_PATH: &'static str = env!("CARGO_BIN_FILE_TWOLITER"); | ||
|
||
pub fn test_projects_dir() -> PathBuf { | ||
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
p.pop(); | ||
p.join("projects") | ||
} | ||
|
||
pub async fn run_command<I, S, E>(cmd: S, args: I, env: E) -> std::process::Output | ||
where | ||
I: IntoIterator<Item = S>, | ||
E: IntoIterator<Item = (S, S)>, | ||
S: AsRef<OsStr>, | ||
{ | ||
let args: Vec<S> = args.into_iter().collect(); | ||
|
||
println!( | ||
"Executing '{}' with args [{}]", | ||
cmd.as_ref().to_string_lossy(), | ||
args.iter() | ||
.map(|arg| format!("'{}'", arg.as_ref().to_string_lossy())) | ||
.collect::<Vec<_>>() | ||
.join(", ") | ||
); | ||
|
||
let output = Command::new(cmd) | ||
.args(args.into_iter()) | ||
.envs(env.into_iter()) | ||
.output() | ||
.await | ||
.expect("failed to execute process"); | ||
|
||
println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); | ||
println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); | ||
output | ||
} |
This file contains 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,76 @@ | ||
use super::{run_command, test_projects_dir, TWOLITER_PATH}; | ||
|
||
const EXPECTED_LOCKFILE: &str = r#"schema-version = 1 | ||
release-version = "1.0.0" | ||
digest = "m/6DbBacnIBHMo34GCuzA4pAHzrnQJ2G/XJMMguZXjw=" | ||
|
||
[sdk] | ||
name = "bottlerocket-sdk" | ||
version = "0.42.0" | ||
vendor = "bottlerocket" | ||
source = "public.ecr.aws/bottlerocket/bottlerocket-sdk:v0.42.0" | ||
digest = "myHHKE41h9qfeyR6V6HB0BfiLPwj3QEFLUFy4TXcR10=" | ||
|
||
[[kit]] | ||
name = "bottlerocket-core-kit" | ||
version = "2.0.0" | ||
vendor = "custom-vendor" | ||
source = "public.ecr.aws/bottlerocket/bottlerocket-core-kit:v2.0.0" | ||
digest = "vlTsAAbSCzXFZofVmw8pLLkRjnG/y8mtb2QsQBSz1zk=" | ||
"#; | ||
|
||
#[tokio::test] | ||
#[ignore] | ||
/// Generates a Twoliter.lock file for the `external-kit` project using docker | ||
async fn test_twoliter_update_docker() { | ||
let external_kit = test_projects_dir().join("external-kit"); | ||
|
||
let lockfile = external_kit.join("Twoliter.lock"); | ||
tokio::fs::remove_file(&lockfile).await.ok(); | ||
|
||
let output = run_command( | ||
TWOLITER_PATH, | ||
[ | ||
"update", | ||
"--project-path", | ||
external_kit.join("Twoliter.toml").to_str().unwrap(), | ||
], | ||
[("TWOLITER_KIT_IMAGE_TOOL", "docker")], | ||
) | ||
.await; | ||
|
||
assert!(output.status.success()); | ||
|
||
let lock_contents = tokio::fs::read_to_string(&lockfile).await.unwrap(); | ||
assert_eq!(lock_contents, EXPECTED_LOCKFILE); | ||
|
||
tokio::fs::remove_file(&lockfile).await.ok(); | ||
} | ||
|
||
#[tokio::test] | ||
#[ignore] | ||
/// Generates a Twoliter.lock file for the `external-kit` project using crane | ||
async fn test_twoliter_update_crane() { | ||
let external_kit = test_projects_dir().join("external-kit"); | ||
|
||
let lockfile = external_kit.join("Twoliter.lock"); | ||
tokio::fs::remove_file(&lockfile).await.ok(); | ||
|
||
let output = run_command( | ||
TWOLITER_PATH, | ||
[ | ||
"update", | ||
"--project-path", | ||
external_kit.join("Twoliter.toml").to_str().unwrap(), | ||
], | ||
[("TWOLITER_KIT_IMAGE_TOOL", "crane")], | ||
) | ||
.await; | ||
|
||
assert!(output.status.success()); | ||
|
||
let lock_contents = tokio::fs::read_to_string(&lockfile).await.unwrap(); | ||
assert_eq!(lock_contents, EXPECTED_LOCKFILE); | ||
|
||
tokio::fs::remove_file(&lockfile).await.ok(); | ||
} |
This file contains 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 |
---|---|---|
@@ -1,19 +1,13 @@ | ||
schema-version = 1 | ||
release-version = "1.0.0" | ||
|
||
[sdk] | ||
name = "bottlerocket-sdk" | ||
vendor = "bottlerocket" | ||
version = "0.41.0" | ||
|
||
[vendor.bottlerocket] | ||
registry = "public.ecr.aws/bottlerocket" | ||
|
||
[vendor.custom-vendor] | ||
# We need to figure out how we can do integration testing with this | ||
registry = "public.ecr.aws/bottlerocket" | ||
|
||
[[kit]] | ||
name = "core-kit" | ||
version = "0.1.0" | ||
name = "bottlerocket-core-kit" | ||
version = "2.0.0" | ||
vendor = "custom-vendor" |
This file contains 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 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 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 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.
Nice!