Skip to content

Commit

Permalink
Merge pull request #71 from fabiomatavelli/feature/update-sdk
Browse files Browse the repository at this point in the history
Update SDKs
  • Loading branch information
kiranchavala committed Jun 21, 2024
2 parents e4c9861 + 8e2b79f commit 05dc88b
Show file tree
Hide file tree
Showing 104 changed files with 1,093 additions and 1,074 deletions.
135 changes: 135 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Acceptance Test

on:
pull_request:
paths:
- .github/workflows/acceptance.yml
- '**.go'
push:
paths:
- .github/workflows/acceptance.yml
- '**.go'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-acceptance
cancel-in-progress: true

permissions:
contents: read

env:
CLOUDSTACK_API_URL: http://localhost:8080/client/api
CLOUDSTACK_VERSIONS: "['4.18.2.0', '4.19.0.1']"

jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
cloudstack-versions: ${{ steps.set-versions.outputs.cloudstack-versions }}
steps:
- name: Set versions
id: set-versions
run: |
echo "cloudstack-versions=${{ env.CLOUDSTACK_VERSIONS }}" >> $GITHUB_OUTPUT
acceptance-terraform:
name: Terraform ${{ matrix.terraform-version }} with Cloudstack ${{ matrix.cloudstack-version }}
needs: [prepare-matrix]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Configure Cloudstack v${{ matrix.cloudstack-version }}
uses: ./.github/workflows/setup-cloudstack
id: setup-cloudstack
with:
cloudstack-version: ${{ matrix.cloudstack-version }}
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Run acceptance test
env:
CLOUDSTACK_USER_ID: ${{ steps.setup-cloudstack.outputs.CLOUDSTACK_USER_ID }}
CLOUDSTACK_API_KEY: ${{ steps.setup-cloudstack.outputs.CLOUDSTACK_API_KEY }}
CLOUDSTACK_SECRET_KEY: ${{ steps.setup-cloudstack.outputs.CLOUDSTACK_SECRET_KEY }}
run: |
make testacc
services:
cloudstack-simulator:
image: apache/cloudstack-simulator:${{ matrix.cloudstack-version }}
ports:
- 8080:5050
strategy:
fail-fast: false
matrix:
terraform-version:
- '1.7.*'
- '1.8.*'
cloudstack-version: ${{ fromJson(needs.prepare-matrix.outputs.cloudstack-versions) }}

acceptance-opentofu:
name: OpenTofu ${{ matrix.opentofu-version }} with Cloudstack ${{ matrix.cloudstack-version }}
needs: [prepare-matrix]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Configure Cloudstack v${{ matrix.cloudstack-version }}
uses: ./.github/workflows/setup-cloudstack
id: setup-cloudstack
with:
cloudstack-version: ${{ matrix.cloudstack-version }}
- uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ matrix.opentofu-version }}
- name: Run acceptance test
env:
CLOUDSTACK_USER_ID: ${{ steps.setup-cloudstack.outputs.CLOUDSTACK_USER_ID }}
CLOUDSTACK_API_KEY: ${{ steps.setup-cloudstack.outputs.CLOUDSTACK_API_KEY }}
CLOUDSTACK_SECRET_KEY: ${{ steps.setup-cloudstack.outputs.CLOUDSTACK_SECRET_KEY }}
run: |
make testacc
services:
cloudstack-simulator:
image: apache/cloudstack-simulator:${{ matrix.cloudstack-version }}
ports:
- 8080:5050
strategy:
fail-fast: false
matrix:
opentofu-version:
- '1.6.*'
cloudstack-version: ${{ fromJson(needs.prepare-matrix.outputs.cloudstack-versions) }}

all-jobs-passed: # Will succeed if it is skipped
runs-on: ubuntu-latest
needs: [acceptance-terraform, acceptance-opentofu]
# Only run if any of the previous jobs failed
if: ${{ failure() }}
steps:
- name: Previous jobs failed
run: exit 1
29 changes: 14 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,24 @@ on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
- name: Build
run: |
make build
- name: Test
run: make test
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'

- name: Build
run: |
make build
- name: Test
run: make test
83 changes: 83 additions & 0 deletions .github/workflows/setup-cloudstack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Setup Cloudstack

inputs:
cloudstack-version:
description: 'Cloudstack version'
required: true
outputs:
CLOUDSTACK_USER_ID:
description: 'Cloudstack user id'
value: ${{ steps.setup-cloudstack.outputs.user_id }}
CLOUDSTACK_API_KEY:
description: 'Cloudstack api key'
value: ${{ steps.setup-cloudstack.outputs.api_key }}
CLOUDSTACK_SECRET_KEY:
description: 'Cloudstack secret key'
value: ${{ steps.setup-cloudstack.outputs.secret_key }}
CLOUDSTACK_API_URL:
description: 'Cloudstack API URL'
value: http://localhost:8080/client/api

runs:
using: composite
steps:
- name: Wait Cloudstack to be ready
shell: bash
run: |
echo "Starting Cloudstack health check"
T=0
until [ $T -gt 20 ] || curl -sfL http://localhost:8080 --output /dev/null
do
echo "Waiting for Cloudstack to be ready..."
((T+=1))
sleep 30
done
- name: Setting up Cloudstack
id: setup-cloudstack
shell: bash
run: |
docker exec $(docker container ls --format=json -l | jq -r .ID) python /root/tools/marvin/marvin/deployDataCenter.py -i /root/setup/dev/advanced.cfg
curl -sf --location "${CLOUDSTACK_API_URL}" \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'command=login' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=password' \
--data-urlencode 'response=json' \
--data-urlencode 'domain=/' -j -c cookies.txt --output /dev/null
CLOUDSTACK_USER_ID=$(curl -fs "${CLOUDSTACK_API_URL}?command=listUsers&response=json" -b cookies.txt | jq -r '.listusersresponse.user[0].id')
CLOUDSTACK_API_KEY=$(curl -s "${CLOUDSTACK_API_URL}?command=getUserKeys&id=${CLOUDSTACK_USER_ID}&response=json" -b cookies.txt | jq -r '.getuserkeysresponse.userkeys.apikey')
CLOUDSTACK_SECRET_KEY=$(curl -fs "${CLOUDSTACK_API_URL}?command=getUserKeys&id=${CLOUDSTACK_USER_ID}&response=json" -b cookies.txt | jq -r '.getuserkeysresponse.userkeys.secretkey')
echo "::add-mask::$CLOUDSTACK_API_KEY"
echo "::add-mask::$CLOUDSTACK_SECRET_KEY"
echo "user_id=$CLOUDSTACK_USER_ID" >> $GITHUB_OUTPUT
echo "api_key=$CLOUDSTACK_API_KEY" >> $GITHUB_OUTPUT
echo "secret_key=$CLOUDSTACK_SECRET_KEY" >> $GITHUB_OUTPUT
- name: Install CMK
shell: bash
run: |
curl -sfL https://github.com/apache/cloudstack-cloudmonkey/releases/download/6.3.0/cmk.linux.x86-64 -o /usr/local/bin/cmk
chmod +x /usr/local/bin/cmk
- name: Create extra resources
shell: bash
run: |
cmk -u $CLOUDSTACK_API_URL -k $CLOUDSTACK_API_KEY -s $CLOUDSTACK_SECRET_KEY -o json create project name=terraform displaytext=terraform
93 changes: 0 additions & 93 deletions .github/workflows/testacc.yml

This file was deleted.

Loading

0 comments on commit 05dc88b

Please sign in to comment.