Skip to content

Bump step-security/harden-runner from 2.9.0 to 2.9.1 #441

Bump step-security/harden-runner from 2.9.0 to 2.9.1

Bump step-security/harden-runner from 2.9.0 to 2.9.1 #441

Workflow file for this run

on:
pull_request:
branches:
- master
push:
jobs:
build_test_job:
name: 'Build and test job'
permissions:
issues: write
pull-requests: write
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- name: 'Checking out repo code'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: cleanup node_modules
shell: pwsh
run: |
if (Test-Path -Path node_modules) {
Remove-Item -Path node_modules -Recurse -Force
}
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 16
- name: 'Validate build'
run: |
npm install
npm run build
- name: 'Run L0 tests'
run: |
npm run test
- name : 'Run test coverage'
if: runner.os == 'Windows' && github.event_name == 'pull_request'
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh # help actionlinter to distinguish the correct shell being used
run: |
$coverage_result = npm run 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;
$middle_index = $count
}
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}"
}
Invoke-RestMethod -Method POST -Uri $url -Headers $headers -Body "{ `"body`": `"${comment}`" }"
test_action_job:
name: 'Execute the local action'
runs-on: ${{ matrix.os }}
needs: build_test_job
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- name: 'Checking out repo code'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Test the local action
uses: ./ # Uses an action in the root directory
with:
files: './src/Tests/Resources/test.json'
env:
ID: "Value from workflow"
glossary.GlossDiv.GlossList.GlossEntry.ID: "Value from workflow"
glossary.title: "Fake title"
- name: Validate the test file
shell: pwsh
run: |
$test_file = Get-Content -Path src\Tests\Resources\test.json -Raw
Write-Host $test_file