Skip to content
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

Add conditional logic to allow CI and Make #252

Merged
merged 20 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/actions/charm-run-task/action.yaml
MichaelThamm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Task Runner'
description: 'Run tests for a charm'
inputs:
charm-path:
description: 'Path to the charm'
required: true
test-type:
description: 'Test type (e.g., lint, fmt, etc.)'
required: true
tox-command:
MichaelThamm marked this conversation as resolved.
Show resolved Hide resolved
description: 'The tox command options and environment (e.g. -vve lint)'
required: true

runs:
using: 'composite'
steps:
- name: Run test
shell: bash
run: |
cd ${{ inputs.charm-path }}
if [ -f tox.ini ]; then
tox ${{ inputs.tox-command }} # If the tox.ini file exists, run Tox
else
if grep -q -E "^\s*${{ inputs.test-type }}:" Makefile; then
make ${{ inputs.test-type }} # If the test type exists, run it with Make
MichaelThamm marked this conversation as resolved.
Show resolved Hide resolved
fi
fi
12 changes: 9 additions & 3 deletions .github/workflows/_charm-linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
with:
python-version: 3.8
- name: Install dependencies
run: python3 -m pip install tox
- name: Run linters
run: cd ${{ inputs.charm-path }} && tox -vve lint
run: |
python3 -m pip install tox
sudo snap install --classic astral-uv
- name: Run tests
uses: canonical/observability/.github/actions/charm-run-task@main
with:
charm-path: ${{ inputs.charm-path }}
test-type: lint
tox-command: -vve lint
20 changes: 16 additions & 4 deletions .github/workflows/_charm-static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ jobs:
with:
python-version: 3.8
- name: Install dependencies
run: python3 -m pip install tox
run: |
python3 -m pip install tox
sudo snap install --classic astral-uv
- name: Run static analysis for /lib for 3.8
run: cd ${{ inputs.charm-path }} && tox -vve static-lib
uses: canonical/observability/.github/actions/charm-run-task@main
with:
charm-path: ${{ inputs.charm-path }}
test-type: static
tox-command: -vve static-lib
static-charm:
name: Static Analysis of Charm
runs-on: ubuntu-latest
Expand All @@ -37,6 +43,12 @@ jobs:
with:
python-version: 3.8
- name: Install dependencies
run: python3 -m pip install tox
run: |
python3 -m pip install tox
sudo snap install --classic astral-uv
- name: Run static analysis (charm)
run: cd ${{ inputs.charm-path }} && tox -vve static-charm
uses: canonical/observability/.github/actions/charm-run-task@main
with:
charm-path: ${{ inputs.charm-path }}
test-type: static
tox-command: -vve static-charm
11 changes: 9 additions & 2 deletions .github/workflows/_charm-tests-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ jobs:
microk8s-group: snap_microk8s
microk8s-addons: "hostpath-storage dns metallb:${{ inputs.ip-range || steps.ip_range.outputs.ip_range }}"
charmcraft-channel: "${{ inputs.charmcraft-channel }}"
- name: Run integration tests
run: cd ${{ inputs.charm-path }} && tox -vve integration
- name: Install dependencies
run: |
sudo snap install --classic astral-uv
- name: Run tests
uses: canonical/observability/.github/actions/charm-run-task@main
with:
charm-path: ${{ inputs.charm-path }}
test-type: integration
tox-command: -vve integration
- name: Dump logs
if: failure()
uses: canonical/charming-actions/dump-logs@main
10 changes: 8 additions & 2 deletions .github/workflows/_charm-tests-scenario.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
with:
python-version: 3.8
- name: Install dependencies
run: python -m pip install tox
run: |
python -m pip install tox
sudo snap install --classic astral-uv
- name: Run tests
run: cd ${{ inputs.charm-path }} && tox -e scenario
uses: canonical/observability/.github/actions/charm-run-task@main
with:
charm-path: ${{ inputs.charm-path }}
test-type: scenario
tox-command: -e scenario
10 changes: 8 additions & 2 deletions .github/workflows/_charm-tests-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
with:
python-version: 3.8
- name: Install dependencies
run: python -m pip install tox
run: |
python -m pip install tox
sudo snap install --classic astral-uv
- name: Run tests
run: cd ${{ inputs.charm-path }} && tox -e unit
uses: canonical/observability/.github/actions/charm-run-task@main
with:
charm-path: ${{ inputs.charm-path }}
test-type: unit
tox-command: -e unit
Loading