From 1a66e881c7b7745ca2e185f92d0f23ee7c736d7b Mon Sep 17 00:00:00 2001 From: Joseph Sirianni Date: Sat, 15 Jun 2024 14:08:52 -0400 Subject: [PATCH] Test against v1.59.0 (#25) * Test against v1.59.0 * setup orgs when 1.59.0 or newer * debug * debug * do not fail fast * pass version as arg --- .github/workflows/ci.yml | 11 +++------ .github/workflows/scripts/init.sh | 41 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) create mode 100755 .github/workflows/scripts/init.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cd0c16..ba4fc29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,7 @@ jobs: test: runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: # This matrix allows us to test multiple bindplane versions. # When writing back to the repo, we write to directories based @@ -76,6 +77,7 @@ jobs: - 1.56.0 - 1.57.0 - 1.58.0 + - 1.59.0 # organizations and projects - latest # keep steps: - name: Checkout @@ -127,19 +129,14 @@ jobs: env: BINDPLANE_LICENSE: ${{ secrets.BINDPLANE_LICENSE }} - - name: Init BindPlane Account + - name: Init BindPlane Account or Organization uses: nick-fields/retry@v2 with: timeout_minutes: 1 polling_interval_seconds: 2 max_attempts: 3 shell: bash - command: | - curl -kv \ - -u admin:admin https://localhost:3001/v1/accounts \ - -X POST -d '{"displayName": "init"}' -v \ - --key step/bindplane.key \ - --cert step/bindplane.crt + command: .github/workflows/scripts/init.sh ${{ matrix.bindplane_versions }} - name: Run BindPlane Action # This should be replaced with a release action. diff --git a/.github/workflows/scripts/init.sh b/.github/workflows/scripts/init.sh new file mode 100755 index 0000000..dc8ca98 --- /dev/null +++ b/.github/workflows/scripts/init.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# This script initializes the BindPlane API with an organization or account +# depending on the version. Pre 1.59.0 was account based, post 1.59.0 is +# organization based. + +set -ex + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +BINDPLANE_VERSION=$1 +ORGS=false + +echo "Initializing BindPlane $BINDPLANE_VERSION" + +if [[ $(printf '%s\n' "$BINDPLANE_VERSION" "1.58.0" | sort -V | head -n1) == "1.58.0" && "$BINDPLANE_VERSION" != "1.58.0" ]]; then + ORGS=true +elif [[ "$BINDPLANE_VERSION" == "latest" ]]; then + ORGS=true +fi + +if [[ $ORGS == "true" ]]; then + curl -v -k \ + -u admin:admin \ + https://localhost:3001/v1/organizations \ + -X POST \ + -d '{"organizationName": "init", "accountName": "project", "eulaAccepted":true}' \ + --key step/bindplane.key \ + --cert step/bindplane.crt +else + curl -v -k \ + -u admin:admin \ + https://localhost:3001/v1/accounts \ + -X POST \ + -d '{"displayName": "init"}' \ + --key step/bindplane.key \ + --cert step/bindplane.crt +fi