Skip to content

Commit

Permalink
Add OpenTofu example and update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Mar 26, 2024
1 parent 2a7937c commit 784b21c
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Examples tests
name: Examples terraform tests

on:
pull_request:
Expand All @@ -14,15 +14,15 @@ on:
workflow_dispatch:

jobs:
Examples_tests:
Examples_terraform_tests:
environment: test-eu-west-2
runs-on: [self-hosted, linux, eu-west-2]
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: outscale-dev/frieza-github-actions/frieza-clean@master
- uses: outscale/frieza-github-actions/frieza-clean@master
with:
access_key: ${{ secrets.OSC_ACCESS_KEY }}
secret_key: ${{ secrets.OSC_SECRET_KEY }}
Expand All @@ -35,7 +35,7 @@ jobs:
with:
terraform_wrapper: false
- name: Run Examples
run: make test-examples
run: make terraform-examples
env:
TF_VAR_access_key_id: ${{ secrets.OSC_ACCESS_KEY }}
TF_VAR_secret_key_id: ${{ secrets.OSC_SECRET_KEY }}
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/tofu_examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Examples tofu tests

on:
pull_request:
branches:
- master
paths:
- 'examples/**.tfvars'
- 'examples/**.tf'
- 'scripts/test-examples.sh'
- 'GNUmakefile'
schedule:
- cron: '30 22 * * *'
workflow_dispatch:

jobs:
Examples_tofu_tests:
environment: test-eu-west-2
runs-on: [self-hosted, linux, eu-west-2]
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: outscale/frieza-github-actions/frieza-clean@master
with:
access_key: ${{ secrets.OSC_ACCESS_KEY }}
secret_key: ${{ secrets.OSC_SECRET_KEY }}
region: ${{ secrets.OSC_REGION }}
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Setup OpenTofu
uses: opentofu/setup-opentofu@v1
with:
tofu_wrapper: false
- name: Run Examples
run: make tofu-examples
env:
TF_VAR_access_key_id: ${{ secrets.OSC_ACCESS_KEY }}
TF_VAR_secret_key_id: ${{ secrets.OSC_SECRET_KEY }}
TF_VAR_region: ${{ secrets.OSC_REGION }}
TF_VAR_image_id: ${{ secrets.OSC_OMI_EXEMPLE }}
10 changes: 7 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ test-locally:
"$(CURDIR)/scripts/local-test.sh" TestAccOthers_Volume_io1Type
"$(CURDIR)/scripts/local-test.sh" TestAccVM_withFlexibleGpuLink_basic

.PHONY: test-examples
test-examples:
@sh -c "'$(CURDIR)/scripts/test-examples.sh'"
.PHONY: terraform-examples
terraform-examples:
@sh -c "'$(CURDIR)/scripts/terraform-examples.sh'"

.PHONY: tofu-examples
tofu-examples:
@sh -c "'$(CURDIR)/scripts/tofu-examples.sh'"

.PHONY: test-integration
test-integration:
Expand Down
2 changes: 1 addition & 1 deletion examples/keypair/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/net/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/net_vm/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/public_load_balancer/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/public_vm/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/security_group/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/volumes/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/yunohost/outscale.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
outscale = {
source = "outscale/outscale"
version = ">= 0.2.0"
version = ">= 0.11.0"
}
}
}
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions scripts/tofu-examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

project_dir=$(cd "$(dirname $0)" && pwd)
project_root=$(cd $project_dir/.. && pwd)
EXAMPLES_DIR=$project_root/examples

go build -o terraform-provider-outscale

for f in $EXAMPLES_DIR/*
do
if [ -d $f ]
then
cd $f
VERSION_DIR=`grep -o '[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*' outscale.tf`
INSTALL_DIR=$f/terraform.d/providers/registry.opentofu.org/outscale/outscale/$VERSION_DIR/linux_amd64/
echo $INSTALL_DIR
mkdir -p $INSTALL_DIR
cp ../../terraform-provider-outscale $INSTALL_DIR
tofu init
tofu apply -auto-approve
tofu destroy -auto-approve
cd -
fi
done

exit 0

0 comments on commit 784b21c

Please sign in to comment.