This repository was archived by the owner on Feb 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
106 lines (93 loc) · 3.81 KB
/
measure-coverage.yml
File metadata and controls
106 lines (93 loc) · 3.81 KB
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
name: Measure coverage of default test suite
on:
workflow_dispatch:
inputs:
packages:
description: "Packages to generate tests for"
default: "+benchmarks.txt"
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
default: false
jobs:
setup:
runs-on: ubuntu-latest
outputs:
packages: "${{ steps.parse_packages.outputs.packages }}"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12
- id: parse_packages
run: |
packages=$(node ${GITHUB_WORKSPACE}/.github/parse_packages.js \
"${{ github.event.inputs.packages || '+benchmarks.txt' }}")
echo "packages=$packages" >> $GITHUB_OUTPUT
benchmark:
needs:
- setup
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.setup.outputs.packages) }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 12
- name: Checkout github package repo
if: ${{ matrix.package.host == 'github.com' }}
uses: actions/checkout@v3
with:
repository: ${{ format('{0}/{1}', matrix.package.owner, matrix.package.repo) }}
ref: ${{ matrix.package.sha }}
path: "source"
- name: Checkout gitlab package repo
if: ${{ matrix.package.host == 'gitlab.com' }}
run: |
git clone ${{ format('https://gitlab.com/{0}/{1}', matrix.package.owner, matrix.package.repo) }} source
cd source
git checkout ${{ matrix.package.sha }}
- name: Determine package name
id: pkg-name
run: |
# name of the package
TESTPILOT_PACKAGE_NAME=$(cat source/${{ matrix.package.path }}/package.json | jq -r .name )
# some packages have a / in their names (looking at you, gitlab-js!)
if [[ "$TESTPILOT_PACKAGE_NAME" == *"/"* ]]; then
TESTPILOT_PACKAGE_NAME=${TESTPILOT_PACKAGE_NAME##*/}
fi
# path to the package within the repo checkout
TESTPILOT_PACKAGE_PATH="$GITHUB_WORKSPACE/$TESTPILOT_PACKAGE_NAME/${{ matrix.package.path }}"
# make sure there isn't already a directory with the same name
if [ -d "$TESTPILOT_PACKAGE_PATH" ]; then
echo "ERROR: $TESTPILOT_PACKAGE_PATH already exists"
exit 1
fi
# rename checkout, since some packages examine its name (looking at you, bluebird!)
mv source $TESTPILOT_PACKAGE_NAME
echo "Package name: $TESTPILOT_PACKAGE_NAME, path: $TESTPILOT_PACKAGE_PATH"
# export environment variables
echo "TESTPILOT_PACKAGE_NAME=$TESTPILOT_PACKAGE_NAME" >> $GITHUB_ENV
echo "TESTPILOT_PACKAGE_PATH=$TESTPILOT_PACKAGE_PATH" >> $GITHUB_ENV
echo "pkgName=$TESTPILOT_PACKAGE_NAME" >> $GITHUB_OUTPUT
- name: Install package, its dependencies, and test packages
run: |
cd $TESTPILOT_PACKAGE_PATH
npm i || npm i --legacy-peer-deps
# if matrix.package.dependencies is not empty, install them
if ! [ -z "${{ matrix.package.dependencies }}" ]; then
npm i ${{ matrix.package.dependencies }}
fi
npm run build || npm run prepack || echo 'Error with npm run build and npm run prepack'
npm i --no-save mocha nyc
- name: Measure coverage of default test suite
run: |
cd $TESTPILOT_PACKAGE_PATH
./node_modules/.bin/nyc npm test
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}