Skip to content

Commit bc05cda

Browse files
committed
Implement fetch-codeql using 'gh codeql'
1 parent 1737d08 commit bc05cda

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

.github/actions/fetch-codeql/action.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@ description: Fetches the latest version of CodeQL
33
runs:
44
using: composite
55
steps:
6-
- name: Select platform - Linux
7-
if: runner.os == 'Linux'
8-
shell: bash
9-
run: echo "GA_CODEQL_CLI_PLATFORM=linux64" >> $GITHUB_ENV
10-
11-
- name: Select platform - MacOS
12-
if: runner.os == 'MacOS'
13-
shell: bash
14-
run: echo "GA_CODEQL_CLI_PLATFORM=osx64" >> $GITHUB_ENV
15-
166
- name: Fetch CodeQL
177
shell: bash
188
run: |
19-
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | grep -v beta | sort --version-sort | tail -1)
20-
gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-$GA_CODEQL_CLI_PLATFORM.zip "$LATEST"
21-
unzip -q -d "${RUNNER_TEMP}" codeql-$GA_CODEQL_CLI_PLATFORM.zip
22-
echo "${RUNNER_TEMP}/codeql" >> "${GITHUB_PATH}"
9+
gh extension install github/gh-codeql
10+
gh codeql set-channel release
11+
gh codeql version
12+
gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_PATH}"
2313
env:
2414
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/check-qldoc.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- name: Install CodeQL
18-
run: |
19-
gh extension install github/gh-codeql
20-
gh codeql set-channel nightly
21-
gh codeql version
22-
env:
23-
GITHUB_TOKEN: ${{ github.token }}
24-
2517
- uses: actions/checkout@v3
2618
with:
2719
fetch-depth: 2
2820

21+
- name: Install CodeQL
22+
uses: ./.github/actions/fetch-codeql
23+
2924
- name: Check QLdoc coverage
3025
shell: bash
3126
run: |
@@ -34,15 +29,15 @@ jobs:
3429
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!swift)[a-z]*/ql/lib' || true; } | sort -u)"
3530
for pack_dir in ${changed_lib_packs}; do
3631
lang="${pack_dir%/ql/lib}"
37-
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"
32+
codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"
3833
done
3934
git checkout HEAD^
4035
for pack_dir in ${changed_lib_packs}; do
4136
# When we add a new language, pack_dir would not exist in HEAD^.
4237
# In this case the right thing to do is to skip the check.
4338
[[ ! -d "${pack_dir}" ]] && continue
4439
lang="${pack_dir%/ql/lib}"
45-
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-baseline.txt" --dir="${pack_dir}"
40+
codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-baseline.txt" --dir="${pack_dir}"
4641
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-current.txt" | sort -u > "${RUNNER_TEMP}/current-undocumented.txt"
4742
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-baseline.txt" | sort -u > "${RUNNER_TEMP}/baseline-undocumented.txt"
4843
UNDOCUMENTED="$(grep -f <(comm -13 "${RUNNER_TEMP}/baseline-undocumented.txt" "${RUNNER_TEMP}/current-undocumented.txt") "${RUNNER_TEMP}/${lang}-current.txt" || true)"

0 commit comments

Comments
 (0)