Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f33e9d0

Browse files
edoardopirovanop0
andauthored
Allow users to input 2.x.y instead of v2.x.y (#7)
* Allow users to input 2.x.y instead of v2.x.y * Fix Linux `find` issue in `list-installed` * Improve test coverage Co-authored-by: Pavel Avgustinov <[email protected]>
1 parent 7125962 commit f33e9d0

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

.github/workflows/pr-checks.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,23 @@ jobs:
4040
- name: Check version pinning
4141
shell: bash
4242
run: |
43-
gh codeql set-version v2.5.9
43+
# Set the version without a v prefix
44+
gh codeql set-version 2.5.9
4445
VERSION=`gh codeql version --format json | jq -r '.version'`
4546
if [[ $VERSION != "2.5.9" ]]; then
4647
echo "::error::Expected version 2.5.9 but got $VERSION"
4748
exit 1
4849
fi
50+
gh codeql list-installed | grep v2.5.9
51+
52+
# Set the version with a v prefix
53+
COUNT_BEFORE=`gh codeql list-installed | wc -l`
54+
gh codeql set-version v2.5.9
55+
COUNT_AFTER=`gh codeql list-installed | wc -l`
56+
if [[ $COUNT_BEFORE != $COUNT_BEFORE ]]; then
57+
echo "::error::Installing an already installed version changed the number of installed versions from $COUNT_BEFORE to $COUNT_AFTER!"
58+
exit 1
59+
fi
4960
5061
- name: Check version unpinning
5162
shell: bash
@@ -56,3 +67,14 @@ jobs:
5667
echo "::error::Expected latest version but got 2.5.9"
5768
exit 1
5869
fi
70+
71+
- name: Check getting nightly version
72+
shell: bash
73+
run: |
74+
gh codeql set-channel nightly
75+
gh codeql set-version codeql-bundle-20210831-manual
76+
VERSION=`gh codeql version --format json | jq -r '.version'`
77+
if [[ $VERSION != "2.6.0+202108311306" ]]; then
78+
echo "::error::Expected version 2.6.0+202108311306 but got $VERSION"
79+
exit 1
80+
fi

gh-codeql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ function set_version() {
122122
elif [ "$version" = "latest" ]; then
123123
version="$(gh api "repos/$repo/releases/latest" --jq ".tag_name")"
124124
fi
125+
if [ $repo = 'github/codeql-cli-binaries' ] && [[ "$version" != v* ]] ; then
126+
# Versions in github/codeql-cli-binaries have tags prefixed with v; we add this in if the user forgot.
127+
version="v$version"
128+
fi
125129
download "$version"
126130
gh config set extensions.codeql.version "$version"
127131
}
@@ -141,7 +145,7 @@ fi
141145

142146
# Handle the list-installed command.
143147
if [ "$1" = "list-installed" ]; then
144-
( cd "$rootdir/dist/$channel" ; find . -depth 1 -type d | cut -c3- ; )
148+
( cd "$rootdir/dist/$channel" ; find . -mindepth 1 -maxdepth 1 -type d | cut -c3- ; )
145149
exit 0
146150
fi
147151

0 commit comments

Comments
 (0)