Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
95 changes: 92 additions & 3 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,100 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: Add fake tag to make vergit happy
run: git tag v0.0.0
- uses: snapcore/action-build@v1
id: snapcraft
id: snap-build
with:
snapcraft-channel: "7.x"
- uses: actions/upload-artifact@v4
with:
name: charm.snap
path: ${{ steps.snapcraft.outputs.snap }}
name: charm-snap
path: ${{ steps.snap-build.outputs.snap }}

integration:
strategy:
matrix:
charmcraft_channel:
- "2.x/stable"
name: Integration test
needs: build
runs-on: ubuntu-latest
steps:
- name: Init LXD
run: |
set -euxo pipefail
sudo lxd init --auto
# This is a throw-away CI environment, do not do this at home
sudo chmod 666 /var/snap/lxd/common/lxd/unix.socket
# Fixup iptables forwarding issues from LXD containers with a flush and
# re-create of rules.
sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT
- name: Checkout layer-basic
uses: actions/checkout@v2
with:
repository: juju-solutions/layer-basic

- name: Download built charm snap
uses: actions/download-artifact@v4
with:
name: charm-snap
path: tests/charm-minimal/charm-snap

- name: Build reactive charm with charmcraft-2.x
if: ${{ matrix.charmcraft_channel == '2.x/stable' }}
run: |
set -euxo pipefail
sudo snap install --classic --channel ${{ matrix.charmcraft_channel }} charmcraft
cat << EOF | tee tests/charm-minimal/charmcraft.yaml
type: charm
parts:
charm-tools:
plugin: nil
override-build: |
ls -lR \$CRAFT_PROJECT_DIR/
snap install --dangerous --classic /root/project/charm-snap/charm_0.0.0_amd64.snap
rm -rf \$CRAFT_PROJECT_DIR/parts/charm/src/charm-snap
charm:
after: [charm-tools]
source: .
plugin: reactive
reactive-charm-build-arguments:
- -v
- --binary-wheels-from-source
- --ignore-requires-python
build-packages:
- python3-dev
- libpq-dev
bases:
- name: ubuntu
channel: "18.04"
architectures: [amd64]
- name: ubuntu
channel: "20.04"
architectures: [amd64]
- name: ubuntu
channel: "22.04"
architectures: [amd64]
EOF
charmcraft pack -p tests/charm-minimal -v
## action to interactively debug CI failures.
# - name: Setup upterm session
# if: failure()
# uses: lhotari/action-upterm@v1
- name: Upload charmcraft execution logs
if: always()
uses: actions/upload-artifact@v4
with:
name: charmcraft execution logs ${{ matrix.runs-on }}
path: ~/snap/charmcraft/common/cache/charmcraft/log/*.log
- name: Upload built charms
uses: actions/upload-artifact@v4
with:
name: Built charms
overwrite: true
path: |
minimal_ubuntu-18.04-amd64.charm
minimal_ubuntu-20.04-amd64.charm
minimal_ubuntu-22.04-amd64.charm
7 changes: 7 additions & 0 deletions charmtools/build/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,12 @@ def main(args=None):
help='Same as --binary-wheels but build all the '
'wheels from source code, even if a binary '
'distribution is available on PyPi.')
parser.add_argument('--ignore-requires-python', action='store_true',
default=False,
help='This flag instructs pip to bypass the '
'Requires-Python metadata specified by the package, '
'which typically indicates the Python versions it '
'officially supports.')
parser.add_argument('charm', nargs="?", default=".", type=path,
help='Source directory for charm layer to build '
'(default: .)')
Expand All @@ -1203,6 +1209,7 @@ def main(args=None):
WheelhouseTactic.per_layer = build.wheelhouse_per_layer
WheelhouseTactic.binary_build = build.binary_wheels
WheelhouseTactic.binary_build_from_source = build.binary_wheels_from_source
WheelhouseTactic.ignore_requires_python = build.ignore_requires_python

configLogging(build)

Expand Down
10 changes: 9 additions & 1 deletion charmtools/build/tactics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ class WheelhouseTactic(ExactMatch, Tactic):
per_layer = False
binary_build = False
binary_build_from_source = False
ignore_requires_python = False

def __init__(self, *args, **kwargs):
super(WheelhouseTactic, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -1113,13 +1114,20 @@ def _add(self, wheelhouse, *reqs):
with utils.tempdir(chdir=False) as temp_dir:
# put in a temp dir first to ensure we track all of the files
_no_binary_opts = ('--no-binary', ':all:')
_ignore_requires_python = ('--ignore-requires-python', )
if self.binary_build_from_source or self.binary_build:
self._pip('wheel',
*_no_binary_opts
if self.binary_build_from_source else tuple(),
*_ignore_requires_python
if self.ignore_requires_python else tuple(),
'-w', temp_dir, *reqs)
else:
self._pip('download', *_no_binary_opts, '-d', temp_dir, *reqs)
self._pip('download',
*_no_binary_opts,
*_ignore_requires_python
if self.ignore_requires_python else tuple(),
'-d', temp_dir, *reqs)
log.debug('Copying wheels:')
for wheel in temp_dir.files():
log.debug(' ' + wheel.name)
Expand Down
4 changes: 4 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ parts:
- git-core
- libssl-dev
- libffi-dev
- libpython3.6
- libpython3.6-minimal
- libpython3.6-stdlib
- libpython3-dev
- libpython3.6-dev
override-build: |
snapcraftctl build
pip3 install https://github.com/openstack-charmers/charm-templates-openstack/archive/master.zip#egg=charm_templates_openstack
Expand Down
Loading