Skip to content

Commit 65c8aff

Browse files
committed
ci: matrix strategy
1 parent ecda4f4 commit 65c8aff

4 files changed

Lines changed: 71 additions & 42 deletions

File tree

.github/workflows/get-matrix.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ const packagesPath = join(__dirname, '../../packages')
1010

1111
for (const packagePath of await readdir(packagesPath)) {
1212
const pkg = join(packagesPath, packagePath, 'package.json')
13-
const { name } = JSON.parse(await readFile(pkg))
14-
packages.push(name)
13+
const { name, scripts } = JSON.parse(await readFile(pkg))
14+
if (scripts && scripts.test && scripts.test !== 'exit 0') {
15+
packages.push(name)
16+
}
1517
}
1618

1719
console.log(`{"package":${JSON.stringify(packages)}}`)
18-

.github/workflows/pull_request.yml

Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,74 +8,92 @@ on:
88
branches:
99
- master
1010

11+
env:
12+
MYSQL_DB_DATABASE: keyv_test
13+
MYSQL_DB_USER: root
14+
MYSQL_DB_PASSWORD: root
15+
1116
jobs:
1217
matrix:
1318
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
- id: matrix
23+
run: echo "matrix=$(node .github/workflows/get-matrix.mjs)" >> $GITHUB_OUTPUT
24+
- run: echo ${{ steps.matrix.outputs.matrix }}
25+
outputs:
26+
matrix: ${{ steps.matrix.outputs.matrix }}
1427

28+
test:
29+
if: github.ref != 'refs/heads/master'
30+
needs: matrix
31+
runs-on: ubuntu-latest
1532
strategy:
16-
matrix:
17-
node-version: [20]
18-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
19-
env:
20-
MYSQL_DB_DATABASE: keyv_test
21-
MYSQL_DB_USER: root
22-
MYSQL_DB_PASSWORD: root
33+
fail-fast: false
34+
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
2335
steps:
2436
- name: Checkout
2537
uses: actions/checkout@v4
26-
- name: Use Node.js ${{ matrix.node-version }}
38+
- name: Setup Node.js
2739
uses: actions/setup-node@v4
2840
with:
29-
node-version: ${{ matrix.node-version }}
41+
node-version: lts/*
42+
- name: Setup PNPM
43+
uses: pnpm/action-setup@v4
44+
with:
45+
version: latest
46+
run_install: true
3047
- name: Start Redis
48+
if: contains(matrix.package, 'redis')
3149
uses: supercharge/redis-github-action@1.8.0
32-
# - name: Start PostgreSQL
33-
# uses: harmon758/postgresql-action@v1
34-
# with:
35-
# postgresql version: '11'
36-
# postgresql password: postgres
37-
# postgresql user: postgres
38-
# postgresql db: keyv_test
3950
- name: Start MongoDB
51+
if: contains(matrix.package, 'mongo')
4052
uses: supercharge/mongodb-github-action@1.12.0
4153
- name: Start MySQL
54+
if: contains(matrix.package, 'mysql')
4255
run: |
4356
sudo systemctl start mysql.service
4457
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DB_DATABASE }}' -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PASSWORD }}
4558
mysql -e 'SET GLOBAL max_connections = 300;' -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PASSWORD }}
46-
- name: Start PostgreSQL on Ubuntu
59+
- name: Start PostgreSQL
60+
if: contains(matrix.package, 'postgres')
4761
run: |
4862
sudo systemctl start postgresql.service
4963
pg_isready
5064
- name: Setup PostgreSQL for ava tests
65+
if: contains(matrix.package, 'postgres')
5166
run: |
5267
sudo -u postgres psql --command="alter system set max_connections = 300;"
5368
sudo -u postgres psql --command="CREATE DATABASE keyv_test;"
5469
sudo -u postgres psql --command="ALTER ROLE postgres WITH PASSWORD 'postgres';" --command="\du"
5570
sudo systemctl restart postgresql.service
5671
pg_isready
57-
- id: matrix
58-
run: echo "matrix=$(node .github/workflows/get-matrix.mjs)" >> $GITHUB_OUTPUT
59-
- run: echo ${{ steps.matrix.outputs.matrix }}
60-
outputs:
61-
matrix: ${{ steps.matrix.outputs.matrix }}
72+
- name: Rebuild @vscode/sqlite3
73+
if: contains(matrix.package, 'multi') || contains(matrix.package, 'sql')
74+
run: |
75+
cd $(pnpm --filter "${{ matrix.package }}" exec pwd)
76+
ls -l
77+
pnpm install @vscode/sqlite3
78+
- name: Test
79+
run: pnpm --filter "${{ matrix.package }}" exec c8 pnpm test
80+
- name: Coverage
81+
run: pnpm --filter "${{ matrix.package }}" exec c8 report --reporter=lcov --report-dir=coverage
82+
- name: Upload
83+
uses: coverallsapp/github-action@main
84+
with:
85+
flag-name: ${{ matrix.package }}
86+
parallel: true
87+
file: $(pnpm --filter "${{ matrix.package }}" exec pwd)/coverage/lcov.info
6288

63-
test:
64-
if: github.ref != 'refs/heads/master'
65-
needs: matrix
89+
finish:
90+
needs: test
6691
runs-on: ubuntu-latest
67-
strategy:
68-
fail-fast: false
69-
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
7092
steps:
71-
- name: Checkout
72-
uses: actions/checkout@v4
93+
- name: Coveralls Finished
94+
uses: coverallsapp/github-action@main
7395
with:
74-
token: ${{ secrets.GITHUB_TOKEN }}
75-
- name: Setup PNPM
76-
uses: pnpm/action-setup@v4
77-
with:
78-
version: latest
79-
run_install: true
80-
- name: Test
81-
run: pnpm --filter "${{ matrix.package }}" test
96+
parallel-finished: true
97+
98+
99+

.npmrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
audit=false
2+
fund=false
3+
loglevel=error
4+
package-lock=false
5+
prefer-dedupe=true
6+
prefer-offline=false
7+
resolution-mode=highest
18
save-prefix=~
29
save=false
10+
shamefully-hoist=true
11+
strict-peer-dependencies=false
312
unsafe-perm=true
13+
link-workspace-packages=true

packages/sqlite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
],
3333
"dependencies": {
3434
"@keyvhq/sql": "workspace:*",
35-
"@vscode/sqlite3": "~5.1.2",
35+
"@vscode/sqlite3": "latest",
3636
"pify": "~5.0.0"
3737
},
3838
"devDependencies": {

0 commit comments

Comments
 (0)