generated from brandonc/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (79 loc) · 2.91 KB
/
ci.yml
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
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
mockinfra:
runs-on: "ubuntu-latest"
name: "E2E Mock Infra"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: ./apply
id: run
with:
token: ${{ secrets.TFC_TOKEN }}
organization: ${{ secrets.TFC_ORGANIZATION }}
# The workspace is set up to use .github/workspace/main.tf in the main branch
workspace: test-terraform-cloud-action
replace-addrs: null_resource.example
e2e:
runs-on: "ubuntu-latest"
name: "E2E Test Outputs"
needs: [ mockinfra ]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Fetch outputs
id: fetch
uses: ./outputs
with:
token: ${{ secrets.TFC_TOKEN }}
organization: ${{ secrets.TFC_ORGANIZATION }}
workspace: test-terraform-cloud-action
- name: Assertions
env:
JSON_DATA: ${{ steps.fetch.outputs.workspace-outputs-json }}
run: |
[[ $(jq -n "$JSON_DATA" | jq .number -re) = "3.14159" ]] && echo PASS || (echo FAIL && exit 1)
[[ $(jq -n "$JSON_DATA" | jq .string -re) = "string" ]] && echo PASS || (echo FAIL && exit 1)
[[ $(jq -n "$JSON_DATA" | jq .tuple[0] -re) = "hello" ]] && echo PASS || (echo FAIL && exit 1)
[[ $(jq -n "$JSON_DATA" | jq .tuple[1] -re) = "list" ]] && echo PASS || (echo FAIL && exit 1)
[[ $(jq -n "$JSON_DATA" | jq .object.hello -re) = "object" ]] && echo PASS || (echo FAIL && exit 1)
echo "The following lines should be redacted! (You should see *** and nothing else)"
jq -n "$JSON_DATA" | jq .secretobject.hello[0] -re
jq -n "$JSON_DATA" | jq .secretobject.hello[1] -re
jq -n "$JSON_DATA" | jq .secretstring -re
destroy-infra:
runs-on: ubuntu-latest
name: E2E Destroy Infra
needs: [ e2e ]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Destroy mock infra
uses: ./destroy
with:
token: ${{ secrets.TFC_TOKEN }}
organization: ${{ secrets.TFC_ORGANIZATION }}
workspace: test-terraform-cloud-action
wait: true # default is false
lint-test:
runs-on: "ubuntu-latest"
name: "Lint & Test"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
cache: npm
- name: npm ci
run: npm ci
- name: Format Check
run: npm run format-check
- name: Verify
run: |
npm run build
# Fail if "npm run build" generated new changes in dist
git update-index --refresh dist/**/* && git diff-index --quiet HEAD dist
- name: Test
run: npm run test