Skip to content

Commit

Permalink
chore: adds a TF testing workflow (#18)
Browse files Browse the repository at this point in the history
## what

- Adds a tf-test workflow for running terraform + tofu tests

## why

- This will ensure we're always running tests on each PR to make sure we
don't break anything

## references

- N/A
  • Loading branch information
Gowiem authored Dec 22, 2024
1 parent 3e385b2 commit 1cee9dc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"config:recommended",
"github>aquaproj/aqua-renovate-config#2.6.0"
],
"schedule": ["before 5am on Monday"],
// Schedule once a month on the first day of the month before 4 AM.
"schedule": ["* 0-3 1 * *"],
"baseBranches": ["main", "master"],
"labels": ["auto-upgrade"],
"dependencyDashboardAutoclose": true,
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/tf-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: TF Test

on:
push:
branches:
- main
pull_request:

env:
SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}

permissions:
actions: read
checks: write
contents: read
id-token: write
pull-requests: read

jobs:
tf-test:
name: ${{ matrix.tf }} Test
runs-on: ubuntu-latest
strategy:
matrix:
tf: [tofu, terraform]
steps:
- uses: actions/checkout@v4

- name: Aqua Cache
uses: actions/cache@v4.0.2
if: ${{ !github.event.act }} # Don't enable the cache step if we're using act for testing
with:
path: ~/.local/share/aquaproj-aqua
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
restore-keys: |
v1-aqua-installer-${{runner.os}}-${{runner.arch}}-
- name: Install Aqua
uses: aquaproj/aqua-installer@4551ec64e21bf0f557c2525135ff0bd2cba40ec7 # v3.0.0
with:
aqua_version: v2.25.2

- name: Aqua Install
shell: bash
run: aqua install --tags ${{ matrix.tf }}

- run: ${{ matrix.tf }} init
- run: ${{ matrix.tf }} test
2 changes: 2 additions & 0 deletions aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ registries:
packages:
- name: terraform-docs/terraform-docs@v0.19.0
- name: hashicorp/terraform@v1.10.3
tags: [terraform]
- name: opentofu/opentofu@v1.8.7
tags: [tofu]
- name: spacelift-io/spacectl@v1.8.0
4 changes: 4 additions & 0 deletions tests/main.tftest.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
provider "spacelift" {
api_key_endpoint = "https://masterpointio.app.spacelift.io"
}

variables {
root_modules_path = "./tests/fixtures"
common_config_file = "common.yaml"
Expand Down

0 comments on commit 1cee9dc

Please sign in to comment.