|
| 1 | +# Tests that the generated code scanning config file contains the expected contents |
| 2 | + |
| 3 | +name: Code-Scanning config CLI tests |
| 4 | +env: |
| 5 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 6 | + CODEQL_PASS_CONFIG_TO_CLI: true |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - releases/v1 |
| 13 | + - releases/v2 |
| 14 | + pull_request: |
| 15 | + types: |
| 16 | + - opened |
| 17 | + - synchronize |
| 18 | + - reopened |
| 19 | + - ready_for_review |
| 20 | + workflow_dispatch: {} |
| 21 | + |
| 22 | +jobs: |
| 23 | + code-scanning-config-tests: |
| 24 | + # Code-Scanning config not created because environment variable is not set |
| 25 | + name: Code Scanning Configuration tests |
| 26 | + timeout-minutes: 45 |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Check out repository |
| 30 | + uses: actions/checkout@v3 |
| 31 | + - name: Prepare test |
| 32 | + id: prepare-test |
| 33 | + uses: ./.github/prepare-test |
| 34 | + with: |
| 35 | + version: latest |
| 36 | + |
| 37 | + - name: Empty file |
| 38 | + uses: ./../action/.github/check-codescanning-config |
| 39 | + with: |
| 40 | + expected-config-file-contents: "{}" |
| 41 | + languages: javascript |
| 42 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 43 | + |
| 44 | + - name: Packs from input |
| 45 | + uses: ./../action/.github/check-codescanning-config |
| 46 | + with: |
| 47 | + expected-config-file-contents: | |
| 48 | + { |
| 49 | + "packs": [" dsp-testing/[email protected]", "dsp-testing/codeql-pack2" ] |
| 50 | + } |
| 51 | + languages: javascript |
| 52 | + packs: dsp-testing/[email protected], dsp-testing/codeql-pack2 |
| 53 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 54 | + |
| 55 | + - name: Packs from input with + |
| 56 | + uses: ./../action/.github/check-codescanning-config |
| 57 | + with: |
| 58 | + expected-config-file-contents: | |
| 59 | + { |
| 60 | + "packs": ["dsp-testing/[email protected]", "dsp-testing/codeql-pack2" ] |
| 61 | + } |
| 62 | + languages: javascript |
| 63 | + packs: + dsp-testing/[email protected], dsp-testing/codeql-pack2 |
| 64 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 65 | + |
| 66 | + - name: Queries from input |
| 67 | + uses: ./../action/.github/check-codescanning-config |
| 68 | + with: |
| 69 | + expected-config-file-contents: | |
| 70 | + { |
| 71 | + "queries": [{ "uses": "./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql" }] |
| 72 | + } |
| 73 | + languages: javascript |
| 74 | + queries: ./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql |
| 75 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 76 | + |
| 77 | + - name: Queries from input with + |
| 78 | + uses: ./../action/.github/check-codescanning-config |
| 79 | + with: |
| 80 | + expected-config-file-contents: | |
| 81 | + { |
| 82 | + "queries": [{ "uses": "./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql" }] |
| 83 | + } |
| 84 | + languages: javascript |
| 85 | + queries: + ./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql |
| 86 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 87 | + |
| 88 | + - name: Queries and packs from input with + |
| 89 | + uses: ./../action/.github/check-codescanning-config |
| 90 | + with: |
| 91 | + expected-config-file-contents: | |
| 92 | + { |
| 93 | + "queries": [{ "uses": "./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql" }], |
| 94 | + "packs": ["dsp-testing/[email protected]", "dsp-testing/codeql-pack2" ] |
| 95 | + } |
| 96 | + languages: javascript |
| 97 | + queries: + ./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql |
| 98 | + packs: + dsp-testing/[email protected], dsp-testing/codeql-pack2 |
| 99 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 100 | + |
| 101 | + - name: Queries and packs from config |
| 102 | + uses: ./../action/.github/check-codescanning-config |
| 103 | + with: |
| 104 | + expected-config-file-contents: | |
| 105 | + { |
| 106 | + "queries": [{ "uses": "./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql" }], |
| 107 | + "packs": { |
| 108 | + "javascript": ["dsp-testing/[email protected]", "dsp-testing/codeql-pack2" ] |
| 109 | + } |
| 110 | + } |
| 111 | + languages: javascript |
| 112 | + queries: + ./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql |
| 113 | + packs: + dsp-testing/[email protected], dsp-testing/codeql-pack2 |
| 114 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 115 | + |
| 116 | + - name: Queries and packs from config overriden by input |
| 117 | + uses: ./../action/.github/check-codescanning-config |
| 118 | + with: |
| 119 | + expected-config-file-contents: | |
| 120 | + { |
| 121 | + "queries": [{ "uses": "./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql" }], |
| 122 | + "packs": ["codeql/javascript-queries"] |
| 123 | + } |
| 124 | + languages: javascript |
| 125 | + queries: ./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql |
| 126 | + packs: codeql/javascript-queries |
| 127 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 128 | + |
| 129 | + - name: Queries and packs from config merging with input |
| 130 | + uses: ./../action/.github/check-codescanning-config |
| 131 | + with: |
| 132 | + expected-config-file-contents: | |
| 133 | + { |
| 134 | + "queries": [ |
| 135 | + { "uses": "./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql" }, |
| 136 | + { "uses": "./codeql-qlpacks/complex-javascript-qlpack/foo2/show_ifs.ql" } |
| 137 | + ], |
| 138 | + "packs": { |
| 139 | + "javascript": ["dsp-testing/[email protected]", "dsp-testing/codeql-pack2", "codeql/javascript-queries" ] |
| 140 | + } |
| 141 | + } |
| 142 | + languages: javascript |
| 143 | + queries: + ./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql |
| 144 | + packs: + codeql/javascript-queries |
| 145 | + config-file: tests/multi-language-repo/.github/codeql/queries-and-packs-config.yml |
| 146 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 147 | + |
| 148 | + - name: Multi-language packs from config |
| 149 | + uses: ./../action/.github/check-codescanning-config |
| 150 | + with: |
| 151 | + expected-config-file-contents: | |
| 152 | + { |
| 153 | + "packs": { |
| 154 | + "javascript": ["dsp-testing/[email protected]", "dsp-testing/codeql-pack2", "codeql/javascript-queries" ], |
| 155 | + "ruby": ["codeql/i-dont-exist", "codeql/hucairz"] |
| 156 | + } |
| 157 | + } |
| 158 | + languages: javascript |
| 159 | + config-file: tests/multi-language-repo/.github/codeql/multi-language-packs-config copy.yml |
| 160 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 161 | + |
| 162 | + - name: Other config properties |
| 163 | + uses: ./../action/.github/check-codescanning-config |
| 164 | + with: |
| 165 | + expected-config-file-contents: | |
| 166 | + { |
| 167 | + "name": "Config using all properties", |
| 168 | + "packs": ["codeql/javascript-queries" ], |
| 169 | + "disable-default-queries": true, |
| 170 | + "paths-ignore": ["xxx"], |
| 171 | + "paths": ["yyy"] |
| 172 | + } |
| 173 | + languages: javascript |
| 174 | + packs: + codeql/javascript-queries |
| 175 | + config-file: tests/multi-language-repo/.github/codeql/other-config-properties.yml |
| 176 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
0 commit comments