generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 57
150 lines (122 loc) · 5.01 KB
/
tests-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: Continuous Integration
on:
push:
branches:
- main
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
security-audit:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
cache: "npm"
- name: Report known vulnerabilities
run: npm audit
test-with-node:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build all workspace packages
run: npm run build
- name: Run linter for all packages
run: npm run lint --ws
- name: Run dwn-server (background)
run: |
node node_modules/@web5/dwn-server/dist/esm/src/main.js &
echo "DWN_SERVER_BACKGROUND_PROCESS=$!" >> $GITHUB_ENV
- name: Run tests for all packages
run: npm run test:node --ws -- --color --reporter mocha-junit-reporter --reporter-options mochaFile=./results.xml
env:
TEST_DWN_URL: http://localhost:3000
- name: Terminate dwn-server
run: kill $DWN_SERVER_BACKGROUND_PROCESS || true
- name: Upload test results to update SDK reports
uses: actions/upload-artifact@v3
with:
name: junit-results
path: packages/*/results.xml
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-with-browsers:
name: test-with-browsers (group ${{ matrix.group }})
# Run browser tests using macOS so that WebKit tests don't fail under a Linux environment
runs-on: macos-latest
strategy:
# parallelism strategy: agent takes as long as roughly all other pkgs combined.
matrix:
include:
- group: "A"
packages: "--workspace packages/agent --workspace packages/dids"
- group: "B"
packages: "--workspace packages/common --workspace packages/crypto --workspace packages/credentials --workspace packages/user-agent --workspace packages/proxy-agent --workspace packages/api --workspace packages/identity-agent"
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Get Playwright Version (for cache)
id: get-playwright-version
run: |
PLAYWRIGHT_VERSION=$(npm view @playwright/test version)
echo "Playwright Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Restore Cached Playwright Browsers
id: cache-playwright-restore
uses: actions/cache/restore@84995e0d91a927aa8da027221d329f84446b8c9b #v3.3.2
with:
path: ~/Library/Caches/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright Browsers (if no cache)
if: steps.cache-playwright-restore.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Save Playwright Cache (if no cache)
uses: actions/cache/save@e08330827dd5663b268018076572bea59a734b60 #v3.3.2
id: cache-playwright-save
if: steps.cache-playwright-restore.outputs.cache-hit != 'true'
with:
path: ~/Library/Caches/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Build esm
run: npm run build:esm --ws
- name: Build browser for matrix ${{ matrix.group }}
run: npm run build:browser ${{ matrix.packages }}
- name: Run dwn-server (background)
run: |
node node_modules/@web5/dwn-server/dist/esm/src/main.js &
echo "DWN_SERVER_BACKGROUND_PROCESS=$!" >> $GITHUB_ENV
- name: Run tests for matrix ${{ matrix.group }}
run: npm run test:browser ${{ matrix.packages }}
- name: Terminate dwn-server
run: kill $DWN_SERVER_BACKGROUND_PROCESS || true
web5-spec:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- uses: TBD54566975/sdk-development@v0.2.3