-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
204 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Test Charmcraft | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- ".github/workflows/*charmcraft*" | ||
- "charmcraft**" | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test-install-success: | ||
strategy: | ||
matrix: | ||
channel: [latest/stable, latest/edge, 2.x/stable] | ||
include: | ||
- channel: '' | ||
revision: 5303 | ||
- channel: latest/stable | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./charmcraft/setup | ||
id: setup | ||
with: | ||
channel: ${{ matrix.channel }} | ||
revision: ${{ matrix.revision }} | ||
- name: Check revision number if set with a revision | ||
if: matrix.revision != '' | ||
run: | | ||
[[ ${{ matrix.revision }} == ${{ steps.setup.outputs.charmcraft-revision }} ]] | ||
- name: Check that revisions are set | ||
run: | | ||
test ${{ steps.setup.outputs.charmcraft-revision }} -ge 0 | ||
test ${{ steps.setup.outputs.lxd-revision }} -ge 0 | ||
- name: Check that install works even if Charmcraft is already installed | ||
uses: ./charmcraft/setup | ||
test-pack: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04, ubuntu-24.04] | ||
channel: [latest/stable] | ||
include: | ||
- os: ubuntu-24.04 | ||
channel: '' | ||
revision: 5303 | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: juju/juju | ||
path: juju | ||
ref: main | ||
- name: Pack charm | ||
id: charmcraft | ||
uses: ./charmcraft/pack | ||
with: | ||
path: juju/testcharms/charms/lxd-profile/ | ||
channel: ${{ matrix.channel }} | ||
revision: ${{ matrix.revision }} | ||
- name: Upload charm | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-charm-${{ matrix.os }}-${{ steps.charmcraft.outputs.charmcraft-revision }} | ||
path: juju/testcharms/charms/lxd-profile/*.charm | ||
|
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,64 @@ | ||
name: "Build a charm" | ||
description: "Pack a charm with Charmcraft" | ||
author: "Canonical" | ||
inputs: | ||
path: | ||
description: > | ||
The location of the Charmcraft project. | ||
Defaults to the base of the repository. | ||
default: '.' | ||
verbosity: | ||
description: > | ||
Set the build verbosity level to 'quiet', 'brief', 'verbose', 'debug' or | ||
'trace'. | ||
The default is 'trace'. | ||
default: 'trace' | ||
channel: | ||
description: > | ||
Install the snap from a specific channel | ||
If not provided, it defaults to stable. | ||
default: 'stable' | ||
revision: | ||
description: > | ||
Pin the snap revision to install. | ||
If not provided, it defaults to whatever revision is in latest/stable. | ||
default: '' | ||
outputs: | ||
charms: | ||
description: The names of any charm files created. | ||
value: ${{ steps.pack-charm.outputs.charms }} | ||
charmcraft-revision: | ||
description: The revision of Charmcraft used for the pack. | ||
value: ${{ steps.setup.outputs.charmcraft-revision }} | ||
lxd-revision: | ||
description: The revision of lxd used for the pack. | ||
value: ${{ steps.setup.outputs.lxd-revision }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./charmcraft/setup | ||
id: setup | ||
with: | ||
channel: ${{ inputs.channel }} | ||
revision: ${{ inputs.revision }} | ||
- uses: actions/cache@v4 | ||
with: | ||
path: ~/snap/charmcraft/common/cache | ||
key: charmcraft-cache-${{ hashfiles('**/requirements.txt', '**/*.lock', '**/charmcraft.yaml') }} | ||
restore-keys: | | ||
charmcraft-cache- | ||
- id: pack-charm | ||
shell: bash | ||
env: | ||
CRAFT_VERBOSITY_LEVEL: ${{ inputs.verbosity }} | ||
working-directory: ${{ inputs.path }} | ||
run: | | ||
charmcraft pack | ||
echo "charms=$(ls -1 *.charm | tr '\n' ' ')" >> "$GITHUB_OUTPUT" | ||
branding: | ||
icon: layers | ||
color: orange |
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,69 @@ | ||
name: "Setup Charmcraft" | ||
description: "Install Charmcraft" | ||
author: "Canonical" | ||
inputs: | ||
channel: | ||
description: > | ||
Install the snap from a specific channel | ||
If not provided, it defaults to stable. | ||
default: 'stable' | ||
revision: | ||
description: > | ||
Pin the snap revision to install. | ||
If not provided, it defaults to whatever revision is in latest/stable. | ||
default: '' | ||
lxd-channel: | ||
description: > | ||
The LXD channel to use. | ||
Defaults to the recommended channel for Charmcraft. | ||
default: 5.21/stable | ||
outputs: | ||
lxd-revision: | ||
description: The LXD revision used. | ||
value: ${{ steps.install.outputs.lxd }} | ||
charmcraft-revision: | ||
description: The Charmcraft revision used. | ||
value: ${{ steps.install.outputs.charmcraft }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- shell: bash | ||
name: Check system compatibility | ||
run: | | ||
if [[ $(uname -s) != Linux ]]; then | ||
echo "::error::This action only works on Linux runners." | ||
exit 1 | ||
fi | ||
if ! which snap; then | ||
echo "::error::This action requires snapd" | ||
fi | ||
- uses: canonical/setup-lxd@main | ||
with: | ||
channel: ${{ inputs.lxd-channel }} | ||
- shell: bash | ||
working-directory: ${{ inputs.path }} | ||
name: Install Charmcraft | ||
id: install | ||
run: | | ||
if [ -x /snap/bin/charmcraft ]; then | ||
action=refresh | ||
else | ||
action=install | ||
fi | ||
if [ -n "${{ inputs.revision }}" ]; then | ||
echo "::notice::Using Charmcraft revision ${{ inputs.revision }}" | ||
sudo snap $action --revision=${{ inputs.revision }} --classic charmcraft | ||
else | ||
echo "::notice::Using Charmcraft from channel ${{ inputs.channel }}" | ||
sudo snap $action --channel=${{ inputs.channel }} --classic charmcraft | ||
fi | ||
echo "lxd=$(curl -sS --unix-socket /run/snapd.socket http://localhost/v2/snaps/lxd -X GET | jq -r .result.revision)" >> "$GITHUB_OUTPUT" | ||
echo "charmcraft=$(curl -sS --unix-socket /run/snapd.socket http://localhost/v2/snaps/charmcraft -X GET | jq -r .result.revision)" >> "$GITHUB_OUTPUT" | ||
branding: | ||
icon: package | ||
color: orange |
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