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

Restructure and remove old files [SOLENG-833] #40

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
171 changes: 151 additions & 20 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Check workflow running linter, unit and functional tests
# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation
# To update the file:
# - Edit it in the canonical/solutions-engineering-automation repository.
# - Open a PR with the changes.
# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes.
name: Tests

on:
workflow_dispatch:
workflow_call:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
branches: [master, main]
branches: [main]
paths-ignore:
- "**.md"
- "**.rst"
Expand All @@ -15,29 +20,155 @@ concurrency:
cancel-in-progress: true

jobs:
lint-unit:
uses: canonical/bootstack-actions/.github/workflows/lint-unit.yaml@v2
lint:
name: Lint
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10"]
with:
python-version: ${{ matrix.python-version }}
working-directory: ./src
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
# pin tox to the current major version to avoid
# workflows breaking all at once when a new major version is released.
python -m pip install 'tox<5'

- name: Run linters
run: tox -e lint

unit:
name: Unit
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install 'tox<5'

- name: Run unit tests
run: tox -e unit

func:
uses: canonical/bootstack-actions/.github/workflows/func.yaml@v2
needs: lint-unit
needs:
- lint
- unit
name: functional tests
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- juju-channel: "3.4/stable"
command: "TEST_JUJU3=1 make functional" # using TEST_JUJU3 due https://github.com/openstack-charmers/zaza/commit/af7eea953dd5d74d3d074fe67b5765dca3911ca6
with:
command: ${{ matrix.command }}
juju-channel: ${{ matrix.juju-channel }}
nested-containers: false
provider: "lxd"
python-version: "3.10"
timeout-minutes: 120
runs-on: [[ubuntu-22.04]]
test-command: ['tox -e func']
juju-channel: ["3.4/stable"]
steps:

- uses: actions/checkout@v4
with:
submodules: true

# arm64 runners don't have gcc installed by default
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y gcc

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Setup Juju environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: "lxd"
juju-channel: ${{ matrix.juju-channel }}
charmcraft-channel: "2.x/stable"

# This is used by zaza in the functional tests for non-amd64 architectures (if applicable)
- name: Set zaza juju model constraints for architecture
run: |
if [ "$(uname -m)" = "aarch64" ]; then
echo "TEST_MODEL_CONSTRAINTS=arch=arm64" >> "$GITHUB_ENV"
fi

- name: Build the charm
run: charmcraft -v pack

- name: Run tests
run: |
# These variables are for a consistent method to find the charm file(s) across all projects.
# It is designed to work both with charms that output one file per base,
# and charms that output a single file to run on all bases.
# Not all charms will use them, and for some charms the variables will resolve to the same file.
export CHARM_PATH_NOBLE="$(pwd)/$(ls | grep '.*24.04.*\.charm$')"
echo "$CHARM_PATH_NOBLE"
export CHARM_PATH_JAMMY="$(pwd)/$(ls | grep '.*22.04.*\.charm$')"
echo "$CHARM_PATH_JAMMY"
export CHARM_PATH_FOCAL="$(pwd)/$(ls | grep '.*20.04.*\.charm$')"
echo "$CHARM_PATH_FOCAL"
${{ matrix.test-command }}
env:
TEST_JUJU3: "1" # https://github.com/openstack-charmers/zaza/pull/653
TEST_JUJU_CHANNEL: ${{ matrix.juju-channel }}

# Save output for debugging

- name: Generate debugging information
if: always()
run: |
set -x
# install dependencies
sudo snap install --classic juju-crashdump
sudo apt install -y jq uuid

# Print juju controller information for debugging
# to check controller and client are compatible versions;
# we can have a mismatch if using an external controller.
juju version
juju controllers

models="$(juju models --format json | jq -r '.models[]."short-name"')"
dir="$(mktemp -d)"
# Use a different dir to avoid charmed-kubernetes/actions-operator from also trying to upload crashdumps.
# We don't want to rely on that action, because it doesn't use a descriptive enough name for the artefact,
# and we may stop using that action soon.
echo "CRASHDUMPS_DIR=$dir" | tee -a "$GITHUB_ENV"
echo "CRASHDUMPS_ARTEFACT_SUFFIX=$(uuid)-$(uname -m)" | tee -a "$GITHUB_ENV"

