PSRule-vscode/.github/workflows/build.yaml

165 строки
3.4 KiB
YAML

#
# CI Pipeline
#
# NOTES:
# This workflow builds and tests extension updates.
name: Build
on:
push:
branches: [main, 'release/*']
pull_request:
branches: [main, 'release/*']
workflow_dispatch: {}
permissions: {}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install dependencies
timeout-minutes: 3
run: |
npm install --global @vscode/vsce --force
npm install
dotnet restore
- name: Build extension
timeout-minutes: 3
run: |
mkdir -p out/package/
npm run package -- 0.0.1
- name: Upload extension
uses: actions/upload-artifact@v4
with:
name: Extension
path: out/package/code-*.vsix
retention-days: 3
if-no-files-found: error
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build
permissions:
contents: read
strategy:
# Get full test results from all platforms.
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
timeout-minutes: 3
run: |
npm install
- name: Configure environment
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: Run tests
timeout-minutes: 5
run: |
npm test
env:
DISPLAY: ':99.0'
oss:
name: Analyze with PSRule
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run PSRule analysis
uses: microsoft/ps-rule@v2.9.0
with:
modules: PSRule.Rules.MSFT.OSS
prerelease: true
devskim:
name: Analyze with DevSkim
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
with:
directory-to-scan: .
- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: devskim-results.sarif
codeql:
name: Analyze with CodeQL
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: typescript, csharp
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3