Skip to content

Commit

Permalink
Test env as well, fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
wrobstory committed Oct 5, 2023
1 parent dcc2c43 commit 17dfda8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
- uses: actions/checkout@v4
- name: example
shell: bash
run: scripts/ci-test.py
run: scripts/ci_test.py
35 changes: 20 additions & 15 deletions scripts/ci_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
import subprocess

# Navigate to tests/simple_flow
os.chdir('tests/simple_flow')
os.chdir("tests/simple_flow")

# Run bazel clean --expunge
subprocess.run(['bazel', 'clean', '--expunge'], check=True)
subprocess.run(["bazel", "clean", "--expunge"], check=True)

# Run bazel build ...
subprocess.run(['bazel', 'build', '...'], check=True)
subprocess.run(["bazel", "build", "..."], check=True)

# Calculate SHA_A
with open('bazel-bin/test_assemble_simple_merger_manifest.json', 'rb') as f:
SHA_A = subprocess.run(['shasum', '-a', '256'], stdin=f, capture_output=True, check=True).stdout.strip()
with open("bazel-bin/test_assemble_simple_merger_manifest.json", "rb") as f:
SHA_A = subprocess.run(["shasum", "-a", "256"], stdin=f, capture_output=True, check=True).stdout.strip()

# Load JSON file
with open('bazel-bin/test_assemble_simple_merger_config.json') as json_file:
with open("bazel-bin/test_assemble_simple_merger_config.json") as json_file:
data = json.load(json_file)

# Check Cmd, Labels, and User fields
cmd = data['config']['Cmd']
labels = data['config']['Labels']
user = data['config']['User']
cmd = data["config"]["Cmd"]
labels = data["config"]["Labels"]
user = data["config"]["User"]
env = data["config"]["Env"]

# Expected values
expected_cmd = ["/usr/bin/my_app"]
Expand All @@ -34,16 +35,20 @@
assert(cmd == expected_cmd)
assert(labels == expected_labels)
assert(user == expected_user)
# We should not override the env, we should add to the existing env
assert(len(env) > 2)
assert("ENV1=FOO" in env)
assert("ENV2=BAR" in env)

# Run bazel clean --expunge
subprocess.run(['bazel', 'clean', '--expunge'], check=True)
subprocess.run(["bazel", "clean", "--expunge"], check=True)

# Run bazel build ...
subprocess.run(['bazel', 'build', '...'], check=True)
subprocess.run(["bazel", "build", "..."], check=True)

# Calculate SHA_B
with open('bazel-bin/test_assemble_simple_merger_manifest.json', 'rb') as f:
SHA_B = subprocess.run(['shasum', '-a', '256'], stdin=f, capture_output=True, check=True).stdout.strip()
with open("bazel-bin/test_assemble_simple_merger_manifest.json", "rb") as f:
SHA_B = subprocess.run(["shasum", "-a", "256"], stdin=f, capture_output=True, check=True).stdout.strip()

# Compare SHA_A and SHA_B
if SHA_A != SHA_B:
Expand All @@ -55,7 +60,7 @@
print(f"[ok] SHA256 matched {SHA_A}")

# Navigate to tests/override_tools
os.chdir('../../tests/override_tools')
os.chdir("../../tests/override_tools")

# Run bazel query ...
subprocess.run(['bazel', 'query', '...'], check=True)
subprocess.run(["bazel", "query", "..."], check=True)
8 changes: 5 additions & 3 deletions tests/simple_flow/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ container_config(
)

container_config(
name = "labels",
name = "labels_and_env",
labels = {"label1": "foo",
"label2": "bar"}
"label2": "bar"},
env = {"ENV1": "FOO",
"ENV2": "BAR"}
)

container_compose(
Expand All @@ -51,7 +53,7 @@ container_compose(
":file_a_data",
":file_b_data",
":user_and_app",
":labels"
":labels_and_env"
],
)

Expand Down

0 comments on commit 17dfda8

Please sign in to comment.