-
Notifications
You must be signed in to change notification settings - Fork 4.9k
98 lines (79 loc) · 2.59 KB
/
ci-javascript-samples.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
name: ci-javascript-samples
env:
ROOT_FOLDER: BotBuilder-Samples/samples/
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- "samples/**/*.js"
- "samples/**/*.ts"
jobs:
generate:
name: detect and generate bot matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: git diff
uses: technote-space/get-diff-action@v4
with:
PATTERNS: samples/**/*.+(ts|js)
ABSOLUTE: true
- name: generate matrix
id: set-matrix
shell: pwsh
if: env.GIT_DIFF
run: |
function UpSearchFolder {
param ([String] $path, [String] $file)
while ($path -and !(Test-Path (Join-Path $path $file))) {
$path = Split-Path $path -Parent
}
return $path
}
$paths = @("${{ env.GIT_DIFF_FILTERED }}" -replace "'", "" -split " ")
$rootFolder = "${{ env.ROOT_FOLDER }}"
$pkg = "package.json"
$result = $paths | ForEach-Object { UpSearchFolder -path $_ -file $pkg } | Get-Unique | ForEach-Object {
$folder = $_
$json = Get-Content -Raw -Path (Join-Path $folder $pkg) | ConvertFrom-Json
$files = @($paths | Where-Object { $_.StartsWith($folder) })
return @{
name = $folder.Substring($folder.IndexOf($rootFolder) + $rootFolder.Length);
scripts = @($json.scripts | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name);
folder = $folder;
files = $files
}
}
"Generated matrix:"
ConvertTo-Json @($result)
$matrix = ConvertTo-Json -Compress @($result)
echo "::set-output name=matrix::$($matrix)"
build:
needs: generate
runs-on: ubuntu-latest
strategy:
matrix:
include: ${{fromJSON(needs.generate.outputs.matrix)}}
fail-fast: false
name: bot - ${{ matrix.name }}
steps:
- uses: actions/checkout@v3
- name: use node 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: yarn install
run: yarn install
working-directory: ${{ matrix.folder }}
- name: yarn build
if: ${{ contains(matrix.scripts, 'build') }}
run: yarn build
working-directory: ${{ matrix.folder }}
- name: yarn lint
run: |
yarn eslint ${{ join(matrix.files, ' ') }}
working-directory: ${{ matrix.folder }}