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

Update check and release workflow to release only tested charms #161

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-apt-mirror_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-cloudsupport_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-duplicity_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "2.x/stable",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-juju-local_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "2.x/stable",
}
}
Expand Down
5 changes: 1 addition & 4 deletions terraform-plans/configs/charm-local-users_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
# github hosted runners are amd64
# Ubuntu_ARM64_4C_16G_01 is the github-hosted arm64 runner we have access to.
# We prefer the github runners because they are smaller machines and save resources.
runs_on = "[[ubuntu-24.04], [Ubuntu_ARM64_4C_16G_01]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-logrotated_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-nginx_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-nrpe_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "2.x/stable",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "2.x/stable",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
# github hosted runners are amd64
# Ubuntu_ARM64_4C_16G_01 is the github-hosted arm64 runner we have access to.
# We prefer the github runners because they are smaller machines and save resources.
runs_on = "[[ubuntu-22.04], [Ubuntu_ARM64_4C_16G_01]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
jira_sync_config = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
6 changes: 3 additions & 3 deletions terraform-plans/configs/charm-sysconfig_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ templates = {
vars = {
# Skip ARM64 check because the functional test runs on lxd VM which is not working
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess now we can remove this comment because we are adding arm64?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

# on arm64 right now.
runs_on = "[[self-hosted, jammy, X64, large]]",
test_commands = "['tox -e func']",
runs_on = "[[self-hosted, jammy, X64, large], [Ubuntu_ARM64_4C_16G_01]]",
test_commands = "['if [ \"$(uname -m)\" = \"aarch64\" ]; then echo \"skipping func tests on arm64\"; else tox -e func; fi']",
juju_channels = "[\"3.4/stable\"]",
charmcraft_channel = "3.x/stable",
python_versions = "['3.8', '3.10']",
Expand All @@ -36,7 +36,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04], [Ubuntu_ARM64_4C_16G_01]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform-plans/configs/charm-userdir-ldap_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
23 changes: 12 additions & 11 deletions terraform-plans/configs/hardware-observer-operator_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ templates = {
destination = ".github/CODEOWNERS"
vars = {}
}
# Temporarily disable it since the charm uses a different template
# check = {
# source = "./templates/github/charm_check.yaml.tftpl"
# destination = ".github/workflows/check.yaml"
# vars = {
# runs_on = "[[ubuntu-22.04], [Ubuntu_ARM64_4C_16G_01]]",
# test_commands = "['tox -e func -- -v --series focal --keep-models', 'tox -e func -- -v --series jammy --keep-models']",
# juju_channels = "[\"3.4/stable\"]",
# }
# }
check = {
source = "./templates/github/charm_check.yaml.tftpl"
destination = ".github/workflows/check.yaml"
vars = {
runs_on = "[[ubuntu-22.04], [Ubuntu_ARM64_4C_16G_01]]",
test_commands = "['tox -e func -- -v --base ubuntu@20.04 --keep-models', 'tox -e func -- -v --base ubuntu@22.04 --keep-models', 'if [ \"$(uname -m)\" = \"aarch64\" ]; then echo \"skipping func tests on ubuntu@24.04/arm64\"; else tox -e func -- -v --base ubuntu@24.04 --keep-models; fi' ]",
juju_channels = "[\"3.4/stable\"]",
charmcraft_channel = "3.x/stable",
python_versions = "['3.8', '3.10']",
}
}
promote = {
source = "./templates/github/charm_promote.yaml.tftpl"
destination = ".github/workflows/promote.yaml"
Expand All @@ -33,7 +34,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04], [Ubuntu_ARM64_4C_16G_01]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ templates = {
source = "./templates/github/charm_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {
runs_on = "[[ubuntu-22.04]]",
runs_on = "ubuntu-24.04",
charmcraft_channel = "3.x/stable",
}
}
Expand Down
57 changes: 51 additions & 6 deletions terraform-plans/templates/github/charm_check.yaml.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,57 @@ jobs:
- name: Run unit tests
run: tox -e unit

func:
build:
needs:
- lint
- unit
name: build charms
runs-on: $${{ matrix.runs-on }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
runs-on: ${ runs_on }
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: canonical/craft-actions/charmcraft/setup@main
with:
channel: "${ charmcraft_channel }"

- name: Pack the charms
id: build
run: |
charmcraft -v pack
echo "charms=$(ls -1 *.charm | tr '\n' ' ')" >> "$GITHUB_OUTPUT"

- name: List the names of the built charms
run: echo "::notice::Successfully built $${{ steps.build.outputs.charms}}"

- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV

- name: Upload the tested charms
uses: actions/upload-artifact@v4
with:
name: built_charms_$${{ env.SYSTEM_ARCH }}
path: ./*.charm

func:
needs:
- build
name: functional tests
runs-on: $${{ matrix.runs-on }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
runs-on: ${runs_on}
runs-on: ${ runs_on }
test-command: ${ test_commands }
juju-channel: ${ juju_channels }
steps:

- uses: actions/checkout@v4
with:
submodules: true
Expand All @@ -109,15 +145,24 @@ jobs:
juju-channel: $${{ matrix.juju-channel }}
charmcraft-channel: "${ charmcraft_channel }"

- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV

# 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
if [ "$${{ env.SYSTEM_ARCH }}" = "aarch64" ]; then
echo "TEST_MODEL_CONSTRAINTS=arch=arm64" >> "$GITHUB_ENV"
fi

- name: Build the charm
run: charmcraft -v pack
- name: Download the built charms
uses: actions/download-artifact@v4
with:
name: built_charms_$${{ env.SYSTEM_ARCH }}

- name: List the names of the downloaded charms
run: |
ls *.charm

- name: Run tests
run: |
Expand Down
22 changes: 11 additions & 11 deletions terraform-plans/templates/github/charm_release.yaml.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ jobs:
release:
needs: check
runs-on: $${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: ${runs_on}
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
# 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: Download the tested charms
uses: actions/download-artifact@v4
with:
pattern: built_charms_*
merge-multiple: true

- name: List the names of the tested charms
run: |
echo "CHARM_NAMES=$(ls *.charm | paste -sd ,)" | tee -a "$GITHUB_ENV"

- name: Pack and upload to charmhub
uses: canonical/charming-actions/upload-charm@2.6.2
uses: canonical/charming-actions/upload-charm@2.7.0
with:
charmcraft-channel: "${charmcraft_channel}"
credentials: "$${{ secrets.CHARMHUB_TOKEN }}"
github-token: "$${{ secrets.GITHUB_TOKEN }}"
# Ensure the charm is built in an isolated environment and on the correct base in an lxd container.
destructive-mode: false
built-charm-path: "$${{ env.CHARM_NAMES }}"