-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (116 loc) · 3.96 KB
/
check-code.yml
File metadata and controls
116 lines (116 loc) · 3.96 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
name: Checks
on:
pull_request:
paths:
- '**.ts*'
- '**.js*'
- '**eslint*'
- 'dist/**'
- 'src/**'
- '__tests__/**'
- 'action.yml'
- '.github/workflows/check-code.yml'
jobs:
eslint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
run: npm clean-install; npm install @microsoft/eslint-formatter-sarif
- name: Run ESLint
run: npx eslint . --format @microsoft/eslint-formatter-sarif --output-file lint.sarif
- name: Print Output
if: always()
run: cat lint.sarif
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: lint.sarif
check-dist:
name: Check dist/
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
run: npm clean-install
- name: Build dist/ Directory
run: npm run package
- name: Compare Expected and Actual Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
- uses: actions/upload-artifact@v4
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
jest:
name: Jest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Package
run: npm clean-install
- name: Run Jest
run: npm run test
gha:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
run:
- {linter: 'flake8', format: 'flake8', regex: '', levelMap: '', analysisPath: '.'}
- {linter: 'mypy', format: 'mypy', regex: '', levelMap: '', analysisPath: '.'}
- {linter: 'pylint', format: 'pylint', regex: '', levelMap: '', analysisPath: '.'}
- {linter: 'mdl', format: 'mdl', regex: '', levelMap: '', analysisPath: '.'}
- {linter: 'yamllint', format: 'yamllint', regex: '', levelMap: '', analysisPath: '.'}
- {linter: 'ghalint', format: 'ghalint', regex: '', levelMap: '', analysisPath: '.'}
- {linter: 'sarif', format: 'sarif', regex: '', levelMap: '', analysisPath: '.'}
- {linter: 'flake8subpath', format: 'flake8', regex: '', levelMap: '', analysisPath: 'A\B'}
- linter: 'custom'
format: ''
# yamllint disable-line rule:line-length
regex: '^(?<path>[^-\n]+)(?:-(?<line>\d+))?(?:-(?<col>\d+))?(?:-(?<eline>\d+))?(?:-(?<ecol>\d+))? (?<level>[^:\s]+):(?<id>[^:\s]+):(?<sym>[^:\s]+) (?<msg>.+)$'
levelMap: '{ "err": "error", "warn": "warning", "info": "note" }'
analysisPath: '.'
name: GitHub Action (${{ matrix.run.linter }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
run: npm install -g json-diff
- name: Run Action
uses: ./
with:
inputFile: '__tests__/${{ matrix.run.linter }}.input.txt'
toolName: 'test'
inputFormat: ${{ matrix.run.format }}
inputRegex: ${{ matrix.run.regex }}
levelMap: ${{ matrix.run.levelMap }}
analysisPath: ${{ matrix.run.analysisPath }}
- name: Create Diff
run: json-diff "__tests__/${{ matrix.run.linter }}.output.json" "sarif.json" | tee diff.txt
- name: Test Output
run: |
if [ -s diff.txt ];
then
echo "Failed with diff:"
cat diff.txt
exit 1
else
echo "Success"
fi