diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index b090a65..629d78d 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -40,12 +40,23 @@ jobs: - name: Check version pinning shell: bash run: | - gh codeql set-version v2.5.9 + # Set the version without a v prefix + gh codeql set-version 2.5.9 VERSION=`gh codeql version --format json | jq -r '.version'` if [[ $VERSION != "2.5.9" ]]; then echo "::error::Expected version 2.5.9 but got $VERSION" exit 1 fi + gh codeql list-installed | grep v2.5.9 + + # Set the version with a v prefix + COUNT_BEFORE=`gh codeql list-installed | wc -l` + gh codeql set-version v2.5.9 + COUNT_AFTER=`gh codeql list-installed | wc -l` + if [[ $COUNT_BEFORE != $COUNT_BEFORE ]]; then + echo "::error::Installing an already installed version changed the number of installed versions from $COUNT_BEFORE to $COUNT_AFTER!" + exit 1 + fi - name: Check version unpinning shell: bash @@ -56,3 +67,14 @@ jobs: echo "::error::Expected latest version but got 2.5.9" exit 1 fi + + - name: Check getting nightly version + shell: bash + run: | + gh codeql set-channel nightly + gh codeql set-version codeql-bundle-20210831-manual + VERSION=`gh codeql version --format json | jq -r '.version'` + if [[ $VERSION != "2.6.0+202108311306" ]]; then + echo "::error::Expected version 2.6.0+202108311306 but got $VERSION" + exit 1 + fi \ No newline at end of file diff --git a/gh-codeql b/gh-codeql index e3a0573..33ad90e 100755 --- a/gh-codeql +++ b/gh-codeql @@ -122,6 +122,10 @@ function set_version() { elif [ "$version" = "latest" ]; then version="$(gh api "repos/$repo/releases/latest" --jq ".tag_name")" fi + if [ $repo = 'github/codeql-cli-binaries' ] && [[ "$version" != v* ]] ; then + # Versions in github/codeql-cli-binaries have tags prefixed with v; we add this in if the user forgot. + version="v$version" + fi download "$version" gh config set extensions.codeql.version "$version" } @@ -141,7 +145,7 @@ fi # Handle the list-installed command. if [ "$1" = "list-installed" ]; then - ( cd "$rootdir/dist/$channel" ; find . -depth 1 -type d | cut -c3- ; ) + ( cd "$rootdir/dist/$channel" ; find . -mindepth 1 -maxdepth 1 -type d | cut -c3- ; ) exit 0 fi