diff --git a/.github/workflows/build-snap.yml b/.github/workflows/build-snap.yml index bc944d7..eb2c125 100644 --- a/.github/workflows/build-snap.yml +++ b/.github/workflows/build-snap.yml @@ -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 diff --git a/charmtools/build/builder.py b/charmtools/build/builder.py index c339cdc..426cf8a 100755 --- a/charmtools/build/builder.py +++ b/charmtools/build/builder.py @@ -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: .)') @@ -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) diff --git a/charmtools/build/tactics.py b/charmtools/build/tactics.py index 42fb2a1..4ea5c40 100644 --- a/charmtools/build/tactics.py +++ b/charmtools/build/tactics.py @@ -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) @@ -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) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 6fc72a2..a9e7499 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -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