Merge branch 'main' into simon-engledew/checkout-wrong-heads

This commit is contained in:
Simon Engledew 2021-01-04 13:37:11 +00:00 committed by GitHub
commit 034bf318b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 17 deletions

19
lib/upload-lib.js generated
View file

@ -72,13 +72,18 @@ async function upload(sarifPath, repositoryNwo, commitOid, ref, analysisKey, ana
throw new Error(`Path does not exist: ${sarifPath}`); throw new Error(`Path does not exist: ${sarifPath}`);
} }
if (fs.lstatSync(sarifPath).isDirectory()) { if (fs.lstatSync(sarifPath).isDirectory()) {
const paths = fs const walkSarifFiles = (dir) => {
.readdirSync(sarifPath) const entries = fs.readdirSync(dir, { withFileTypes: true });
.filter((f) => f.endsWith(".sarif")) for (const entry of entries) {
.map((f) => path.resolve(sarifPath, f)); if (entry.isFile() && entry.name.endsWith(".sarif")) {
for (const filepath of paths) { sarifFiles.push(path.resolve(dir, entry.name));
sarifFiles.push(filepath); }
} else if (entry.isDirectory()) {
walkSarifFiles(path.resolve(dir, entry.name));
}
}
};
walkSarifFiles(sarifPath);
if (sarifFiles.length === 0) { if (sarifFiles.length === 0) {
throw new Error(`No SARIF files found to upload in "${sarifPath}".`); throw new Error(`No SARIF files found to upload in "${sarifPath}".`);
} }

File diff suppressed because one or more lines are too long

View file

@ -31,8 +31,7 @@ python3 -m pip install --user pipenv
if command -v python2 &> /dev/null; then if command -v python2 &> /dev/null; then
# Setup Python 2 dependency installation tools. # Setup Python 2 dependency installation tools.
# The Ubuntu 20.04 GHA environment does not come with a Python 2 pip # The Ubuntu 20.04 GHA environment does not come with a Python 2 pip
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py curl --location --fail https://bootstrap.pypa.io/get-pip.py | python2
python2 get-pip.py
python2 -m pip install --user --upgrade pip setuptools wheel python2 -m pip install --user --upgrade pip setuptools wheel

View file

@ -104,13 +104,17 @@ export async function upload(
throw new Error(`Path does not exist: ${sarifPath}`); throw new Error(`Path does not exist: ${sarifPath}`);
} }
if (fs.lstatSync(sarifPath).isDirectory()) { if (fs.lstatSync(sarifPath).isDirectory()) {
const paths = fs const walkSarifFiles = (dir: string) => {
.readdirSync(sarifPath) const entries = fs.readdirSync(dir, { withFileTypes: true });
.filter((f) => f.endsWith(".sarif")) for (const entry of entries) {
.map((f) => path.resolve(sarifPath, f)); if (entry.isFile() && entry.name.endsWith(".sarif")) {
for (const filepath of paths) { sarifFiles.push(path.resolve(dir, entry.name));
sarifFiles.push(filepath); } else if (entry.isDirectory()) {
} walkSarifFiles(path.resolve(dir, entry.name));
}
}
};
walkSarifFiles(sarifPath);
if (sarifFiles.length === 0) { if (sarifFiles.length === 0) {
throw new Error(`No SARIF files found to upload in "${sarifPath}".`); throw new Error(`No SARIF files found to upload in "${sarifPath}".`);
} }