-
Notifications
You must be signed in to change notification settings - Fork 17
159 lines (152 loc) · 4.91 KB
/
wing-sdk.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Wing SDK Tests
on:
push:
paths-ignore:
- '**/*.md'
branches: [ main ]
pull_request:
branches: [ main ]
repository_dispatch:
types: [ feedreader ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env:
AWS_REGION : "us-east-1"
WING_DISABLE_ANALYTICS: 1
DEBUG: "wing:*"
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get list of directories
id: setdirs
shell: bash
run: |
dirs=$(ls -d examples/*/ | sed 's/\/$//' | grep -v "provider-specific" | jq -R -s -c 'split("\n")[:-1]')
processed_dirs=$(echo "{ \"directory\": $dirs }" | jq -c '[ .directory[] | {directory: ., name: (split("/") | last)}]')
wrapped_dirs=$(echo "{ \"example\": $processed_dirs }" | jq -c .)
echo "DIRS=$wrapped_dirs" >> $GITHUB_ENV
- name: Pass environment variable to output
id: passenv
run: |
echo "::set-output name=dirs::$DIRS"
outputs:
examples: ${{ steps.passenv.outputs.dirs }}
test:
needs: setup
runs-on: ubuntu-latest
strategy:
max-parallel: 6
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.examples) }}
name: ${{ matrix.example.name }} (Simulator)
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node.js v18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install winglang globally
run: |
npm install -g winglang@latest
wing --version
- name: Check for package.json file
run: |
if [[ -f "${{ matrix.example.directory }}/package.json" ]]; then
cd ${{ matrix.example.directory }}
npm install
fi
- name: Check for setup.sh file
run: |
if [[ -f "${{ matrix.example.directory }}/setup.sh" ]]; then
cd ${{ matrix.example.directory }}
./setup.sh
fi
- name: Create ~/.wing/secrets.json
run: |
mkdir -p ~/.wing
echo '{}' > ~/.wing/secrets.json
- name: Execute wing test in matrix directory
run: |
cd ${{ matrix.example.directory }}
if [ -f "main.w" ]; then
wing test --debug --platform sim main.w
elif [ -f "main.ts" ]; then
wing test --debug --platform sim main.ts
else
echo "No main.w or main.ts found"
exit 1
fi
test-tf-aws:
needs: setup
runs-on: ubuntu-latest
strategy:
max-parallel: 6
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.examples) }}
name: ${{ matrix.example.name }} (AWS)
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Check for skip.ci file
id: check_skip
run: |
if [[ -f "${{ matrix.example.directory }}/skip.ci.aws" ]]; then
echo "skip.ci file detected. Skipping job."
echo "skip=true" >> $GITHUB_ENV
else
echo "skip=false" >> $GITHUB_ENV
fi
- name: Setup Node.js v18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install winglang globally
if: env.skip == 'false'
run: |
npm install -g winglang@latest
wing --version
- name: Check for package.json file
run: |
if [[ -f "${{ matrix.example.directory }}/package.json" ]]; then
cd ${{ matrix.example.directory }}
npm install
fi
- name: Check for setup.sh file
run: |
if [[ -f "${{ matrix.example.directory }}/setup.sh" ]]; then
cd ${{ matrix.example.directory }}
./setup.sh
fi
- name: Configure AWS credentials
if: env.skip == 'false'
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: gh-actions-winglang-examples
aws-region: ${{ env.AWS_REGION }}
- name: Execute wing test in matrix directory
if: env.skip == 'false'
env:
TF_LOG: info
TF_LOG_PATH: ${{ runner.workspace }}/terraform.log
run: |
cd ${{ matrix.example.directory }}
if [ -f "main.w" ]; then
wing test --debug --no-analytics --no-update-check --platform tf-aws main.w
elif [ -f "main.ts" ]; then
wing test --debug --no-analytics --no-update-check --platform tf-aws main.ts
else
echo "No main.w or main.ts found"
exit 1
fi
- name: Output Terraform log
if: failure()
run: cat ${{ runner.workspace }}/terraform.log