-
-
Notifications
You must be signed in to change notification settings - Fork 159
128 lines (110 loc) · 3.28 KB
/
test-registry.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Test actions using registry
on:
- pull_request
permissions:
contents: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
registry_module:
runs-on: ubuntu-24.04
name: Use registry module
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Create dummy credential file
env:
RUNNER_TEMP_D: ${{ runner.temp }}
run: |
mkdir -p "$RUNNER_TEMP_D/_github_home"
cp tests/workflows/test-registry/terraformrc "$RUNNER_TEMP_D/_github_home/.terraformrc"
ls -la "$RUNNER_TEMP_D"
- name: Plan
uses: ./terraform-plan
env:
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }}
with:
path: tests/workflows/test-registry
label: test-registry registry_module
- name: Apply
uses: ./terraform-apply
id: output
with:
path: tests/workflows/test-registry
label: test-registry registry_module
env:
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }}
- name: Verify outputs
env:
WORD: ${{ steps.output.outputs.word }}
RUNNER_TEMP_D: ${{ runner.temp }}
run: |
if [[ "$WORD" != "hello" ]]; then
echo "::error:: output not set correctly"
exit 1
fi
# Check that terraformrc is as before
diff tests/workflows/test-registry/terraformrc "$RUNNER_TEMP_D/_github_home/.terraformrc"
multiple_registry_module:
runs-on: ubuntu-24.04
name: Multiple registries
permissions:
contents: read
pull-requests: write
env:
TERRAFORM_CLOUD_TOKENS: |
terraform.example.com = Registry doesn't exist
app.terraform.io = ${{ secrets.TF_API_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Plan
uses: ./terraform-plan
with:
path: tests/workflows/test-registry
label: test-registry multiple_registry_module
- name: Apply
uses: ./terraform-apply
id: output
with:
path: tests/workflows/test-registry
label: test-registry multiple_registry_module
- name: Verify outputs
env:
WORD: ${{ steps.output.outputs.word }}
run: |
if [[ "$WORD" != "hello" ]]; then
echo "::error:: output not set correctly"
exit 1
fi
nonsense_credentials:
runs-on: ubuntu-24.04
name: Nonsense cloud credentials
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Plan
uses: ./terraform-plan
id: plan
continue-on-error: true
env:
TERRAFORM_CLOUD_TOKENS: No thanks
with:
path: tests/workflows/test-registry
- name: Check failed
env:
OUTCOME: ${{ steps.plan.outcome }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "did not fail correctly with nonsense credentials"
exit 1
fi