Skip to content

Commit

Permalink
respond to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rscohn2 committed Jun 15, 2024
1 parent 15f5593 commit cf3b4eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
52 changes: 35 additions & 17 deletions .github/scripts/domain-check.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
function matchesPattern(domain, filePaths) {
// filter files that end in .md
filePaths = filePaths.filter(filePath =>
!filePath.endsWith('.md') &&
!filePath.startsWith('docs/') &&
!filePath.startsWith('third-party-programs/')
//
// This script is used by pr.yml to determine if a domain must be tested based
// on the files modified in the pull request.
//

// Given a domain name and set of files, return true if the domain should be
// tested
function matchesPattern(domain, filePaths) { // filter files that end in .md
filePaths = filePaths.filter(filePath => !filePath.endsWith('.md') &&
!filePath.startsWith('docs/') &&
!filePath.startsWith('third-party-programs/')
);
// These directories contain domain specific code
const dirs = '(tests/unit_tests|examples|src|include/oneapi/mkl)'
Expand All @@ -14,20 +19,20 @@ function matchesPattern(domain, filePaths) {
return match;
}

async function prFiles(github, context) {
const response = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
// Return the list of files modified in the pull request
async function prFiles(github, context) { const response = await
github.rest.pulls.listFiles({ owner: context.repo.owner, repo:
context.repo.repo, pull_number: context.payload.pull_request.number
});
const prFiles = response.data.map(file => file.filename);
return prFiles;
const prFiles = response.data.map(file => file.filename); return prFiles;
}

module.exports = async ({github, context, domain}) => {
if (!context.payload.pull_request) {
console.log('Not a pull request. Testing all domains.');
return true;
// Called by pr.yml. See:
// https://github.com/actions/github-script/blob/main/README.md for more
// information on the github and context parameters
module.exports = async ({github, context, domain}) => { if
(!context.payload.pull_request) { console.log('Not a pull request. Testing
all domains.'); return true;
}
const files = await prFiles(github, context);
const match = matchesPattern(domain, files);
Expand All @@ -37,6 +42,18 @@ module.exports = async ({github, context, domain}) => {
return match;
}


//
// Test the matchesPattern function
//
// Run this script with `node domain-check.js` It should exit with code 0 if
// all tests pass.
//
// If you need to change the set of files that are ignored, add a test pattern
// below with positive and negative examples. It is also possible to test by
// setting up a fork and then submitting pull requests that modify files, but
// it requires a lot of manual work.
//
test_patterns = [
{
domain: 'blas',
Expand Down Expand Up @@ -132,4 +149,5 @@ function testPattern(test) {
if (require.main === module) {
// invoke test for each test pattern
test_patterns.forEach(testPattern)
console.log('All tests pass')
}
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "PR Tests"
permissions: read-all

# Trigger for PR an merge to develop branch
# Trigger for PR and merge to develop branch
on:
push:
branches: develop
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
with:
script: |
const domainCheck = require('.github/scripts/domain-check.js')
return domainCheck({github, context, domain: "${{ matrix.domain}}"})
return domainCheck({github, context, domain: "${{ matrix.domain }}"})
- name: Restore netlib from cache
id: cache-lapack
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
Expand Down

0 comments on commit cf3b4eb

Please sign in to comment.