Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 'source-root' input to the init Action #607

Merged
merged 21 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
42babdf
Add 'source-root' input to init action
mario-campos Jun 29, 2021
337ae83
Make 'source-root' init input relative to github.workspace
mario-campos Jun 29, 2021
a05a7f9
Remove '${{ github.workspace }}' from action.yml
mario-campos Jun 29, 2021
57f584a
Update CHANGELOG for PR #607
mario-campos Jun 29, 2021
e1cd524
Recompile JS files to bring JS inline with TS for PR #607
mario-campos Jun 29, 2021
66df091
Refer to $GITHUB_WORKSPACE specifically in source-root description
mario-campos Jun 30, 2021
35e1b55
Use path.resolve instead of path.join for sourceRoot
mario-campos Jun 30, 2021
a607042
Recompile code after accepting suggestions from PR #607 review
mario-campos Jun 30, 2021
c6728b6
Merge branch 'main' into source-root-input
adityasharad Jul 1, 2021
45c0f11
Clarify 'source-root' description to include default path
mario-campos Jul 1, 2021
c78fb87
Add test case for 'source-root' input to 'init' Action
mario-campos Jul 1, 2021
028f98f
Use different config file for testing 'source-root' input
mario-campos Jul 1, 2021
67d6f79
Delete 'packaing' from source-root test job name
mario-campos Jul 1, 2021
1c69fae
Avoid moving repo files out of \$GITHUB_WORKSPACE in 'source-root' test
mario-campos Jul 1, 2021
2ca807c
Merge branch 'source-root-input' of github.com:mario-campos/codeql-ac…
mario-campos Jul 1, 2021
12f1cff
Rename CodeQL action paths in 'source-root' test to reflect repo paths
mario-campos Jul 1, 2021
2c0da4b
Remove build.sh step from 'source-root' test
mario-campos Jul 1, 2021
b9217ca
Test presence of database instead of results of analysis
mario-campos Jul 2, 2021
06c6845
Add analyze step to 'source-root' input test case
mario-campos Jul 2, 2021
a4a91a8
Merge branch 'main' into source-root-input
mario-campos Jul 2, 2021
9932052
Merge branch 'main' into source-root-input
aibaars Jul 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -894,3 +894,44 @@ jobs:
- name: Build code
run: ./build.sh
- uses: ./../action/analyze

test-packaging-javascript-source-root:
mario-campos marked this conversation as resolved.
Show resolved Hide resolved
needs: [check-js, check-node-modules]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Move codeql-action
shell: bash
run: |
mkdir ../action
mv * .github ../action/
mv ../action/tests/multi-language-repo/{*,.github} .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is the problem: it will move all the contents of multi-language-repo into the current directory, and not preserve the tests/multi-language-repo enclosing directories.

One option to try might be to avoid these moves entirely, and set source-root as you've done below. The moves are needed for other tests because they scan the entire repo from the workspace root, but the whole point of source-root is to customise that behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. That makes sense.

mv ../action/.github/workflows .github
- uses: ./../action/init
with:
config-file: ".github/codeql/codeql-config-packaging.yml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may be able to remove this, and keep the test focused on only the source-root feature.

languages: javascript
source-root: tests/multi-language-repo
- name: Build code
shell: bash
run: ./build.sh
- uses: ./../action/analyze
with:
output: "${{ runner.temp }}/results"
env:
TEST_MODE: true
- name: Assert Results
run: |
cd "$RUNNER_TEMP/results"
# We should have 3 hits from these rules
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"

# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
echo "Found matching rules '$RULES'"
if [ "$RULES" != "$EXPECTED_RULES" ]; then
echo "Did not match expected rules '$EXPECTED_RULES'."
exit 1
fi

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [UNRELEASED]

- The `init` step of the Action now supports a `source-root` input as a path to the root source-code directory. By default, the path is relative to $GITHUB_WORKSPACE. [#607](https://github.com/github/codeql-action/pull/607)
- The `analyze` step of the Action now supports a `skip-queries` option to merely build the CodeQL database without analyzing. This functionality is not present in the runner. Additionally, the step will no longer fail if it encounters a finalized database, and will instead continue with query execution. [#602](https://github.com/github/codeql-action/pull/602)
- Update the warning message when the baseline lines of code count is unavailable. [#608](https://github.com/github/codeql-action/pull/608)

Expand Down
3 changes: 3 additions & 0 deletions init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ inputs:
description: Try to auto-install your python dependencies
required: true
default: 'true'
source-root:
description: Path of the root source code directory, relative to $GITHUB_WORKSPACE.
required: false
outputs:
codeql-path:
description: The path of the CodeQL binary used for analysis
Expand Down
4 changes: 3 additions & 1 deletion lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions lib/init.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading