-
Notifications
You must be signed in to change notification settings - Fork 10
126 lines (107 loc) · 3.86 KB
/
test.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
name: Test and publish
on:
workflow_dispatch:
pull_request:
push:
branches: "master"
jobs:
# Test the extension on multiple OSs.
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '15'
distribution: 'zulu'
- name: Install NPM dependencies
run: npm install
- name: Run linter
run: npm run lint
- name: Package the extension
run: npm run package
- name: Run tests (headless)
uses: coactions/setup-xvfb@v1
id: runTests
with:
run: npm test --full-trace
env:
GITHUB_TOKEN: ${{ secrets.VIPER_ADMIN_TOKEN }}
- name: Collect coverage
if: ${{ steps.runTests.outcome == 'success' }}
run: npx nyc report --reporter=lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: ${{ steps.runTests.outcome == 'success' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/lcov.info
# Publish the extension when we are on master and the version specified in
# package.json is not the latest published version of the extension.
publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Install NPM dependencies
run: npm install
- name: Obtain version information
run: |
LAST_PUBLISHED_VERSION="$(
npx vsce show viper-admin.prusti-assistant --json \
| jq '.versions[0].version' --raw-output
)"
CURRENT_VERSION="$(
cat package.json | jq '.version' --raw-output
)"
echo "LAST_PUBLISHED_VERSION=$LAST_PUBLISHED_VERSION" >> $GITHUB_ENV
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Package the extension
run: npm run package
- name: Publish the extension to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v0
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
with:
pat: ${{ secrets.VSCE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
packagePath: ''
- name: Publish the extension to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v0
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
with:
pat: ${{ secrets.OPEN_VSX_TOKEN }}
registryUrl: https://open-vsx.org
extensionFile: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
packagePath: ''
- name: Create a release for the published version
id: create_release
uses: actions/create-release@v1
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.CURRENT_VERSION }}
release_name: Release v${{ env.CURRENT_VERSION }}
- name: Upload release asset
uses: actions/upload-release-asset@v1
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
asset_name: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
asset_content_type: application/zip