Skip to content

Commit c78fb87

Browse files
committed
Add test case for 'source-root' input to 'init' Action
1 parent 45c0f11 commit c78fb87

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

.github/workflows/pr-checks.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,3 +894,44 @@ jobs:
894894
- name: Build code
895895
run: ./build.sh
896896
- uses: ./../action/analyze
897+
898+
test-packaging-javascript-source-root:
899+
needs: [check-js, check-node-modules]
900+
runs-on: ubuntu-latest
901+
902+
steps:
903+
- uses: actions/checkout@v2
904+
- name: Move codeql-action
905+
shell: bash
906+
run: |
907+
mkdir ../action
908+
mv * .github ../action/
909+
mv ../action/tests/multi-language-repo/{*,.github} .
910+
mv ../action/.github/workflows .github
911+
- uses: ./../action/init
912+
with:
913+
config-file: ".github/codeql/codeql-config-packaging2.yml"
914+
languages: javascript
915+
source-root: tests/multi-language-repo
916+
- name: Build code
917+
shell: bash
918+
run: ./build.sh
919+
- uses: ./../action/analyze
920+
with:
921+
output: "${{ runner.temp }}/results"
922+
env:
923+
TEST_MODE: true
924+
- name: Assert Results
925+
run: |
926+
cd "$RUNNER_TEMP/results"
927+
# We should have 3 hits from these rules
928+
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
929+
930+
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
931+
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
932+
echo "Found matching rules '$RULES'"
933+
if [ "$RULES" != "$EXPECTED_RULES" ]; then
934+
echo "Did not match expected rules '$EXPECTED_RULES'."
935+
exit 1
936+
fi
937+

0 commit comments

Comments
 (0)