Skip to content

Commit

Permalink
compatible: Prefer tox run -e build over charmcraft pack in build…
Browse files Browse the repository at this point in the history
… charm workflows

`tox run -e build` was added to support Poetry (and to version control poetry.lock instead of requirements.txt). Example: canonical/mysql-operator#192
  • Loading branch information
carlcsaposs-canonical committed Jul 21, 2023
1 parent 43a0280 commit 831a06e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build_charm_without_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ jobs:
sudo iptables -P FORWARD ACCEPT
sudo snap install charmcraft --classic
pipx install tox
pipx install poetry
- name: Pack charm
id: pack
working-directory: ${{ inputs.path-to-charm-directory }}
run: sg lxd -c "charmcraft pack"
run: |
if tox list --no-desc | grep --fixed-strings --line-regexp build
then
sg lxd -c "tox run -e build"
else
sg lxd -c "charmcraft pack"
fi
- name: Upload charmcraft logs
if: ${{ failure() && steps.pack.outcome == 'failure' }}
uses: actions/upload-artifact@v3
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/build_charms_with_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
sudo iptables -P FORWARD ACCEPT
sudo snap install charmcraft --classic
pipx install tox
pipx install poetry
- name: Get charmcraft version
id: charmcraft-version
# Major and minor versions (e.g. "2.1")
Expand All @@ -102,7 +104,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ~/ga-charmcraft-cache/**
key: charmcraft-pack-${{ matrix.charm.directory_path }}-${{ matrix.charm.bases_index }}-${{ steps.charmcraft-version.outputs.version }}-${{ hashFiles(format('{0}/charmcraft.yaml', matrix.charm.directory_path), format('{0}/requirements.txt', matrix.charm.directory_path)) }}
key: charmcraft-pack-${{ matrix.charm.directory_path }}-${{ matrix.charm.bases_index }}-${{ steps.charmcraft-version.outputs.version }}-${{ hashFiles(format('{0}/charmcraft.yaml', matrix.charm.directory_path), format('{0}/poetry.lock', matrix.charm.directory_path), format('{0}/requirements.txt', matrix.charm.directory_path)) }}
- name: Import cached containers
if: ${{ steps.restore-cache.outputs.cache-hit }}
run: |
Expand Down Expand Up @@ -134,7 +136,13 @@ jobs:
- name: Pack charm
id: pack
working-directory: ${{ matrix.charm.directory_path }}
run: sg lxd -c "charmcraft pack --bases-index='${{ matrix.charm.bases_index }}'"
run: |
if tox list --no-desc | grep --fixed-strings --line-regexp build
then
sg lxd -c "tox run -e build -- --bases-index='${{ matrix.charm.bases_index }}'"
else
sg lxd -c "charmcraft pack --bases-index='${{ matrix.charm.bases_index }}'"
fi
- name: Upload charmcraft logs
if: ${{ failure() && steps.pack.outcome == 'failure' }}
uses: actions/upload-artifact@v3
Expand Down

0 comments on commit 831a06e

Please sign in to comment.