Skip to content

Commit

Permalink
Build charms before running the integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Dec 12, 2023
1 parent a9f8cb5 commit ed91516
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/build-charm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

name: Build Charms

on:
workflow_call:
inputs:
runs-on:
type: string
description: Image runner for building the images
default: ubuntu-22.04
working-directory:
type: string
description: The working directory for jobs
default: "./"

jobs:
build-charms:
name: Build and push charms
runs-on: ${{ inputs.runs-on }}
steps:
- uses: actions/[email protected]
- uses: canonical/[email protected]
- name: Extract charm name
working-directory: ${{ inputs.working-directory }}
run: echo "CHARM_NAME=$([ -f metadata.yaml ] && yq '.name' metadata.yaml || echo UNKNOWN)" >> $GITHUB_ENV
- name: Pack charm
if: ${{ env.CHARM_NAME != 'UNKNOWN' && !cancelled() }}
working-directory: ${{ inputs.working-directory }}/${{ matrix.path }}
run: |
sudo snap install charmcraft --classic --channel latest/stable
charmcraft pack -v
echo "CHARM_FILE=$(ls ${{matrix.name}}_*.charm)" >> $GITHUB_ENV
- name: Upload charm artifact
if: ${{ env.CHARM_NAME != 'UNKNOWN' && !cancelled() }}
uses: actions/upload-artifact@v3
with:
name: charm-artifacts
path: ${{ inputs.working-directory }}/${{ env.CHARM_FILE }}
if-no-files-found: error
12 changes: 11 additions & 1 deletion .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ on:
pull_request:

jobs:
build-all-charms:
strategy:
matrix:
path:
- "./charms/k8s/"
- "./charms/k8s-worker/"
uses: ./.github/workflows/build-charm.yaml
with:
working-directory: ${{ matrix.path }}
integration-tests:
uses: addyess/operator-workflows/.github/workflows/integration_test.yaml@integration/multi-charm-artifacts
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
needs: [build-all-charms]
secrets: inherit
with:
provider: lxd
Expand Down

0 comments on commit ed91516

Please sign in to comment.