Skip to content

Commit c08cab9

Browse files
authored
Add github actions to check PR and push (#29)
Adds various actions from vscode-pylint to here: * Action to check PRs * Action to check pushes * Action to check labels on PRs Signed-off-by: Eric Brown <[email protected]>
1 parent 20571b0 commit c08cab9

File tree

6 files changed

+399
-2
lines changed

6 files changed

+399
-2
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: 'Build VSIX'
2+
description: "Build the extension's VSIX"
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@v4
14+
with:
15+
node-version: ${{ inputs.node_version }}
16+
cache: 'npm'
17+
18+
# Minimum supported version is Python 3.9
19+
- name: Use Python 3.9
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.9'
23+
24+
- name: Pip cache
25+
uses: actions/cache@v4
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-build-vsix-${{ hashFiles('**/requirements.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-build-vsix-
31+
32+
- name: Upgrade Pip
33+
run: python -m pip install -U pip
34+
shell: bash
35+
36+
# For faster/better builds of sdists.
37+
- name: Install build pre-requisite
38+
run: python -m pip install wheel
39+
shell: bash
40+
41+
- name: Install nox
42+
run: python -m pip install nox
43+
shell: bash
44+
45+
- name: Run npm ci
46+
run: npm ci --prefer-offline
47+
shell: bash
48+
49+
- name: Install bundled python libraries
50+
run: python -m nox --session install_bundled_libs
51+
shell: bash
52+
53+
# Use the GITHUB_RUN_ID environment variable to update the build number.
54+
# GITHUB_RUN_ID is a unique number for each run within a repository.
55+
# This number does not change if you re-run the workflow run.
56+
- name: Update extension build number
57+
run: python -m nox --session update_build_number -- $GITHUB_RUN_ID
58+
shell: bash
59+
60+
- name: Build VSIX
61+
run: npm run vsce-package
62+
shell: bash
63+
64+
- name: Upload VSIX
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: linter-package
68+
path: |
69+
**/*.vsix
70+
if-no-files-found: error
71+
retention-days: 7

.github/actions/lint/action.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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@v4
14+
with:
15+
node-version: ${{ inputs.node_version }}
16+
cache: 'npm'
17+
18+
- name: Install Node dependencies
19+
run: npm ci
20+
shell: bash
21+
22+
- name: Lint TypeScript code
23+
run: npm run lint
24+
shell: bash
25+
26+
- name: Check TypeScript format
27+
run: npm run format-check
28+
shell: bash
29+
30+
- name: Install Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.9'
34+
35+
- name: Pip cache
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.cache/pip
39+
key: ${{ runner.os }}-pip-lint-${{ hashFiles('**/requirements.txt') }}
40+
restore-keys: |
41+
${{ runner.os }}-pip-lint-
42+
43+
- name: Upgrade Pip
44+
run: python -m pip install -U pip
45+
shell: bash
46+
47+
- name: Install wheel and nox
48+
run: python -m pip install wheel nox
49+
shell: bash
50+
51+
# This will install libraries to a target directory.
52+
- name: Install bundled python libraries
53+
run: python -m nox --session install_bundled_libs
54+
shell: bash
55+
56+
- name: Check linting and formatting
57+
run: python -m nox --session lint
58+
shell: bash

.github/workflows/pr-check.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
6+
env:
7+
NODE_VERSION: 18.17.1
8+
TEST_RESULTS_DIRECTORY: .
9+
# Force a path with spaces and unicode chars to test extension works in these scenarios
10+
special-working-directory: './🐍 🐛'
11+
special-working-directory-relative: '🐍 🐛'
12+
13+
jobs:
14+
build-vsix:
15+
name: Create VSIX
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Build VSIX
22+
uses: ./.github/actions/build-vsix
23+
with:
24+
node_version: ${{ env.NODE_VERSION}}
25+
26+
lint:
27+
name: Lint
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
33+
- name: Lint
34+
uses: ./.github/actions/lint
35+
with:
36+
node_version: ${{ env.NODE_VERSION }}
37+
38+
tests:
39+
name: Tests
40+
runs-on: ${{ matrix.os }}
41+
defaults:
42+
run:
43+
working-directory: ${{ env.special-working-directory }}
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
os: [ubuntu-latest, windows-latest]
48+
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
with:
54+
path: ${{ env.special-working-directory-relative }}
55+
56+
# Install bundled libs using 3.9 even though you test it on other versions.
57+
- name: Use Python 3.9
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: '3.9'
61+
62+
- name: Update pip, install wheel and nox
63+
run: python -m pip install -U pip wheel nox
64+
shell: bash
65+
66+
# This will install libraries to a target directory.
67+
- name: Install bundled python libraries
68+
run: python -m nox --session install_bundled_libs
69+
shell: bash
70+
71+
# Now that the bundle is installed to target using python 3.9
72+
# switch back the python we want to test with
73+
- name: Use Python ${{ matrix.python }}
74+
uses: actions/setup-python@v5
75+
with:
76+
python-version: ${{ matrix.python }}
77+
78+
# The new python may not have nox so install it again
79+
- name: Update pip, install wheel and nox (again)
80+
run: python -m pip install -U pip wheel nox
81+
shell: bash
82+
83+
- name: Run tests
84+
run: python -m nox --session tests
85+
shell: bash
86+
87+
- name: Validate README.md
88+
run: python -m nox --session validate_readme
89+
shell: bash
90+
91+
ts-tests:
92+
name: TypeScript Tests
93+
runs-on: ${{ matrix.os }}
94+
strategy:
95+
fail-fast: false
96+
matrix:
97+
os: [ubuntu-latest, windows-latest]
98+
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v3
102+
103+
- name: Install Node
104+
uses: actions/setup-node@v3
105+
with:
106+
node-version: ${{ env.NODE_VERSION }}
107+
cache: 'npm'
108+
cache-dependency-path: ./package-lock.json
109+
110+
- name: Install Node dependencies
111+
run: npm ci
112+
shell: bash
113+
114+
- name: Compile TS tests
115+
run: npm run pretest
116+
shell: bash
117+
118+
- name: Run TS tests
119+
uses: GabrielBB/[email protected]
120+
with:
121+
run: npm run tests

.github/workflows/pr-labels.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'PR labels'
2+
on:
3+
pull_request:
4+
types:
5+
- 'opened'
6+
- 'reopened'
7+
- 'labeled'
8+
- 'unlabeled'
9+
- 'synchronize'
10+
11+
jobs:
12+
add-pr-label:
13+
name: 'Ensure Required Labels'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: 'PR impact specified'
17+
uses: mheap/github-action-required-labels@v5
18+
with:
19+
mode: exactly
20+
count: 1
21+
labels: 'bug, debt, feature-request, no-changelog'

0 commit comments

Comments
 (0)