-
Notifications
You must be signed in to change notification settings - Fork 8
150 lines (129 loc) · 3.62 KB
/
ci.yml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: ci
on:
pull_request:
push:
branches:
- main
workflow_call:
inputs:
version:
description: Version to build.
required: false
type: string
default: ''
outputs:
node-version:
description: Version of node used to build package.
value: ${{ jobs.test.outputs.node-version }}
package-name:
description: Name of the package built.
value: ${{ jobs.test.outputs.package-name }}
permissions:
checks: write
statuses: write
defaults:
run:
shell: bash
jobs:
lint:
runs-on: ubuntu-latest
env:
NODE_VERSION: '18.x'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{ env.NODE_VERSION }}
- name: Spell check
uses: streetsidesoftware/cspell-action@v5
with:
config: .cspell.json
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version:
- '18.x'
os:
- macos-latest
- ubuntu-latest
- windows-latest
vscode-channel:
- stable
- insiders
include:
- os: ubuntu-latest
vscode-channel: stable
build-package: true
outputs:
node-version: ${{ steps.package.outputs.node-version }}
package-name: ${{ steps.package.outputs.package-name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: npm
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Test (Linux)
if: runner.os == 'Linux'
run: xvfb-run -a npm test
env:
CODE_VERSION: ${{ matrix.vscode-channel }}
TEST_RESULTS_PATH: ${{ github.workspace }}/.vscode-test/test-results.xml
- name: Test
if: runner.os != 'Linux'
run: npm test
env:
CODE_VERSION: ${{ matrix.vscode-channel }}
TEST_RESULTS_PATH: ${{ github.workspace }}/.vscode-test/test-results.xml
- name: Publish test results
if: github.repository_owner == 'heaths'
uses: dorny/test-reporter@v1
with:
name: test-results-${{ matrix.os }}-${{ matrix.vscode-channel }}
path: .vscode-test/test-results.xml
reporter: jest-junit
- id: package
name: Package
run: |
BUILD_VERSION="${{ inputs.version }}"
if [[ -z "${BUILD_VERSION}" ]]; then
BUILD_VERSION="$(npm pkg get version | tr -d \")-pre"
fi
BUILD_VERSION="${BUILD_VERSION#v}"
echo "BUILD_VERSION=${BUILD_VERSION}" >> $GITHUB_ENV
npm install -g @vscode/vsce
vsce package -o "${{ runner.temp }}/vscode-guid-${BUILD_VERSION}.vsix"
echo "node-version=${{ matrix.node-version }}" >> $GITHUB_OUTPUT
echo "package-name=vscode-guid-${BUILD_VERSION}.vsix" >> $GITHUB_OUTPUT
if: matrix.build-package
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: artifact
path: ${{ runner.temp }}/vscode-guid-${{ env.BUILD_VERSION }}.vsix
if: matrix.build-package
check:
needs:
- lint
- test
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
steps:
- name: Check
run: |
if [[ "${{ needs.lint.result }}" != "success" ]]; then
exit 1
fi
if [[ "${{ needs.test.result }}" != "success" ]]; then
exit 1
fi
echo "All tests passed :tada:" >> $GITHUB_STEP_SUMMARY