2020-07-01 05:37:14 +02:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-03-16 07:18:18 +01:00
|
|
|
- main
|
2020-07-01 05:37:14 +02:00
|
|
|
- 'releases/*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build_test_job:
|
|
|
|
name: 'Build and test job'
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: 'Checking out repo code'
|
|
|
|
uses: actions/checkout@v1
|
|
|
|
|
|
|
|
- name: 'Run L0 tests'
|
|
|
|
run: |
|
2021-03-16 07:22:33 +01:00
|
|
|
npm install
|
2020-07-01 05:37:14 +02:00
|
|
|
npm run test
|
|
|
|
|
|
|
|
- name : 'Run test coverage'
|
2021-03-16 07:22:33 +01:00
|
|
|
if: runner.os == 'Windows' && (github.event.pull_request.base.ref == 'releases/v1' || github.event.pull_request.base.ref == 'main')
|
2020-07-01 05:37:14 +02:00
|
|
|
env:
|
|
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
|
|
|
$coverage_result = npm run test-coverage
|
|
|
|
$start = $false;
|
|
|
|
$middle = $false;
|
|
|
|
$end = $false;
|
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
foreach ($j in $coverage_result)
|
|
|
|
{
|
|
|
|
if ($j.tostring().startswith("----------"))
|
|
|
|
{
|
|
|
|
if (!$start)
|
|
|
|
{
|
|
|
|
$start = $true;
|
|
|
|
$start_index = $count
|
|
|
|
}
|
|
|
|
elseif (!$middle)
|
|
|
|
{
|
|
|
|
$middle = $true;
|
|
|
|
}
|
|
|
|
elseif (!$end)
|
|
|
|
{
|
|
|
|
$end = $true;
|
|
|
|
$end_index = $count
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$count++
|
|
|
|
}
|
|
|
|
|
|
|
|
$tbl_md = $coverage_result[($start_index+1)..($end_index-1)] -join "\n"
|
|
|
|
$summary = $coverage_result[($end_index + 1)..$count] -join "\n"
|
|
|
|
$comment = $tbl_md + "\n" + $summary
|
|
|
|
$url = "https://api.github.com/repos/${env:GITHUB_REPOSITORY}/issues/${env:PR_NUMBER}/comments"
|
|
|
|
$headers = @{
|
|
|
|
"Authorization" = "token ${env:GITHUB_TOKEN}"
|
|
|
|
}
|
|
|
|
$body = "{ `"body`": `"${comment}`" }"
|
2021-03-16 07:18:18 +01:00
|
|
|
Invoke-RestMethod -Method POST -Uri $url -Headers $headers -Body $body
|