Skip to content

Commit ddb83a4

Browse files
Edoardo Pirovanoedoardopirovano
Edoardo Pirovano
authored andcommitted
Cleanup CodeQL DBs and output their location for later steps
1 parent cbdf0df commit ddb83a4

12 files changed

+113
-14
lines changed

.github/workflows/pr-checks.yml

+29-11
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,38 @@ jobs:
6565
shell: bash
6666
run: ./build.sh
6767
- uses: ./../action/analyze
68+
id: analysis
6869
env:
6970
TEST_MODE: true
7071
- run: |
71-
cd "$RUNNER_TEMP/customDbLocation"
72-
# List all directories as there will be precisely one directory per database
73-
# but there may be other files in this directory such as query suites.
74-
if [ "$(ls -d */ | wc -l)" != 6 ] || \
75-
[[ ! -d cpp ]] || \
76-
[[ ! -d csharp ]] || \
77-
[[ ! -d go ]] || \
78-
[[ ! -d java ]] || \
79-
[[ ! -d javascript ]] || \
80-
[[ ! -d python ]]; then
81-
echo "Did not find expected number of databases. Database dir contains: $(ls)"
72+
CPP_DB=${{ fromJson(steps.analysis.outputs.db-locations).cpp }}
73+
if [[ ! -d $CPP_DB ]] || [[ ! $CPP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
74+
echo "Did not create a database for CPP, or created it in the wrong location."
75+
exit 1
76+
fi
77+
CSHARP_DB=${{ fromJson(steps.analysis.outputs.db-locations).csharp }}
78+
if [[ ! -d $CSHARP_DB ]] || [[ ! $CSHARP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
79+
echo "Did not create a database for C Sharp, or created it in the wrong location."
80+
exit 1
81+
fi
82+
GO_DB=${{ fromJson(steps.analysis.outputs.db-locations).go }}
83+
if [[ ! -d $GO_DB ]] || [[ ! $GO_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
84+
echo "Did not create a database for Go, or created it in the wrong location."
85+
exit 1
86+
fi
87+
JAVA_DB=${{ fromJson(steps.analysis.outputs.db-locations).java }}
88+
if [[ ! -d $JAVA_DB ]] || [[ ! $JAVA_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
89+
echo "Did not create a database for Java, or created it in the wrong location."
90+
exit 1
91+
fi
92+
JAVASCRIPT_DB=${{ fromJson(steps.analysis.outputs.db-locations).javascript }}
93+
if [[ ! -d $JAVASCRIPT_DB ]] || [[ ! $JAVASCRIPT_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
94+
echo "Did not create a database for Javascript, or created it in the wrong location."
95+
exit 1
96+
fi
97+
PYTHON_DB=${{ fromJson(steps.analysis.outputs.db-locations).python }}
98+
if [[ ! -d $PYTHON_DB ]] || [[ ! $PYTHON_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
99+
echo "Did not create a database for Python, or created it in the wrong location."
82100
exit 1
83101
fi
84102

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Output the location of CodeQL databases created in the analyze step. [#543](https://github.com/github/codeql-action/pull/543)
6+
57
## 1.0.0 - 31 May 2021
68

79
- Add this changelog file. [#507](https://github.com/github/codeql-action/pull/507)

analyze/action.yml

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
description: Upload the SARIF file
1414
required: false
1515
default: "true"
16+
cleanup-level:
17+
description: "Level of cleanup to perform on CodeQL databases at the end of the analyze step. This should either be 'none' to skip cleanup, or be a valid argument for the --mode flag of the CodeQL CLI command 'codeql database cleanup' as documented at https://codeql.github.com/docs/codeql-cli/manual/database-cleanup"
18+
required: false
19+
default: "brutal"
1620
ram:
1721
description: Override the amount of memory in MB to be used by CodeQL. By default, almost all the memory of the machine is used.
1822
required: false
@@ -34,6 +38,9 @@ inputs:
3438
default: ${{ github.token }}
3539
matrix:
3640
default: ${{ toJson(matrix) }}
41+
outputs:
42+
db-locations:
43+
description: A map from language to absolute path for each database created by CodeQL.
3744
runs:
3845
using: 'node12'
3946
main: '../lib/analyze-action.js'

lib/analyze-action.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)