-
-
Notifications
You must be signed in to change notification settings - Fork 13
86 lines (76 loc) · 2.91 KB
/
tf_tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
name: TF Tests
on:
pull_request:
paths: [.github/workflows/tf_tests.yaml, action.yml, tests/**]
types: [opened, reopened, synchronize, closed]
jobs:
tests:
runs-on: ubuntu-24.04
permissions:
actions: read # Required to download repository artifact.
checks: write # Required to add status summary.
contents: read # Required to checkout repository.
pull-requests: write # Required to add PR comment and label.
strategy:
fail-fast: false
matrix:
test:
- pass_one
# - pass_character_limit
# - fail_data_source_error
# - fail_format_diff
# - fail_invalid_resource_type
steps:
- name: Echo context
env:
GH_JSON: ${{ toJson(github) }}
run: echo "$GH_JSON"
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Setup TF
uses: opentofu/setup-opentofu@12f4debbf681675350b6cd1f0ff8ecfbda62027b # v1.0.4
with:
tofu_version: 1.8.5
tofu_wrapper: false
- name: Provision TF
id: tf
continue-on-error: true
uses: ./
with:
command: init # ${{ github.event.pull_request.merged && 'apply' || 'plan' }}
arg-lock: false # ${{ github.event.pull_request.merged }}
working-directory: tests/${{ matrix.test }}
tool: tofu
# format: true
# validate: true
- name: Echo TF
run: |
echo "check-id: ${{ steps.tf.outputs.check-id }}"
echo "command: ${{ steps.tf.outputs.command }}"
echo "comment-id: ${{ steps.tf.outputs.comment-id }}"
echo "diff: ${{ steps.tf.outputs.diff }}"
echo "exitcode: ${{ steps.tf.outputs.exitcode }}"
echo "identifier: ${{ steps.tf.outputs.identifier }}"
echo "job-id: ${{ steps.tf.outputs.job-id }}"
echo "plan-id: ${{ steps.tf.outputs.plan-id }}"
echo "plan-url: ${{ steps.tf.outputs.plan-url }}"
echo "result: ${{ steps.tf.outputs.result }}"
echo "run-url: ${{ steps.tf.outputs.run-url }}"
echo "summary: ${{ steps.tf.outputs.summary }}"
- name: Parse plan-file artifact
env:
PLAN_FILE: ${{ steps.tf.outputs.identifier }}
run: |
echo "Get artifact ID for $PLAN_FILE"
artifact_id=$(gh api /repos/{owner}/{repo}/actions/artifacts --method GET --field "name=$PLAN_FILE" --jq '.artifacts[0].id')
echo "Download artifact zip"
gh api /repos/{owner}/{repo}/actions/artifacts/${artifact_id}/zip --method GET > "$PLAN_FILE.zip"
echo "Unzip artifact"
unzip "$PLAN_FILE.zip" -d "tests/${{ matrix.test }}"
# Change directory to plan-file
cd "tests/${{ matrix.test }}"
echo "Show plan"
tofu show "tfplan"