Skip to content

Commit

Permalink
patch: Remove quotes in snap install if no flag passed (#88)
Browse files Browse the repository at this point in the history
A recent change to `snap install` causes commands such as `snap install
charmcraft ''` to fail.

Only add `''` if we're passing flags to `snap install`

Example failure:
https://github.com/canonical/spark-history-server-k8s-operator/actions/runs/6506459332/job/17672046098?pr=20#step:6:27
  • Loading branch information
carlcsaposs-canonical authored Oct 13, 2023
1 parent 92ff3b7 commit 3cc668d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_charm_without_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
# (shellcheck sees it as constant, but GitHub Actions expression is not constant between workflow runs)
if [[ '${{ steps.lxd-snap-version.outputs.install_flag }}' ]]
then
sudo snap refresh lxd '${{ steps.lxd-snap-version.outputs.install_flag }}'
sudo snap refresh lxd ${{ steps.lxd-snap-version.outputs.install_flag }}
fi
sudo adduser "$USER" lxd
# `newgrp` does not work in GitHub Actions; use `sg` instead
Expand All @@ -90,7 +90,7 @@ jobs:
sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT
sudo snap install charmcraft --classic '${{ steps.charmcraft-snap-version.outputs.install_flag }}'
sudo snap install charmcraft --classic ${{ steps.charmcraft-snap-version.outputs.install_flag }}
pipx install tox
pipx install poetry
- name: Pack charm
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_charms_with_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
# (shellcheck sees it as constant, but GitHub Actions expression is not constant between workflow runs)
if [[ '${{ steps.lxd-snap-version.outputs.install_flag }}' ]]
then
sudo snap refresh lxd '${{ steps.lxd-snap-version.outputs.install_flag }}'
sudo snap refresh lxd ${{ steps.lxd-snap-version.outputs.install_flag }}
fi
sudo adduser "$USER" lxd
# `newgrp` does not work in GitHub Actions; use `sg` instead
Expand All @@ -107,7 +107,7 @@ jobs:
sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT
sudo snap install charmcraft --classic '${{ steps.charmcraft-snap-version.outputs.install_flag }}'
sudo snap install charmcraft --classic ${{ steps.charmcraft-snap-version.outputs.install_flag }}
pipx install tox
pipx install poetry
- name: Get charmcraft version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
id: charmcraft-snap-version
run: parse-snap-version --revision='${{ inputs.charmcraft-snap-revision }}' --channel='${{ inputs.charmcraft-snap-channel }}' --revision-input-name=charmcraft-snap-revision --channel-input-name=charmcraft-snap-channel
- name: Install charmcraft
run: sudo snap install charmcraft --classic '${{ steps.charmcraft-snap-version.outputs.install_flag }}'
run: sudo snap install charmcraft --classic ${{ steps.charmcraft-snap-version.outputs.install_flag }}
- name: Checkout
uses: actions/checkout@v3
- name: Download charm package(s)
Expand Down
4 changes: 2 additions & 2 deletions python/cli/data_platform_workflows_cli/parse_snap_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def main():
assert (
not args.channel
), f"`{args.channel_input_name}` input cannot be used if `{args.revision_input_name}` input is passed"
output += f"--revision={args.revision}"
output += f"'--revision={args.revision}'"
elif args.channel:
output += f"--channel={args.channel}"
output += f"'--channel={args.channel}'"

print(output)
with open(os.environ["GITHUB_OUTPUT"], "a") as file:
Expand Down

0 comments on commit 3cc668d

Please sign in to comment.