Skip to content

Commit a66b44a

Browse files
authored
Merge e68056c into cbdf0df
2 parents cbdf0df + e68056c commit a66b44a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1585
-395
lines changed

.github/workflows/post-release-mergeback.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ jobs:
124124
--base "$BASE_BRANCH" \
125125
--title "$PR_TITLE" \
126126
--body "$PR_BODY" \
127-
"$DRAFT"
127+
${DRAFT:+"$DRAFT"} # no quotes around $DRAFT. gh will error out if there is an empty ""

.github/workflows/pr-checks.yml

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,81 @@ 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."
100+
exit 1
101+
fi
102+
103+
# Packaging test that runs against a javascript database
104+
test-packaging-javascript:
105+
needs: [check-js, check-node-modules]
106+
runs-on: ubuntu-latest
107+
108+
steps:
109+
- uses: actions/checkout@v2
110+
- name: Move codeql-action
111+
shell: bash
112+
run: |
113+
mkdir ../action
114+
mv * .github ../action/
115+
mv ../action/tests/multi-language-repo/{*,.github} .
116+
mv ../action/.github/workflows .github
117+
- uses: ./../action/init
118+
with:
119+
config-file: ".github/codeql/codeql-config-packaging.yml"
120+
languages: javascript
121+
# TODO: this is temporary until we have a release that includes the latest packaging work.
122+
tools: https://github.com/dsp-testing/aeisenberg-codeql-action-packaging/releases/download/codeql-bundle-20210606/codeql-bundle-linux64.tar.gz
123+
124+
- name: Build code
125+
shell: bash
126+
run: ./build.sh
127+
- uses: ./../action/analyze
128+
with:
129+
output: "${{ runner.temp }}/results"
130+
env:
131+
TEST_MODE: true
132+
- name: Assert Results
133+
run: |
134+
cd "$RUNNER_TEMP/results"
135+
# We should have 3 hits from these rules
136+
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
137+
138+
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
139+
RULES="$(cat javascript-custom.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
140+
echo "Found matching rules '$RULES'"
141+
if [ "$RULES" != "$EXPECTED_RULES" ]; then
142+
echo "Did not match expected rules '$EXPECTED_RULES'."
82143
exit 1
83144
fi
84145

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [UNRELEASED]
44

5+
## 1.0.1 - 07 Jun 2021
6+
7+
- Pass the `--sarif-group-rules-by-pack` argument to CodeQL CLI invocations that generate SARIF. This means the SARIF rule object for each query will now be found underneath its corresponding query pack in `runs[].tool.extensions`. [#546](https://github.com/github/codeql-action/pull/546)
8+
- Output the location of CodeQL databases created in the analyze step. [#543](https://github.com/github/codeql-action/pull/543)
9+
510
## 1.0.0 - 31 May 2021
611

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

analyze/action.yml

Lines changed: 7 additions & 0 deletions
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/analysis-paths.test.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analysis-paths.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)