-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (52 loc) · 2.22 KB
/
test-pr.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
name: "Test Latest Updated Templates"
on:
pull_request:
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
templates: ${{ steps.filter.outputs.changes }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
sap-cap-javascript-node: ./**/sap-cap-javascript-node/**
test:
needs: [detect-changes]
runs-on: ubuntu-latest
if: ${{ needs.detect-changes.outputs.templates != '[]' && needs.detect-changes.outputs.templates != '' }}
continue-on-error: true
strategy:
matrix:
template: ${{ fromJSON(needs.detect-changes.outputs.templates) }}
steps:
- uses: actions/checkout@v2
- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli
- name: "Generating tests for '${{ matrix.template }}'"
run: echo "${{ matrix.template }}"
- name: "Run smoke tests for '${{ matrix.template }}'"
run: |
set -e
cd src/${{ matrix.template }}
# Configure templates only if `devcontainer-template.json` contains the `options` property.
optionProp=( $(jq -r '.options' devcontainer-template.json) )
if [ "${optionProp}" != "" ] && [ "${optionProp}" != "null" ] ; then
options=( $(jq -r '.options | keys[]' devcontainer-template.json) )
if [ "${options[0]}" != "" ] && [ "${options[0]}" != "null" ] ; then
echo "(!) Configuring template options within 'src/${{ matrix.template }}' folder"
for option in "${options[@]}"
do
# Get default variant for current template
option_key="\${templateOption:$option}"
option_value=$(jq -r ".options | .${option} | .default" devcontainer-template.json)
if [ "${option_value}" = "" ] || [ "${option_value}" = "null" ] ; then
echo "Template '${{ matrix.template }}' is missing a default value for option '${option}'"
exit 1
fi
# Execute test for the default variant of that template
VARIANT="$option_value" ../../test/${{ matrix.template }}/test.sh
done
fi
fi