Skip to content

Commit 9703a9d

Browse files
authored
Introduce a lint composite action (microsoft#17260)
1 parent e26a1ed commit 9703a9d

4 files changed

Lines changed: 80 additions & 58 deletions

File tree

‎.github/actions/build-vsix/action.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,26 @@ runs:
2020
with:
2121
node-version: ${{ inputs.node_version }}
2222

23+
- uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-build-vsix-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-build-vsix-
29+
2330
# Jedi LS depends on dataclasses which is not in the stdlib in Python 3.6.
2431
- name: Use Python 3.6 for JediLSP
2532
uses: actions/setup-python@v2
2633
with:
2734
python-version: 3.6
2835

36+
- uses: actions/cache@v2
37+
with:
38+
path: ~/.cache/pip
39+
key: ${{ runner.os }}-pip-build-vsix-${{ hashFiles('**/requirements.txt') }}
40+
restore-keys: |
41+
${{ runner.os }}-pip-build-vsix-
42+
2943
- name: Upgrade Pip
3044
run: python -m pip install -U pip
3145
shell: bash

‎.github/actions/lint/action.yml‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 'Lint'
2+
description: 'Lint TypeScript and Python code'
3+
4+
inputs:
5+
node_version:
6+
description: 'Version of Node to install'
7+
required: true
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- name: Install Node
13+
uses: actions/setup-node@v2
14+
with:
15+
node-version: ${{ inputs.node_version }}
16+
- uses: actions/cache@v2
17+
with:
18+
path: ~/.npm
19+
key: ${{ runner.os }}-node-lint-${{ hashFiles('**/package-lock.json') }}
20+
restore-keys: |
21+
${{ runner.os }}-node-lint-
22+
23+
- name: Install Node dependencies
24+
run: npm ci --prefer-offline
25+
shell: bash
26+
27+
- name: Run `gulp prePublishNonBundle`
28+
run: npx gulp prePublishNonBundle
29+
shell: bash
30+
31+
- name: Check dependencies
32+
run: npm run checkDependencies
33+
shell: bash
34+
35+
- name: Lint TypeScript code
36+
run: npm run lint
37+
shell: bash
38+
39+
- name: Check TypeScript format
40+
run: npm run format-check
41+
shell: bash
42+
43+
- name: Install Python
44+
uses: actions/setup-python@v2
45+
with:
46+
python-version: '3.x'
47+
48+
- uses: actions/cache@v2
49+
with:
50+
path: ~/.cache/pip
51+
key: ${{ runner.os }}-pip-lint-${{ hashFiles('**/requirements.txt') }}
52+
restore-keys: |
53+
${{ runner.os }}-pip-lint-
54+
55+
- name: Check Python format
56+
run: |
57+
python -m pip install -U black
58+
python -m black . --check
59+
working-directory: pythonFiles
60+
shell: bash

‎.github/workflows/build.yml‎

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,36 +65,10 @@ jobs:
6565
- name: Checkout
6666
uses: actions/checkout@v2.3.4
6767

68-
- name: Install Node
69-
uses: actions/setup-node@v2.4.0
68+
- name: Lint
69+
uses: ./.github/actions/lint
7070
with:
71-
node-version: ${{env.NODE_VERSION}}
72-
73-
- name: Install dependencies (npm ci)
74-
run: npm ci --prefer-offline
75-
76-
- name: Run gulp prePublishNonBundle
77-
run: npx gulp prePublishNonBundle
78-
79-
- name: Check dependencies
80-
run: npm run checkDependencies
81-
82-
- name: Run linting on TypeScript code
83-
run: npm run lint
84-
85-
- name: Run formatting on TypeScript code
86-
run: npm run format-check
87-
88-
- name: Use Python 3.x
89-
uses: actions/setup-python@v2
90-
with:
91-
python-version: 3.x
92-
93-
- name: Run Black on Python code
94-
run: |
95-
python -m pip install -U black
96-
python -m black . --check
97-
working-directory: pythonFiles
71+
node_version: ${{ env.NODE_VERSION }}
9872

9973
### Non-smoke tests
10074
tests:

‎.github/workflows/pr-check.yml‎

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,36 +41,10 @@ jobs:
4141
- name: Checkout
4242
uses: actions/checkout@v2.3.4
4343

44-
- name: Install Node
45-
uses: actions/setup-node@v2.4.0
46-
with:
47-
node-version: ${{env.NODE_VERSION}}
48-
49-
- name: Install dependencies (npm ci)
50-
run: npm ci --prefer-offline
51-
52-
- name: Run gulp prePublishNonBundle
53-
run: npx gulp prePublishNonBundle
54-
55-
- name: Check dependencies
56-
run: npm run checkDependencies
57-
58-
- name: Run linting on TypeScript code
59-
run: npm run lint
60-
61-
- name: Run formatting on TypeScript code
62-
run: npm run format-check
63-
64-
- name: Use Python ${{env.PYTHON_VERSION}}
65-
uses: actions/setup-python@v2
44+
- name: Lint
45+
uses: ./.github/actions/lint
6646
with:
67-
python-version: ${{env.PYTHON_VERSION}}
68-
69-
- name: Run Black on Python code
70-
run: |
71-
python -m pip install -U black
72-
python -m black . --check
73-
working-directory: pythonFiles
47+
node_version: ${{ env.NODE_VERSION }}
7448

7549
### Non-smoke tests
7650
tests:

0 commit comments

Comments
 (0)