Skip to content

Commit

Permalink
Merge pull request #3 from canonical/KU-1411/multiarch-metrics-server
Browse files Browse the repository at this point in the history
Rockcraft arm64 builds
  • Loading branch information
addyess authored Aug 26, 2024
2 parents a065ce5 + c457bbf commit 00cb7d7
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/cli-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: cla-check
on: [pull_request_target]

jobs:
cla-check:
runs-on: ubuntu-latest
steps:
- name: Check if CLA signed
uses: canonical/has-signed-canonical-cla@v1
17 changes: 17 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,27 @@ jobs:
trivy-image-config: "trivy.yaml"
multiarch-awareness: true
cache-action: ${{ (github.event_name == 'push') && 'save' || 'restore' }}
arch-skipping-maximize-build-space: '["arm64"]'
platform-labels: '{"arm64": ["Ubuntu_ARM64_4C_16G_01"]}'
run-tests:
uses: canonical/k8s-workflows/.github/workflows/run_tests.yaml@main
needs: [build-and-push-arch-specifics]
secrets: inherit
with:
rock-metas: ${{ needs.build-and-push-arch-specifics.outputs.rock-metas }}
scan-images:
uses: canonical/k8s-workflows/.github/workflows/scan_images.yaml@main
needs: [build-and-push-arch-specifics]
secrets: inherit
with:
upload-result: ${{ github.event_name == 'push' }}
images: ${{ needs.build-and-push-arch-specifics.outputs.images }}
trivy-image-config: ./trivy.yaml
build-and-push-multiarch-manifest:
name: Combine Rocks and Push Multiarch Manifest
uses: canonical/k8s-workflows/.github/workflows/assemble_multiarch_image.yaml@main
needs: [build-and-push-arch-specifics]
if: ${{ needs.build-and-push-arch-specifics.outputs.changed-rock-metas != '[]' }}
with:
rock-metas: ${{ needs.build-and-push-arch-specifics.outputs.rock-metas }}
dry-run: ${{ github.event_name != 'push' }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/__pycache__/
**/.tox/
3 changes: 1 addition & 2 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ base: bare
build-base: [email protected]
platforms:
amd64:
# TODO: Add after workflows support bulding arm64 ROCKs
# arm64:
arm64:

services:
metrics-server:
Expand Down
1 change: 1 addition & 0 deletions tests/.copyright.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copyright ${years} ${owner}.
5 changes: 5 additions & 0 deletions tests/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
black==24.3.0
codespell==2.2.4
flake8==6.0.0
isort==5.12.0
licenseheaders==0.8.8
5 changes: 5 additions & 0 deletions tests/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage[toml]==7.2.5
pytest==7.3.1
PyYAML==6.0.1
tenacity==8.2.3
git+https://github.com/canonical/k8s-test-harness.git@main
18 changes: 18 additions & 0 deletions tests/sanity/test_rock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2024 Canonical, Ltd.
#

import pytest
from k8s_test_harness.util import docker_util, env_util


@pytest.mark.parametrize("image_version", ["0.7.0"])
def test_sanity(image_version):
rock = env_util.get_build_meta_info_for_rock_version(
"metrics-server", image_version, "amd64"
)
image = rock.image
entrypoint = "/metrics-server"

process = docker_util.run_in_docker(image, [entrypoint, "--version"])
assert image_version in process.stdout
59 changes: 59 additions & 0 deletions tests/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[tox]
no_package = True
skip_missing_interpreters = True
env_list = format, lint, integration
min_version = 4.0.0

[testenv]
set_env =
PYTHONBREAKPOINT=pdb.set_trace
PY_COLORS=1
pass_env =
PYTHONPATH

[testenv:format]
description = Apply coding style standards to code
deps = -r {tox_root}/requirements-dev.txt
commands =
licenseheaders -t {tox_root}/.copyright.tmpl -cy -o 'Canonical, Ltd' -d {tox_root}/sanity
isort {tox_root}/sanity --profile=black
black {tox_root}/sanity

[testenv:lint]
description = Check code against coding style standards
deps = -r {tox_root}/requirements-dev.txt
commands =
codespell {tox_root}/sanity
flake8 {tox_root}/sanity
licenseheaders -t {tox_root}/.copyright.tmpl -cy -o 'Canonical, Ltd' -d {tox_root}/sanity --dry

[testenv:sanity]
description = Run sanity tests
deps =
-r {tox_root}/requirements-test.txt
commands =
pytest -v \
--maxfail 1 \
--tb native \
--log-cli-level DEBUG \
--disable-warnings \
{posargs} \
{tox_root}/sanity
pass_env =
TEST_*
ROCK_*
BUILT_ROCKS_METADATA

[testenv: integration]
allowlist_externals =
echo
commands =
# TODO: Implement integration tests here
echo "WARNING: This is a placeholder test - no test is implemented here."

[flake8]
max-line-length = 120
select = E,W,F,C,N
ignore = W503
exclude = venv,.git,.tox,.tox_env,.venv,build,dist,*.egg_info
show-source = true

0 comments on commit 00cb7d7

Please sign in to comment.