diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index 0988c75e..93188fa1 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -19,18 +19,19 @@ defaults: jobs: build-rock: runs-on: ubuntu-latest - outputs: - rock: ${{ steps.rockcraft.outputs.rock }} steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Setup LXD + uses: canonical/setup-lxd@v0.1.1 + with: + channel: 5.21/edge - name: Prepare Rock - uses: canonical/craft-actions/rockcraft-pack@main - id: rockcraft + run: ./scripts/test-helper.sh build_rock - uses: actions/upload-artifact@v3 with: name: rock - path: ${{ steps.rockcraft.outputs.rock }} + path: ceph.rock CephAdmScriptTest: runs-on: ubuntu-latest diff --git a/.github/workflows/publish_edge.yaml b/.github/workflows/publish_edge.yaml index 47f4fba6..db335fbc 100644 --- a/.github/workflows/publish_edge.yaml +++ b/.github/workflows/publish_edge.yaml @@ -14,8 +14,6 @@ jobs: runs-on: ubuntu-22.04 permissions: packages: write - outputs: - rock: ${{ steps.rockcraft.outputs.rock }} steps: - name: Check out the repo uses: actions/checkout@v3 @@ -23,7 +21,7 @@ jobs: - name: Setup LXD uses: canonical/setup-lxd@v0.1.1 with: - channel: 5.20/stable + channel: 5.21/edge - name: Install deps and clean legacy rules. run: | @@ -59,19 +57,10 @@ jobs: type=raw,value=dev-edge,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - name: Prepare Rock - uses: canonical/craft-actions/rockcraft-pack@main - id: rockcraft + run: ./scripts/test-helper.sh build_rock - name: Load to Docker daemon - run: | - # iterate through the tags - for tag in $TAGS; do - echo "$tag" - skopeo --insecure-policy copy oci-archive:${{ steps.rockcraft.outputs.rock }} docker-daemon:$tag - done - docker image ls -a - sleep 10 - docker push ghcr.io/canonical/ceph --all-tags + run: ./scripts/test-helper.sh load_to_docker $TAGS env: TAGS: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/publish_hotfix.yaml b/.github/workflows/publish_hotfix.yaml index 90435801..a0cad4a4 100644 --- a/.github/workflows/publish_hotfix.yaml +++ b/.github/workflows/publish_hotfix.yaml @@ -12,8 +12,6 @@ jobs: runs-on: ubuntu-22.04 permissions: packages: write - outputs: - rock: ${{ steps.rockcraft.outputs.rock }} steps: - run: | echo Publishing container image for PR# $NUMBER @@ -34,7 +32,7 @@ jobs: - name: Setup LXD uses: canonical/setup-lxd@v0.1.1 with: - channel: 5.20/stable + channel: 5.21/edge - name: Install deps and clean legacy rules. run: | @@ -70,19 +68,10 @@ jobs: type=raw,value=hotfix-${{ github.event.pull_request.number }}-${{ steps.versioning.outputs.ceph_version }} - name: Prepare Rock - uses: canonical/craft-actions/rockcraft-pack@main - id: rockcraft + run: ./scripts/test-helper.sh build_rock - name: Load to Docker daemon - run: | - # iterate through the tags - for tag in $TAGS; do - echo "$tag" - skopeo --insecure-policy copy oci-archive:${{ steps.rockcraft.outputs.rock }} docker-daemon:$tag - done - docker image ls -a - sleep 10 - docker push ghcr.io/canonical/ceph --all-tags + run: ./scripts/test-helper.sh load_to_docker $TAGS env: TAGS: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/publish_release.yaml b/.github/workflows/publish_release.yaml index 2fedfb63..4058655b 100644 --- a/.github/workflows/publish_release.yaml +++ b/.github/workflows/publish_release.yaml @@ -13,8 +13,6 @@ jobs: runs-on: ubuntu-22.04 permissions: packages: write - outputs: - rock: ${{ steps.rockcraft.outputs.rock }} steps: - name: Check out the repo uses: actions/checkout@v3 @@ -22,7 +20,7 @@ jobs: - name: Setup LXD uses: canonical/setup-lxd@v0.1.1 with: - channel: 5.20/stable + channel: 5.21/edge - name: Install deps and clean legacy rules. run: | @@ -60,18 +58,9 @@ jobs: type=raw,value=reef,enable=${{ startsWith(steps.versioning.outputs.ceph_version, '18') }} - name: Prepare Rock - uses: canonical/craft-actions/rockcraft-pack@main - id: rockcraft + run: ./scripts/test-helper.sh build_rock - name: Load to Docker daemon - run: | - # iterate through the tags - for tag in $TAGS; do - echo "$tag" - skopeo --insecure-policy copy oci-archive:${{ steps.rockcraft.outputs.rock }} docker-daemon:$tag - done - docker image ls -a - sleep 10 - docker push ghcr.io/canonical/ceph --all-tags + run: ./scripts/test-helper.sh load_to_docker $TAGS env: TAGS: ${{ steps.meta.outputs.tags }} diff --git a/rockcraft.yaml b/rockcraft.yaml index 6646be18..c15041b5 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -71,6 +71,7 @@ parts: - python3-natsort - sharutils - lsof + - python3-onelogin-saml2 kubectl: plugin: go diff --git a/scripts/test-helper.sh b/scripts/test-helper.sh new file mode 100755 index 00000000..38d590a5 --- /dev/null +++ b/scripts/test-helper.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -xeEo pipefail + + +function build_rock() { + sudo snap install rockcraft --classic + rockcraft clean + rockcraft pack -v + mv ceph*.rock ceph.rock +} + +function load_to_docker() { + local tags=${1:?missing} + # iterate through the tags + for tag in $tags; do + echo "$tag" + skopeo --insecure-policy copy oci-archive:ceph.rock docker-daemon:$tag + done + # Check all images + docker image ls -a + sleep 10 + docker push ghcr.io/canonical/ceph --all-tags +} + + + +FUNCTION="$1" +shift # remove function arg now that we've recorded it +# call the function with the remainder of the user-provided args +# -e, -E, and -o=pipefail will ensure this script returns a failure if a part of the function fails +$FUNCTION "$@"