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

feat(ci): v1 #248

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e3dded7
feat(ci): v1
lucabello Dec 12, 2024
0cc6b1a
fix workflow
lucabello Dec 12, 2024
bc42ff7
fix workflow
lucabello Dec 12, 2024
f7a5b56
add linting to local PRs
lucabello Dec 12, 2024
44ca51c
chore: trigger ci
lucabello Dec 12, 2024
522b1f9
call the correct workflow
lucabello Dec 12, 2024
aa8a48d
fix workflow
lucabello Dec 12, 2024
ac9fefb
fix workflow
lucabello Dec 12, 2024
339f6db
bump upload-artifact in rock-release-dev to v4
lucabello Dec 12, 2024
5589f11
add group to just recipes
lucabello Dec 12, 2024
ea9bb95
cleanup workflows
lucabello Dec 12, 2024
695f30d
add changes
lucabello Jan 9, 2025
3150b67
fix: use feature/v1 in release
lucabello Jan 9, 2025
0b9240b
remove leftover
lucabello Jan 9, 2025
340fa29
chore: trigger ci
lucabello Jan 9, 2025
48e75f9
fix parallel itests
lucabello Jan 9, 2025
0217cc5
use default GITHUB_TOKEN for labels
lucabello Jan 9, 2025
84f78a5
fix: invocation of release ci
lucabello Jan 9, 2025
a6e7928
things
lucabello Jan 10, 2025
17d59c1
use caching for charmcraft pack and reduce duplication of charmcraft …
lucabello Jan 10, 2025
59138b4
use runner.arch instead of inputs.runner for display name
lucabello Jan 10, 2025
9e5632c
try to fix json parsing in uploaded_charm
lucabello Jan 10, 2025
d13734b
use inputs.runner again
lucabello Jan 10, 2025
c127031
clean the json output with jq
lucabello Jan 10, 2025
b346454
add git config to release
lucabello Jan 10, 2025
77aa7e8
try to fix ci command
lucabello Jan 10, 2025
8c54338
temporarily remove quality checks from release
lucabello Jan 10, 2025
e8b8010
remove quality-checks dep
lucabello Jan 10, 2025
141204e
move the matrix job to _charm-release
lucabello Jan 10, 2025
526cf83
fix bash syntax
lucabello Jan 10, 2025
6db3e6f
fix bash syntax again
lucabello Jan 10, 2025
afb72bb
install uv snap
lucabello Jan 10, 2025
0a889fe
fix used variables
lucabello Jan 10, 2025
4d02a3e
add debug message
lucabello Jan 10, 2025
f3b9014
try to fix jq
lucabello Jan 10, 2025
605b719
another try
lucabello Jan 10, 2025
c3beaa3
try again
lucabello Jan 10, 2025
4d8bd13
this should work
lucabello Jan 10, 2025
9ed1108
use jq from apt
lucabello Jan 10, 2025
444420c
avoid printing uv message
lucabello Jan 10, 2025
e92ca51
unwrap uvx noctua
lucabello Jan 10, 2025
068d1a8
fix filename
lucabello Jan 10, 2025
5700b91
use printf instead of print
lucabello Jan 10, 2025
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
64 changes: 0 additions & 64 deletions .github/workflows/_charm-codeql-analysis.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/_charm-linting.yaml

This file was deleted.

214 changes: 157 additions & 57 deletions .github/workflows/_charm-quality-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ on:
charm-path:
type: string
required: false
default: .
provider:
type: string
description: "The provider to choose for either machine or k8s tests ('lxd' or 'microk8s')"
description: "The provider to choose for integration tests ('machine' or 'microk8s')"
required: true
ip-range:
type: string
description: |
The IP range in the address pool for the load balancer to use.
It can be either a subnet(IP/mask) or a range (<IP1>-<IP2>)
required: false
default: null
charmcraft-channel:
type: string
default: "3.x/candidate"
required: false
required: true
description: |
The snap channel from which to install Charmcraft.
juju-channel:
type: string
required: true
description: |
The snap channel from which to install Juju.
Overrides the default branch-dependant selection of the Juju version.
secrets:
CHARMHUB_TOKEN:
required: false
Expand All @@ -38,69 +37,170 @@ jobs:
CHARMHUB_TOKEN: ${{ secrets.CHARMHUB_TOKEN }}
if: "${{ env.CHARMHUB_TOKEN != '' }}"
run: echo "defined=true" >> $GITHUB_OUTPUT

snap-channels:
name: Select snap channels
runs-on: ubuntu-latest
outputs:
juju-channel: ${{ steps.channels.outputs.juju-channel }}
env:
BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
steps:
- name: Determine Juju version
id: channels
run: |
# If a Juju version is passed from the inputs use that, otherwise use the defaults
# we picked for each track name
if [[ -n "${{ inputs.juju-channel }}" ]]; then
echo "juju-channel=${{ inputs.juju-channel }}" >> $GITHUB_OUTPUT
elif [[ "${BRANCH_NAME#refs/heads/}" == "track/1" ]]; then
echo "juju-channel=3.1/stable" >> $GITHUB_OUTPUT
else
echo "juju-channel=3.6/stable" >> $GITHUB_OUTPUT
fi

