-
Notifications
You must be signed in to change notification settings - Fork 5.8k
88 lines (74 loc) · 2.69 KB
/
Copy pathlintdiff-code.yaml
File metadata and controls
88 lines (74 loc) · 2.69 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
name: "Swagger LintDiff - Analyze Code"
on:
pull_request:
types:
# default
- opened
- synchronize
- reopened
# re-run if base branch is changed, since previous merge commit may generate incorrect diff
- edited
permissions:
contents: read
jobs:
lintdiff:
name: "Swagger LintDiff - Analyze Code"
runs-on: ubuntu-24.04
steps:
- name: Checkout eng
uses: actions/checkout@v6
with:
sparse-checkout: |
eng/
.github/
- name: Checkout 'after' state
uses: actions/checkout@v6
with:
fetch-depth: 2
path: after
- name: Checkout 'before' state
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.sha }}
path: before
- name: Setup Node and install deps
uses: ./.github/actions/setup-node-install-deps
- name: Get changed files
uses: actions/github-script@v8
with:
script: |
const { getChangedFiles } = await import('${{ github.workspace }}/.github/shared/src/changed-files.js');
const { writeFileSync } = await import('fs');
const { join } = await import('path');
// TODO: Logger
const changedFiles = await getChangedFiles({ cwd: 'after', paths: ['specification'] });
console.log('Changed files:', changedFiles);
const filePath = join(process.cwd(), 'changed-files.txt');
writeFileSync(filePath, changedFiles.join('\n'), 'utf8');
console.log(`Changed files written to ${filePath}`);
# TODO: Could be github.sha for merge commit
- name: Run LintDiff
id: run-lintdiff
run: |
set -x
echo "summary=$GITHUB_STEP_SUMMARY" >> "$GITHUB_OUTPUT"
npm exec --no -- lint-diff \
--before before \
--after after \
--changed-files-path changed-files.txt \
--base-branch ${{ github.event.pull_request.base.ref }} \
--compare-sha ${{ github.event.pull_request.head.sha }} \
--out-file "$GITHUB_STEP_SUMMARY"
env:
# Some LintDiff runs are memory intensive and require more than the
# default.
NODE_OPTIONS: "--max-old-space-size=16384"
# Used by other workflows like set-status
- name: Set job-summary artifact
if: ${{ always() && steps.run-lintdiff.outputs.summary }}
uses: actions/upload-artifact@v7
with:
name: job-summary
path: ${{ steps.run-lintdiff.outputs.summary }}
# If the file doesn't exist, just don't add the artifact
if-no-files-found: ignore