From 65961877cbf19a3c40b7f6c3381f2e170f5e4abb Mon Sep 17 00:00:00 2001 From: Edoardo Pirovano Date: Fri, 17 Sep 2021 14:50:54 +0100 Subject: [PATCH 1/6] Allow users to input 2.x.y instead of v2.x.y --- .github/workflows/pr-checks.yml | 2 +- gh-codeql | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index b090a65..3f9a873 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -40,7 +40,7 @@ jobs: - name: Check version pinning shell: bash run: | - gh codeql set-version v2.5.9 + 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" diff --git a/gh-codeql b/gh-codeql index e3a0573..3576c81 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' ] && ! (echo $version | grep -q '^v' ); then + # Versions in github/codeql-cli-binaries have tags prefixed with v, add this in if the user forgot + version="v$version" + fi download "$version" gh config set extensions.codeql.version "$version" } From 2c2ecf59ab97d954f2c2442926f793b658f67d1c Mon Sep 17 00:00:00 2001 From: Edoardo Pirovano <6748066+edoardopirovano@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:31:38 +0100 Subject: [PATCH 2/6] Update gh-codeql Co-authored-by: Pavel Avgustinov <54942558+p0@users.noreply.github.com> --- gh-codeql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gh-codeql b/gh-codeql index 3576c81..9a543e2 100755 --- a/gh-codeql +++ b/gh-codeql @@ -122,8 +122,8 @@ function set_version() { elif [ "$version" = "latest" ]; then version="$(gh api "repos/$repo/releases/latest" --jq ".tag_name")" fi - if [ $repo = 'github/codeql-cli-binaries' ] && ! (echo $version | grep -q '^v' ); then - # Versions in github/codeql-cli-binaries have tags prefixed with v, add this in if the user forgot + 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" From f98907ac6ff65ce151d5ef3ea44850caabd8a3be Mon Sep 17 00:00:00 2001 From: Edoardo Pirovano Date: Fri, 17 Sep 2021 16:33:41 +0100 Subject: [PATCH 3/6] Add test for downloading nightly --- .github/workflows/pr-checks.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 3f9a873..6f9dc07 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -56,3 +56,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 From 94c563b973c37e27673cfcecaeca059ab39fd08d Mon Sep 17 00:00:00 2001 From: Edoardo Pirovano Date: Fri, 17 Sep 2021 16:48:52 +0100 Subject: [PATCH 4/6] Fix typo in `list-installed` --- gh-codeql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gh-codeql b/gh-codeql index 9a543e2..8f7b6ed 100755 --- a/gh-codeql +++ b/gh-codeql @@ -145,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 . -maxdepth 1 -type d | cut -c3- ; ) exit 0 fi From 93bd153fb8d9079b7ada1042c54f0e3749777b3e Mon Sep 17 00:00:00 2001 From: Edoardo Pirovano Date: Fri, 17 Sep 2021 16:49:19 +0100 Subject: [PATCH 5/6] Expand version pinning test --- .github/workflows/pr-checks.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 6f9dc07..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: | + # 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 From a3ae270c4abafffb99a536a5b1fbb9dd0c80df03 Mon Sep 17 00:00:00 2001 From: Edoardo Pirovano <6748066+edoardopirovano@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:57:02 +0100 Subject: [PATCH 6/6] Update gh-codeql Co-authored-by: Pavel Avgustinov <54942558+p0@users.noreply.github.com> --- gh-codeql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gh-codeql b/gh-codeql index 8f7b6ed..33ad90e 100755 --- a/gh-codeql +++ b/gh-codeql @@ -145,7 +145,7 @@ fi # Handle the list-installed command. if [ "$1" = "list-installed" ]; then - ( cd "$rootdir/dist/$channel" ; find . -maxdepth 1 -type d | cut -c3- ; ) + ( cd "$rootdir/dist/$channel" ; find . -mindepth 1 -maxdepth 1 -type d | cut -c3- ; ) exit 0 fi