call-inclusive-naming-check:
# Issues with this workflow can be addressed by adding a .wokeignore in the repository root
name: Inclusive naming
uses: canonical/Inclusive-naming/.github/workflows/woke.yaml@main
with:
fail-on-error: "true"
lib-check:
name: Check libraries

codeql:
name: CodeQL analysis
runs-on: ubuntu-latest
needs:
- check-secret
if: needs.check-secret.outputs.defined == 'true'
- static-analysis
- linting
- unit-test
permissions:
security-events: write
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
fetch-depth: 1
- name: Check charm libraries # Make sure our charm libraries are updated
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
charm-path: "${{ inputs.charm-path }}"
charmcraft-channel: "${{ inputs.charmcraft-channel }}"
static-analysis:
name: Static Analysis
uses: canonical/observability/.github/workflows/_charm-static-analysis.yaml@main
with:
charm-path: "${{ inputs.charm-path }}"
languages: python
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

linting:
name: Linting
uses: canonical/observability/.github/workflows/_charm-linting.yaml@main
with:
charm-path: "${{ inputs.charm-path }}"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint
run: |
sudo snap install astral-uv --classic
cd "${{ inputs.charm-path }}"
uvx tox -e lint

static-analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Static analysis
run: |
sudo snap install astral-uv --classic
cd "${{ inputs.charm-path }}"
uvx tox -e static

unit-test:
name: Unit Tests
uses: canonical/observability/.github/workflows/_charm-tests-unit.yaml@main
with:
charm-path: "${{ inputs.charm-path }}"
scenario-test:
name: Scenario Tests
uses: canonical/observability/.github/workflows/_charm-tests-scenario.yaml@main
with:
charm-path: "${{ inputs.charm-path }}"
integration-test:
name: Integration Tests
needs:
- static-analysis
- linting
- unit-test
- scenario-test
uses: canonical/observability/.github/workflows/_charm-tests-integration.yaml@main
with:
charm-path: "${{ inputs.charm-path }}"
provider: "${{ inputs.provider }}"
ip-range: ${{ inputs.ip-range }}
charmcraft-channel: ${{ inputs.charmcraft-channel }}
codeql:
name: CodeQL analysis
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Unit tests
run: |
sudo snap install astral-uv --classic
cd "${{ inputs.charm-path }}"
uvx tox -e unit

pack-charm:
name: Pack the charm
runs-on: ubuntu-latest
needs:
- static-analysis
- linting
- unit-test
uses: canonical/observability/.github/workflows/_charm-codeql-analysis.yml@main
with:
charm-path: "${{ inputs.charm-path }}"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Install charmcraft
run: sudo snap install charmcraft --classic
- name: Cache wheels
uses: actions/cache@v4
with:
path: /home/runner/snap/charmcraft/common/cache/charmcraft
key: ${{ runner.os }}-wheel-cache-${{ hashFiles('./uv.lock') }}
# If the above cache key doesn't match, it's because the uv.lock has changed.
# Even so, pre-existing caches may still contain useful cached builds for some
# portion of the dependencies, and restore-keys can partially match a cache.
restore-keys: |
${{ runner.os }}-wheel-cache-
- name: Run charmcraft pack
run: |
cd "${{ inputs.charm-path }}"
charmcraft pack -v
- name: Upload charm artifact
uses: actions/upload-artifact@v4
with:
name: charm
path: ${{ inputs.charm-path }}/*.charm

integration-matrix:
name: Define Integration tests matrix
runs-on: ubuntu-latest
needs: [pack-charm]
outputs:
suites: ${{ steps.suites.outputs.suites }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate matrix list
id: suites
run: |
list="$(find tests/integration -name 'test_*.py' -printf '%f\n' | jq -r -ncR '[inputs]')"
echo "suites=$list"
echo "suites=$list" >> $GITHUB_OUTPUT

integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: [snap-channels, pack-charm, integration-matrix]
strategy:
fail-fast: false
matrix:
suite: ${{ fromJSON(needs.integration-matrix.outputs.suites) }}
env:
CONCIERGE_JUJU_CHANNEL: ${{ needs.snap-channels.outputs.juju-channel }}
CONCIERGE_MICROK8S_CHANNEL: 1.31-strict/stable
CONCIERGE_CHARMCRAFT_CHANNEL: ${{ inputs.charmcraft-channel }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo snap install concierge --classic
sudo concierge prepare -p "${{ inputs.provider }}" --extra-snaps=astral-uv
- name: Download charm artifact
uses: actions/download-artifact@v4
with:
name: charm
path: ${{ inputs.charm-path }}
- name: Run integration tests
run: |
cd ${{ inputs.charm-path }}
charm_relative_path="$(find . -maxdepth 1 -name '*.charm' | tail -n1)"
export CHARM_PATH="$(realpath $charm_relative_path)"
uvx tox -e integration -- -k "${{ matrix.suite }}"

Loading