generated from canonical/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache charmcraft pack container, skip unstable tests except on schedu…
…le (#35) Ported from canonical/mysql-k8s-operator#146 --------- Co-authored-by: WRFitch <[email protected]>
- Loading branch information
1 parent
21c83d2
commit a83dab0
Showing
12 changed files
with
145 additions
and
149 deletions.
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 |
---|---|---|
@@ -1,114 +1,97 @@ | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
name: Tests | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
workflow_call: | ||
pull_request: | ||
schedule: | ||
- cron: '53 0 * * *' # Daily at 00:53 UTC | ||
# Triggered on push to branch "main" by .github/workflows/release.yaml | ||
workflow_call: | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
- name: Install tox | ||
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version | ||
run: python3 -m pip install tox | ||
- name: Run linters | ||
run: tox -e lint | ||
run: tox run -e lint | ||
|
||
unit-test: | ||
name: Unit tests | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 5 | ||
needs: | ||
- lint | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: python -m pip install tox | ||
- name: Install tox | ||
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version | ||
run: python3 -m pip install tox | ||
- name: Run tests | ||
run: tox -e unit | ||
run: tox run -e unit | ||
|
||
integration-test-lxd-charm: | ||
name: Integration tests for the charm (lxd) | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- unit-test | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: lxd | ||
- name: Run integration tests | ||
run: | | ||
# set sysctl values in case the cloudinit-userdata not applied | ||
sudo sysctl -w vm.max_map_count=262144 | ||
sudo sysctl -w vm.swappiness=0 | ||
sudo sysctl -w net.ipv4.tcp_retries2=5 | ||
build: | ||
name: Build charms | ||
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v2 | ||
|
||
tox -e charm-integration | ||
integration-test-lxd-tls: | ||
name: Integration tests for TLS (lxd) | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- unit-test | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: lxd | ||
- name: Run integration tests | ||
run: | | ||
# set sysctl values in case the cloudinit-userdata not applied | ||
sudo sysctl -w vm.max_map_count=262144 | ||
sudo sysctl -w vm.swappiness=0 | ||
sudo sysctl -w net.ipv4.tcp_retries2=5 | ||
tox -e tls-integration | ||
# Commented due to failures because of HW related issues of the github runners: | ||
# integration-test-lxd-ha: | ||
# name: Integration tests for HA (lxd) | ||
# runs-on: ubuntu-22.04 | ||
# needs: | ||
# - unit-test | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v3 | ||
# - name: Setup operator environment | ||
# uses: charmed-kubernetes/actions-operator@main | ||
# with: | ||
# provider: lxd | ||
# - name: Run integration tests | ||
# run: | | ||
# # set sysctl values in case the cloudinit-userdata not applied | ||
# sudo sysctl -w vm.max_map_count=262144 | ||
# sudo sysctl -w vm.swappiness=0 | ||
# sudo sysctl -w net.ipv4.tcp_retries2=5 | ||
# | ||
# tox -e ha-integration | ||
|
||
integration-test-client-relation: | ||
name: Integration tests for client relation | ||
runs-on: ubuntu-22.04 | ||
integration-test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
tox-environments: | ||
- charm-integration | ||
- tls-integration | ||
# - ha-integration | ||
- client-integration | ||
name: ${{ matrix.tox-environments }} | ||
needs: | ||
- lint | ||
- unit-test | ||
- build | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup operator environment | ||
# TODO: Replace with custom image on self-hosted runner | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: lxd | ||
- name: Download packed charm(s) | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ needs.build.outputs.artifact-name }} | ||
- name: Select tests | ||
id: select-tests | ||
run: | | ||
if [ "${{ github.event_name }}" == "schedule" ] | ||
then | ||
echo Running unstable and stable tests | ||
echo "mark_expression=" >> $GITHUB_OUTPUT | ||
else | ||
echo Skipping unstable tests | ||
echo "mark_expression=not unstable" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Run integration tests | ||
run: | | ||
# set sysctl values in case the cloudinit-userdata not applied | ||
sudo sysctl -w vm.max_map_count=262144 | ||
sudo sysctl -w vm.swappiness=0 | ||
sudo sysctl -w net.ipv4.tcp_retries2=5 | ||
tox -e client-integration | ||
tox run -e ${{ matrix.tox-environments }} -- -m '${{ steps.select-tests.outputs.mark_expression }}' | ||
env: | ||
CI_PACKED_CHARMS: ${{ needs.build.outputs.charms }} |
This file was deleted.
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
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,28 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
import json | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
from pytest_operator.plugin import OpsTest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def ops_test(ops_test: OpsTest) -> OpsTest: | ||
if os.environ.get("CI") == "true": | ||
# Running in GitHub Actions; skip build step | ||
# (GitHub Actions uses a separate, cached build step. See .github/workflows/ci.yaml) | ||
packed_charms = json.loads(os.environ["CI_PACKED_CHARMS"]) | ||
|
||
async def build_charm(charm_path, bases_index: int = None) -> Path: | ||
for charm in packed_charms: | ||
if Path(charm_path) == Path(charm["directory_path"]): | ||
if bases_index is None or bases_index == charm["bases_index"]: | ||
return charm["file_path"] | ||
raise ValueError(f"Unable to find .charm file for {bases_index=} at {charm_path=}") | ||
|
||
ops_test.build_charm = build_charm | ||
return ops_test |
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.