name: Query Filter Test
description: Runs a test of query filters using the check SARIF action
inputs:
  sarif-file:
    required: true
    description: The SARIF file to check

  queries-run:
    required: true
    description: |
      Comma separated list of query ids that should be included in this SARIF file.

  queries-not-run:
    required: true
    description: |
      Comma separated list of query ids that should NOT be included in this SARIF file.

  config-file:
    required: true
    description: |
      The location of the codeql configuration file to use.

  tools:
    required: true
    description: |
      The version of CodeQL passed to the `tools` input of the init action.
      This can be any of the following:

      - A local path to a tarball containing the CodeQL tools, or
      - A URL to a GitHub release assets containing the CodeQL tools, or
      - A special value `linked` which is forcing the use of the CodeQL tools
        that the action has been bundled with.

      If not specified, the Action will check in several places until it finds
      the CodeQL tools.

runs:
  using: composite
  steps:
    - uses: ./../action/init
      with:
        languages: javascript
        config-file: ${{ inputs.config-file }}
        tools: ${{ inputs.tools }}
        db-location: ${{ runner.temp }}/query-filter-test
      env:
        CODEQL_ACTION_TEST_MODE: "true"
    - uses: ./../action/analyze
      with:
        output: ${{ runner.temp }}/results
        upload: never
      env:
        CODEQL_ACTION_TEST_MODE: "true"
    - name: Check SARIF
      uses: ./../action/.github/actions/check-sarif
      with:
        sarif-file:  ${{ inputs.sarif-file }}
        queries-run: ${{ inputs.queries-run}}
        queries-not-run: ${{ inputs.queries-not-run}}
    - name: Cleanup after test
      shell: bash
      run: rm -rf "$RUNNER_TEMP/results" "$RUNNER_TEMP/query-filter-test"
