Skip to content

Commit

Permalink
format strategy matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcavazos committed Jul 22, 2024
1 parent 4b97738 commit 0f60b21
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
26 changes: 16 additions & 10 deletions .github/testing/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { List } from 'immutable';
import * as affected from './affected';
import * as git from './git';
import {global} from './config/global';
import {python} from './config/python';
import { global } from './config/global';
import { python } from './config/python';

const diffsCommit =
process.argv.length > 2 //
Expand All @@ -15,11 +16,16 @@ const baseCommit =

const diffs = git.diffs(diffsCommit, baseCommit).filter(global.matchFile);

const affectedPython = diffs
.filter(python.matchFile)
.map(python.changes)
.groupBy(change => change.package)
.map(change => change.map(pkg => pkg.affected))
.map(affected.merge);

console.log('affectedPython:', affectedPython.toJS());
const strategyMatrix = {
python: List(
diffs
.filter(python.matchFile)
.map(python.changes)
.groupBy(change => change.package)
.map(change => change.map(pkg => pkg.affected))
.map(affected.merge)
.map((tests, pkg) => ({ package: pkg, tests: tests }))
.values()
),
};
console.log(JSON.stringify(strategyMatrix));
17 changes: 11 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@ jobs:
find-tests:
runs-on: ubuntu-latest
outputs:
tests: ${{steps.affected.outputs.tests}}
affected: ${{steps.find-affected.outputs.affected}}
steps:
- uses: actions/checkout@v4
- id: affected
run: echo "tests=`TODO`" >> "$GITHUB_OUTPUT"
- run: npm run build
working-directory: .github/testing
- id: find-affected
run: echo "affected=$AFFECTED" >> "$GITHUB_OUTPUT"
working-directory: .github/testing
env:
AFFECTED: $(npm run affected)


test-python:
needs: find-tests
runs-on: ubuntu-latest
strategy:
matrix:
test: ${{fromJson(needs.find-tests.outputs.tests)}}
matrix: ${{fromJson(needs.find-tests.outputs.affected)}}
steps:
# - uses: actions/checkout@v4
- run: echo ${{matrix.test}}
- run: echo ${{matrix}}

0 comments on commit 0f60b21

Please sign in to comment.