for model in $models; do
# show status here for quick debugging
juju status -m "$model"
juju-crashdump --as-root -m "$model" -u "$model-$(uname -m)" -o "$dir"
done

- name: Upload juju crashdumps
uses: actions/upload-artifact@v4
if: always()
with:
name: "juju-crashdumps-${{ env.CRASHDUMPS_ARTEFACT_SUFFIX }}"
path: "${{ env.CRASHDUMPS_DIR }}/juju-crashdump-*.tar.xz"
25 changes: 0 additions & 25 deletions .github/workflows/issues_to_jira.yaml

This file was deleted.

35 changes: 25 additions & 10 deletions .github/workflows/promote.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
name: Promote charm to other tracks and channels
# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation
# To update the file:
# - Edit it in the canonical/solutions-engineering-automation repository.
# - Open a PR with the changes.
# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes.
name: Promote charm to default track, standard risk levels.

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel, e.g. latest/candidate'
required: true
origin-channel:
description: 'Origin Channel, e.g. latest/edge'
channel-promotion:
description: 'Channel Promotion, e.g. latest/edge -> latest/candidate'
required: true
type: choice
options:
- 'latest/edge -> latest/candidate'
- 'latest/candidate -> latest/stable'

jobs:
promote-charm:
name: Promote charm
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set channels
id: set-channels
run: |
channel_promotion="${{ github.event.inputs.channel-promotion }}"
origin=$(echo "$channel_promotion" | sed 's/\s*->.*//')
destination=$(echo "$channel_promotion" | sed 's/.*->\s*//')
echo "destination-channel=$destination" >> $GITHUB_OUTPUT
echo "origin-channel=$origin" >> $GITHUB_OUTPUT
- name: Release charm to channel
uses: canonical/charming-actions/release-charm@2.4.0
uses: canonical/charming-actions/release-charm@2.6.2
with:
credentials: ${{ secrets.CHARMHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
destination-channel: ${{ github.event.inputs.destination-channel }}
origin-channel: ${{ github.event.inputs.origin-channel }}
destination-channel: ${{ steps.set-channels.outputs.destination-channel }}
origin-channel: ${{ steps.set-channels.outputs.origin-channel }}
charmcraft-channel: "2.x/stable"
26 changes: 20 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation
# To update the file:
# - Edit it in the canonical/solutions-engineering-automation repository.
# - Open a PR with the changes.
# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes.
name: Release to Edge

on:
Expand All @@ -13,17 +18,26 @@ jobs:

release:
needs: check
runs-on: ubuntu-latest
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [[ubuntu-22.04]]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Initialize lxd # This should dropped once it's implemented on charming-actions itself. https://github.com/canonical/charming-actions/issues/140
uses: canonical/[email protected]
- name: Upload charm to charmhub
uses: canonical/charming-actions/[email protected]
# revision is latest main at time of writing; using because it contains a fix to https://github.com/canonical/setup-lxd/issues/19
uses: canonical/setup-lxd@2aa6f7caf7d1484298a64192f7f63a6684e648a4

- name: Pack and upload to charmhub
uses: canonical/charming-actions/[email protected]
with:
charmcraft-channel: "2.x/stable"
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
channel: "latest/edge"
# Note(rgildein): Right now we are not using destructive-mode, since our charmcraft.yaml is designed with a single build-on and the ability to run-on multiple bases. Running with destructive-mode would require aligning the base defined in this job with the one defined in charmcraft.yaml (build-on).
# Ensure the charm is built in an isolated environment and on the correct base in an lxd container.
destructive-mode: false
17 changes: 0 additions & 17 deletions .github/workflows/sonar.yaml

This file was deleted.

49 changes: 0 additions & 49 deletions .pre-commit-config.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading