Skip to content

Commit ca5439c

Browse files
author
Adrian Chang
committed
dynamic matrix
1 parent ac068a4 commit ca5439c

File tree

3 files changed

+72
-26
lines changed

3 files changed

+72
-26
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: 'lbox-matrix'
2+
description: 'Generate running matrix for an lbox package'
3+
inputs:
4+
files-changed:
5+
description: 'Files changed as json array'
6+
required: true
7+
default: '[]'
8+
outputs:
9+
time:
10+
matrix: 'Matrix to run lbox packages tests against'
11+
runs:
12+
using: 'node20'
13+
main: 'index.js'

.github/actions/lbox-matrix/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const core = require('@actions/core');
2+
3+
try {
4+
const files = JSON.parse(core.getInput('files-changed'));
5+
const startingMatrix = [
6+
{
7+
"python-version": "3.8",
8+
"api-key": "STAGING_LABELBOX_API_KEY_2",
9+
"da-test-key": "DA_GCP_LABELBOX_API_KEY"
10+
},
11+
{
12+
"python-version": "3.9",
13+
"api-key": "STAGING_LABELBOX_API_KEY_3",
14+
"da-test-key": "DA_GCP_LABELBOX_API_KEY"
15+
},
16+
{
17+
"python-version": "3.10",
18+
"api-key": "STAGING_LABELBOX_API_KEY_4",
19+
"da-test-key": "DA_GCP_LABELBOX_API_KEY"
20+
},
21+
{
22+
"python-version": "3.11",
23+
"api-key": "STAGING_LABELBOX_API_KEY",
24+
"da-test-key": "DA_GCP_LABELBOX_API_KEY"
25+
},
26+
{
27+
"python-version": "3.12",
28+
"api-key": "STAGING_LABELBOX_API_KEY_5",
29+
"da-test-key": "DA_GCP_LABELBOX_API_KEY"
30+
}
31+
];
32+
const finalMatrix = [];
33+
files.forEach(file => {
34+
startingMatrix.forEach(matrixItem => {
35+
finalMatrix.push({
36+
...matrixItem,
37+
package: files.split('/')[1]
38+
});
39+
});
40+
});
41+
core.setOutput("matrix", JSON.stringify(finalMatrix));
42+
} catch {
43+
core.setFailed("Could not create matrix");
44+
}

.github/workflows/lbox-develop.yml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,27 @@ jobs:
1717
path-filter:
1818
runs-on: ubuntu-latest
1919
outputs:
20-
lbox-example: ${{ steps.filter.outputs.lbox-example }}
20+
lbox: ${{ steps.filter.outputs.lbox }}
21+
matrix: ${{ steps.matrix.outputs.matrix }}
2122
steps:
2223
- uses: dorny/paths-filter@v3
2324
id: filter
2425
with:
2526
list-files: 'json'
2627
filters: |
27-
lbox-example:
28-
- 'libs/lbox-example/**'
28+
lbox:
29+
- 'libs/lbox*/**'
30+
- id: matrix
31+
uses: ./.github/actions/lbox-matrix
32+
with:
33+
files-changed: ${{ steps.filter.outputs.lbox_files }}
2934
build:
3035
needs: ['path-filter']
31-
if: ${{ needs.path-filter.outputs.lbox-example == 'true' }}
36+
if: ${{ needs.path-filter.outputs.lbox == 'true' }}
3237
runs-on: ubuntu-latest
3338
strategy:
3439
fail-fast: false
35-
matrix:
36-
include:
37-
- python-version: 3.8
38-
api-key: STAGING_LABELBOX_API_KEY_2
39-
da-test-key: DA_GCP_LABELBOX_API_KEY
40-
- python-version: 3.9
41-
api-key: STAGING_LABELBOX_API_KEY_3
42-
da-test-key: DA_GCP_LABELBOX_API_KEY
43-
- python-version: "3.10"
44-
api-key: STAGING_LABELBOX_API_KEY_4
45-
da-test-key: DA_GCP_LABELBOX_API_KEY
46-
- python-version: 3.11
47-
api-key: STAGING_LABELBOX_API_KEY
48-
da-test-key: DA_GCP_LABELBOX_API_KEY
49-
- python-version: 3.12
50-
api-key: STAGING_LABELBOX_API_KEY_5
51-
da-test-key: DA_GCP_LABELBOX_API_KEY
40+
matrix: ${{ fromJSON(needs.path-filter.outputs.matrix) }}
5241
steps:
5342
- uses: actions/checkout@v4
5443
with:
@@ -59,12 +48,12 @@ jobs:
5948
rye-version: ${{ vars.RYE_VERSION }}
6049
python-version: ${{ matrix.python-version }}
6150
- name: Format
62-
run: rye format --check -v -p lbox-example
51+
run: rye format --check -v -p ${{ matrix.package }}
6352
- name: Linting
64-
run: rye lint -v -p lbox-example
53+
run: rye lint -v -p ${{ matrix.package }}
6554
- name: Unit
66-
working-directory: libs/lbox-example
55+
working-directory: libs/${{ matrix.package }}
6756
run: rye run unit
6857
- name: Integration
69-
working-directory: libs/lbox-example
70-
run: rye run integration --pyproject libs/lbox-example/pyproject.toml
58+
working-directory: libs/${{ matrix.package }}
59+
run: rye run integration

0 commit comments

Comments
 (0)